sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function run(OutputInterface $output)
{
$file = $this->getParameter('file');
if (strpos($file, '/') !== 0) {
$file = getcwd().'/'.ltrim($file, '/');
}
$content = $this->getParameter('content');
if ($this->getParameter('append')) {
$content = fi... | {@inheritdoc} | entailment |
public function normalize($node, $format = null, array $context = [])
{
$res = [];
foreach ($node->getProperties() as $property) {
if (false === $this->isPropertyEditable($property)) {
continue;
}
$propertyType = $property->getType();
... | {@inheritdoc} | entailment |
public function denormalize($data, $class, $format = null, array $context = [])
{
if (!$data) {
throw new \InvalidArgumentException(
'Editor returned nothing .. nodes must have at least one property (i.e. the jcr:primaryType property)'
);
}
if (!isset... | {@inheritdoc} | entailment |
private function isPropertyEditable(PropertyInterface $property)
{
// do not serialize binary objects
if (false === $this->allowBinary && PropertyType::BINARY == $property->getType()) {
$this->notes[] = sprintf(
'Binary property "%s" has been omitted', $property->getName(... | Return false if property type is not editable.
(e.g. property type is binary)
@return bool | entailment |
public function findTaskByType($type)
{
foreach ($this->tasks as $task) {
if ($task->getName() === $type) {
return $task;
}
}
throw new TaskNotFoundException($type);
} | @param string $type
@throws TaskNotFoundException
@return TaskInterface|AbstractTask | entailment |
public function create(array $data)
{
$data = self::mergeData($data, [
'finished' => false,
'smContactTaskReq' => [
'id' => false,
],
]);
return $this->client->doPost('contact/updateTask', $data);
} | Create new task.
@param array $data Task data
@return array | entailment |
public function update($taskId, array $data)
{
$data = self::mergeData($data, [
'finished' => false,
'smContactTaskReq' => [
'id' => $taskId,
],
]);
return $this->client->doPost('contact/updateTask', $data);
} | Update task.
@param string $taskId Task internal ID
@param array $data Task data
@return array | entailment |
static public function dump($value)
{
if ('1.1' === sfYaml::getSpecVersion())
{
$trueValues = array('true', 'on', '+', 'yes', 'y');
$falseValues = array('false', 'off', '-', 'no', 'n');
}
else
{
$trueValues = array('true');
$falseValues = array('false');
}
switch (... | Dumps a given PHP variable to a YAML string.
@param mixed $value The PHP variable to convert
@return string The YAML string representing the PHP array | entailment |
static protected function parseMapping($mapping, &$i = 0)
{
$output = array();
$len = strlen($mapping);
$i += 1;
// {foo: bar, bar:foo, ...}
while ($i < $len)
{
switch ($mapping[$i])
{
case ' ':
case ',':
++$i;
continue 2;
case '}':
... | Parses a mapping to a YAML string.
@param string $mapping
@param integer $i
@return string A YAML string | entailment |
static protected function evaluateScalar($scalar)
{
$scalar = trim($scalar);
if ('1.1' === sfYaml::getSpecVersion())
{
$trueValues = array('true', 'on', '+', 'yes', 'y');
$falseValues = array('false', 'off', '-', 'no', 'n');
}
else
{
$trueValues = array('true');
$false... | Evaluates scalars and replaces magic values.
@param string $scalar
@return string A YAML string | entailment |
public function findAverageNote(Thread $thread)
{
return $this->repository->createQueryBuilder('c')
->select('avg(c.note)')
->where('c.private <> :private')
->andWhere('c.thread = :thread')
->setParameters([
'private' => 1,
'thr... | Returns Thread average note.
@param Thread $thread
@return float | entailment |
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper->add('id');
if (interface_exists('Sonata\\ClassificationBundle\\Model\\CategoryInterface')) {
$formMapper->add('category');
}
$formMapper
->add('permalink')
->add('isCom... | {@inheritdoc} | entailment |
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('id');
if (interface_exists('Sonata\\ClassificationBundle\\Model\\CategoryInterface')) {
$datagridMapper->add('category');
}
$datagridMapper
->add('permalink')... | {@inheritdoc} | entailment |
public static function sync_to_server($src, $server_host, $remote_path, $rsync_login = '', $transport = 'ssh')
{
if (strlen($rsync_login) > 0) {
$rsync_login .= '@';
}
if (is_string($src)) {
// sync contents of dir, so adding trailing slash
if ($src[strle... | put one or several local-paths onto server.
if $src is string it it treated as a source-dir of objects. if $src is array, it is treated as a list of objects
@param mixed $src
@param string $server_host
@param string $remote_path
@param string $rsync_login (note: this is rsync-login, not transport login)
@param string ... | entailment |
protected function tableName(string $schemaName, string $typeName): string
{
return implode('_', [$this->prefix, $schemaName, $typeName]);
} | @param string $schemaName
@param string $typeName
@return string | entailment |
public function paginate(Response $response, $limit = null)
{
// If there's nothing to paginate, return response as-is
if (!$response->hasPages() || $limit === 0) {
return $response;
}
$next = $this->request('GET', $response->nextUrl());
$merged = $response->me... | {@inheritDoc} | entailment |
protected function resolveExceptionClass(ClientException $exception)
{
$response = $exception->getResponse()->getBody();
$response = json_decode($response->getContents());
if ($response === null) {
return new Exception($exception->getMessage());
}
$meta = iss... | Parses a ``ClientException`` for any specific exceptions thrown by the
API in the response body. If the response body is not in JSON format,
an ``Exception`` is returned.
Check a ``ClientException`` to see if it has an associated
``ResponseInterface`` object.
@param ClientException $exception
@return Exception | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('bldr');
$rootNode
->addDefaultsIfNotSet()
->children()
->scalarNode('name')
->defaultValue('')
->end()
... | {@inheritDoc} | entailment |
public function getFrontEndFields($param = null)
{
$fields = FieldList::create(
TextField::create('Name'),
TextField::create('Email'),
HiddenField::create('EventID')
);
$this->extend('updateFrontEndFields', $fields);
return $fields;
} | Frontend fields | entailment |
public function doRegister($data, $form)
{
$r = new EventRegistration();
$form->saveInto($r);
$r->write();
return "Thanks. We've received your registration.";
} | Register action
@param type $data
@param type $form
@return \SS_HTTPResponse | entailment |
public function hydrate(TypeSchema $type, array $data = []) : Metadata
{
if (!array_key_exists('id', $data)) {
throw HydrationException::missingId();
}
$id = new MetadataId($data['id']);
unset($data['id']);
$fieldValues = [];
foreach ($data as $key => $v... | @param TypeSchema $type
@param array $data
@return Metadata
@throws HydrationException | entailment |
private function associate(Association $association): Metadata
{
$data = $this->storage->findBy(
$association->schema(),
$association->type()->name(),
$association->criteria()
);
return $this->hydrate($association->type(), $data);
} | @param Association $association
@return Metadata
@throws HydrationException | entailment |
private function extractContentIds($data)
{
$ids = [];
foreach ($data->response->docs as $doc) {
$ids[] = $doc->content_id_id;
}
return $ids;
} | @param mixed $data
@return array | entailment |
public function git_run($command)
{
$git = escapeshellarg(pake_which('git'));
if (self::$needs_work_tree_workaround === true) {
$cmd = '(cd '.escapeshellarg($this->repository_path).' && '.$git.' '.$command.')';
} else {
$cmd = $git;
$cmd .= ' --git-dir='.... | Run git-command in context of repository
This method is useful for implementing some custom command, not implemented by pake.
In cases when pake has native support for command, please use it, as it will provide better compatibility
@param $command | entailment |
public static function init($path, $template_path = null, $shared = false)
{
pake_mkdirs($path);
if (false === $shared)
$shared = 'false';
elseif (true === $shared)
$shared = 'true';
elseif (is_int($shared))
$shared = sprintf("%o", $shared);
... | new git-repo | entailment |
public static function add_to_repo($repository_path, $files = null)
{
$repo = new pakeGit($repository_path);
$repo->add($files);
return $repo;
} | one-time operations | entailment |
public function createAndSend($data, $method)
{
if (!in_array($method, array('Email', 'Letter', 'Email+Letter')))
throw new InvalidFieldValueError("Invalid method, should be 'Email', 'Letter' or 'Email+Letter'");
$billogram = $this->create($data);
try {
$billogram->se... | Creates and sends a billogram using the $data and $method supplied.
@param $data
@param $method
@throws \Billogram\Api\Exceptions\InvalidFieldValueError
@return \Billogram\Api\Objects\BillogramObject | entailment |
final public function load(array $config, SymfonyContainerBuilder $container)
{
$this->originalConfiguration = $config;
$configClass = $this->getConfigurationClass();
if ($configClass !== false) {
$this->config = (new Processor())->processConfiguration(new $configClass(), $confi... | {@inheritDoc} | entailment |
protected function addDecoratedTask($name, $class, $parentName, array $arguments = [])
{
return $this->container->setDefinition($name, new DefinitionDecorator($parentName))
->setClass($class)
->setArguments($arguments)
->addTag('bldr')
;
} | @param $name
@param $class
@param $parentName
@param array $arguments
@return Definition | entailment |
public function moveTo($targetPath) : void
{
if (! ($this->stream instanceof StreamInterface))
{
throw new \RuntimeException('The uploaded file already moved');
}
if (! (\UPLOAD_ERR_OK === $this->error))
{
throw new \RuntimeException('The uploaded file cannot be moved due to an error');
}
$folder... | {@inheritDoc} | entailment |
public function registerTableAttributes(RegisterElementTableAttributesEvent $event)
{
$event->tableAttributes['elementMap_incomingReferenceCount'] = ['label' => Craft::t('element-map', 'References From (Count)')];
$event->tableAttributes['elementMap_outgoingReferenceCount'] = ['label' => Craft::t('element-map', 'R... | Handler for the Element::EVENT_REGISTER_TABLE_ATTRIBUTES event. | entailment |
public function getTableAttributeHtml(SetElementTableAttributeHtmlEvent $event)
{
if ($event->attribute == 'elementMap_incomingReferenceCount') {
$event->handled = true;
$entry = $event->sender;
$elements = $this->renderer->getIncomingElements($entry->id, $entry->site->id);
$event->html = Craft::$app->vi... | Handler for the Element::EVENT_SET_TABLE_ATTRIBUTE_HTML event. | entailment |
public function renderEntryElementMap(array &$context)
{
$map = $this->renderer->getElementMap($context['entry']['id'], $context['site']['id']);
return $this->renderMap($map);
} | Renders the element map for an entry within the entry editor, given the current Twig context.
@param array $context The incoming Twig context. | entailment |
public function renderCategoryElementMap(array &$context)
{
$map = $this->renderer->getElementMap($context['category']['id'], $context['site']['id']);
return $this->renderMap($map);
} | Renders the element map for a category within the category editor, given the current Twig context.
@param array $context The incoming Twig context. | entailment |
public function renderUserElementMap(array &$context)
{
$map = $this->renderer->getElementMap($context['user']['id'], Craft::$app->getSites()->getPrimarySite()->id);
return $this->renderMap($map);
} | Renders the element map for a user within the user editor, given the current Twig context.
@param array $context The incoming Twig context. | entailment |
public function renderProductElementMap(array &$context)
{
$map = $this->renderer->getElementMap($context['product']['id'], $context['site']['id']);
return $this->renderMap($map);
} | Renders the element map for a product within the product editor, given the current Twig context.
@param array $context The incoming Twig context. | entailment |
final protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setInput($input);
$this->getApplication()->setBuildName();
$this->setOutput($output);
$this->setHelperSet($this->getApplication()->getHelperSet());
$this->doExecute();
} | {@inheritdoc} | entailment |
public function addEvent($name, EventInterface $event)
{
$this->container->get('bldr.dispatcher')->dispatch($name, $event);
return $this;
} | @param string $name
@param EventInterface $event
@return $this | entailment |
public static function formatted_dates($startObj, $endObj)
{
//Checking if end date is set
$endDateIsset = true;
if (isset($endObj->value)) {
$endDateIsset = false;
}
$startTime = strtotime($startObj->value);
$endTime = strtotime($endObj->value);
... | Formatted Dates
Returns either the event's date or both start and end date if the event spans more than
one date
Format:
Jun 7th - Jun 10th
@param SS_Datetime $startObj
@param SS_Datetime $endObj
@return string | entailment |
public static function formatted_timeframe($startStr, $endStr)
{
$str = null;
if ($startStr == $endStr) {
return null;
}
$startTime = strtotime($startStr->value);
$endTime = strtotime($endStr->value);
if ($startTime == $endTime) {
return nul... | Formatted time frame
Returns either a string or null
Time frame is only applicable if both start and end time is on the same day
@param string $startStr
@param string $endStr
@return string|null | entailment |
public function getFile($strFilename)
{
ob_start();
header("Content-type: text/calendar");
header('Content-Disposition: attachment; filename="' . $strFilename . '"');
echo $this->_strIcs;
ob_flush();
die();
} | getFile
@param string $strFilename the names of the file | entailment |
public static function cleanString($strDirtyString)
{
$arrBadSigns = array('<br />', '<br/>', '<br>', "\r\n", "\r", "\n", "\t", '"');
$arrGoodSigns = array('\n', '\n', '\n', '', '', '', ' ', '\"');
return(trim(str_replace($arrBadSigns, $arrGoodSigns, strip_tags($strDirtyString, '<br>'))));
... | cleanString
@param string $strDirtyString the dirty input string
@return string cleaned string | entailment |
public static function ics_from_sscal($cal)
{
$events = $cal->Events();
$eventsArr = $events->toNestedArray();
//Debug::dump($eventsArr);
//return false;
$ics = new ICSExport($eventsArr);
return $ics;
} | returns an ICSExport calendar object by supplying a Silverstripe calendar
@param type $cal | entailment |
public function cal()
{
//echo 'test';
$call = null;
$request = $this->getRequest();
$ics = null;
$idOrURL = $request->param('ID');
//echo $idOrURL;
//Public calendar via id
if (is_numeric($idOrURL)) {
//calendar id is requested
... | Single calendar
Can be public or private
For public calendars either the calendar id or the calendar url can be supplied
For private calendars user email and hash need to be supplied - like this.
The private calendar hash is created in {@see PrivateCalendarMemberExtension} | entailment |
public function all()
{
$calendars = PublicCalendar::get();
$events = new ArrayList();
foreach ($calendars as $cal) {
$events->merge($cal->Events());
}
$eventsArr = $events->toNestedArray();
//Debug::dump($eventsArr);
//return false;
$i... | All public calendars | entailment |
public function isValid($value) : bool
{
if ($value === null && $this->nullable) {
return true;
}
return $value instanceof Metadata;
} | @param $value
@return bool | entailment |
public function serialize($value) : string
{
if (!$value instanceof Metadata) {
throw InvalidValueException::valueDoesNotMatchType($this, $value);
}
return (string) $value->id();
} | @param $value
@return string
@throws InvalidValueException | entailment |
public function deserialize($serializedValue)
{
if (null === $serializedValue && $this->isNullable()) {
return null;
}
if (!is_string($serializedValue)) {
throw InvalidArgumentException::expected('string', $serializedValue);
}
return new Association(... | @param string $serializedValue
@return null|Association
@throws InvalidArgumentException | entailment |
public function register()
{
$container = $this->getContainer();
$config = $container->get('config');
$container->share(HandlerStack::class, function () {
return HandlerStack::create();
});
// If access token was provided, then instantiate and add to middlewa... | Use the register method to register items with the container via the
protected ``$this->container`` property or the ``getContainer`` method
from the ``ContainerAwareTrait``.
@return void | entailment |
public function run(OutputInterface $output)
{
$message = $this->getParameter('message');
if (!$this->hasParameter('email')) {
$this->sendDesktopNotification($message);
return $output->writeln(["", ' <info>[notify]</info> - <comment>'.$message.'</comment>', ""]);
... | {@inheritDoc} | entailment |
private function sendEmail(OutputInterface $output, $content)
{
$output->writeln("Sending an email");
$transport = $this->getTransport();
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance('Bldr Notify - New Message')
->setFrom(['... | Sends an email with the given message
@param OutputInterface $output
@param string $content
@return int | entailment |
public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
{
if (!$definition instanceof AssociationFieldDefinition) {
throw DoctrineStorageException::invalidDefinition(AssociationFieldDefinition::class, $definition);
}
$table->addColumn(
... | @param string $schema
@param Table $table
@param string $name
@param FieldDefinition $definition
@throws DoctrineStorageException | entailment |
public function kickStarterCommand(
$mass = EnterpriseLevelEnumeration::BY_DEFAULT,
$makeResources = true,
$makeMountPoint = true,
$extensionKey = null,
$author = null,
$title = null,
$description = null,
$useVhs = true,
$useFluidcontentCore = true... | Gerenates a Fluid Powered TYPO3 based site. Welcome to our world.
@param string $mass [default,minimalist,small,medium,large] Site enterprise level: If you wish, select the
expected size of your site here. Depending on your selection, system extensions will be
installed or uninstalled to create a sane default extensio... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.