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 = file_get_contents($file).$this->getParameter('character').$content; } $this->fileSystem->dumpFile($file, $content); }
{@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(); $propertyValue = $property->getValue(); $propertyName = $property->getName(); if (in_array($property->getType(), [PropertyType::REFERENCE, PropertyType::WEAKREFERENCE])) { $nodeUuids = []; if (false === is_array($propertyValue)) { $propertyValue = [$propertyValue]; } foreach ($propertyValue as $node) { $nodeUuids[] = $node->getIdentifier(); } $propertyValue = $nodeUuids; if (false === $property->isMultiple()) { $propertyValue = reset($propertyValue); } } $res[$propertyName] = [ 'type' => PropertyType::nameFromValue($propertyType), 'value' => $propertyValue, ]; } return $res; }
{@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($context['node'])) { throw new \InvalidArgumentException(sprintf( 'You must provide the PHPCR node instance to update in the context using the "node" key.' )); } $node = $context['node']; $errors = []; // Update / remove existing properties foreach ($node->getProperties() as $property) { if (false === $this->isPropertyEditable($property)) { continue; } try { if (!isset($data[$property->getName()])) { $property->remove(); continue; } $datum = $this->normalizeDatum($data[$property->getName()]); $typeValue = isset($datum['type']) ? PropertyType::valueFromName($datum['type']) : null; if (isset($datum['value'])) { // if the type or the value is differnet, update the property if ($datum['value'] != $property->getValue() || $typeValue != $property->getType()) { // setValue doesn't like being passed a null value as a type ... if ($typeValue !== null) { $property->setValue($datum['value'], $typeValue); } else { $property->setValue($datum['value']); } } } } catch (\Exception $e) { $errors[] = $e->getMessage(); } unset($data[$property->getName()]); } // Add new properties foreach ($data as $pName => $datum) { $datum = $this->normalizeDatum($datum); $pValue = isset($datum['value']) ? $datum['value'] : null; $pType = isset($datum['type']) ? PropertyType::valueFromName($datum['type']) : null; if ($pValue !== null) { $node->setProperty($pName, $pValue, $pType); } } if (count($errors) > 0) { throw new InvalidArgumentException(sprintf( 'Errors encountered during denormalization: %s', implode($errors, "\n") )); } }
{@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; } return true; }
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 (true) { case is_resource($value): throw new InvalidArgumentException('Unable to dump PHP resources in a YAML file.'); case is_object($value): return '!!php/object:'.serialize($value); case is_array($value): return self::dumpArray($value); case null === $value: return 'null'; case true === $value: return 'true'; case false === $value: return 'false'; case ctype_digit($value): return is_string($value) ? "'$value'" : (int) $value; case is_numeric($value): return is_infinite($value) ? str_ireplace('INF', '.Inf', strval($value)) : (is_string($value) ? "'$value'" : $value); case false !== strpos($value, "\n") || false !== strpos($value, "\r"): return sprintf('"%s"', str_replace(array('"', "\n", "\r"), array('\\"', '\n', '\r'), $value)); case preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value): return sprintf("'%s'", str_replace('\'', '\'\'', $value)); case '' == $value: return "''"; case preg_match(self::getTimestampRegex(), $value): return "'$value'"; case in_array(strtolower($value), $trueValues): return "'$value'"; case in_array(strtolower($value), $falseValues): return "'$value'"; case in_array(strtolower($value), array('null', '~')): return "'$value'"; default: return $value; } }
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 '}': return $output; } // key $key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false); // value $done = false; while ($i < $len) { switch ($mapping[$i]) { case '[': // nested sequence $output[$key] = self::parseSequence($mapping, $i); $done = true; break; case '{': // nested mapping $output[$key] = self::parseMapping($mapping, $i); $done = true; break; case ':': case ' ': break; default: $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); $done = true; --$i; } ++$i; if ($done) { continue 2; } } } throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $mapping)); }
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'); $falseValues = array('false'); } switch (true) { case 'null' == strtolower($scalar): case '' == $scalar: case '~' == $scalar: return null; case 0 === strpos($scalar, '!str'): return (string) substr($scalar, 5); case 0 === strpos($scalar, '! '): return intval(self::parseScalar(substr($scalar, 2))); case 0 === strpos($scalar, '!!php/object:'): return unserialize(substr($scalar, 13)); case ctype_digit($scalar): $raw = $scalar; $cast = intval($scalar); return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw); case in_array(strtolower($scalar), $trueValues): return true; case in_array(strtolower($scalar), $falseValues): return false; case is_numeric($scalar): return '0x' == $scalar[0].$scalar[1] ? hexdec($scalar) : floatval($scalar); case 0 == strcasecmp($scalar, '.inf'): case 0 == strcasecmp($scalar, '.NaN'): return -log(0); case 0 == strcasecmp($scalar, '-.inf'): return log(0); case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): return floatval(str_replace(',', '', $scalar)); case preg_match(self::getTimestampRegex(), $scalar): return strtotime($scalar); default: return (string) $scalar; } }
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, 'thread' => $thread, ]) ->getQuery() ->getSingleScalarResult(); }
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('isCommentable') ; }
{@inheritdoc}
entailment
protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper->add('id'); if (interface_exists('Sonata\\ClassificationBundle\\Model\\CategoryInterface')) { $datagridMapper->add('category'); } $datagridMapper ->add('permalink') ->add('isCommentable') ; }
{@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[strlen($src)-1] != '/') $src .= '/'; $src = array($src); } elseif (is_array($src)) { // syncing multiple objects, so removing trailing slashes $src = array_map(create_function('$path', 'return rtrim($path, "/");'), $src); } array_walk($src, array('self', 'throwIfPathDoesNotExists')); pake_sh(escapeshellarg(pake_which('rsync')).' -az -e '.escapeshellarg($transport).' ' .implode(' ', array_map('escapeshellarg', $src)).' ' .escapeshellarg("{$rsync_login}{$server_host}:{$remote_path}") ); }
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 $transport (use 'ssh -l username' if specific ssh-login is required) @return void @author Jimi Dini
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->merge($next); // If ``$limit`` is not set then call itself indefinitely if ($limit === null) { return $this->paginate($merged); } // If ``$limit`` is set, call itself while decrementing it each time $limit--; return $this->paginate($merged, $limit); }
{@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 = isset($response->meta) ? $response->meta : $response; $class = '\\Larabros\\Elogram\\Exceptions\\'.$meta->error_type; return new $class($meta->error_message); }
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() ->scalarNode('description') ->defaultValue('') ->end() ->append($this->getProfilesNode()) ->append($this->getTasksNode()) ->end() ; return $treeBuilder; }
{@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 => $value) { $field = $type->getFieldDefinition($key); $value = $field->deserialize($value); if ($value instanceof Association) { $value = $this->associate($value); } $fieldValues[$key] = $value; } foreach ($type->getDefinitions(array_keys($data)) as $key => $field) { $fieldValues[$key] = $field->defaultValue(); } return new Metadata($id, $type->name(), $fieldValues); }
@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='.escapeshellarg($this->repository_path.'/.git'); $cmd .= ' --work-tree='.escapeshellarg($this->repository_path); $cmd .= ' '.$command; } try { return pake_sh($cmd); } catch (pakeException $e) { if (strpos($e->getMessage(), 'cannot be used without a working tree') !== false || // workaround for windows (using win7 and git 1.7.10) strpos($e->getMessage(), 'fatal: Could not switch to ') !== false) { pake_echo_error('Your version of git is buggy. Using workaround'); self::$needs_work_tree_workaround = true; return $this->git_run($command); } throw $e; } }
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); $cmd = escapeshellarg(pake_which('git')).' init -q'; if (null !== $template_path) { $cmd .= ' --template='.escapeshellarg($template_path); } $cmd .= ' --shared='.escapeshellarg($shared); $cwd = getcwd(); chdir($path); chdir('.'); // hack for windows. see http://docs.php.net/manual/en/function.chdir.php#88617 pake_sh($cmd); chdir($cwd); return new pakeGit($path); }
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->send($method); } catch (InvalidFieldValueError $e) { $billogram->delete(); throw $e; } return $billogram; }
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(), $config); } $this->container = $container; $this->assemble($this->config, $this->container); }
{@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 = \dirname($targetPath); if (! \is_dir($folder)) { throw new \RuntimeException(\sprintf('The uploaded file cannot be moved. The directory "%s" does not exist', $folder)); } if (! \is_writeable($folder)) { throw new \RuntimeException(\sprintf('The uploaded file cannot be moved. The directory "%s" is not writeable', $folder)); } $target = (new StreamFactory)->createStreamFromFile($targetPath, 'wb'); $this->stream->rewind(); while (! $this->stream->eof()) { $target->write($this->stream->read(4096)); } $this->stream->close(); $this->stream = null; $target->close(); }
{@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', 'References To (Count)')]; $event->tableAttributes['elementMap_incomingReferences'] = ['label' => Craft::t('element-map', 'References From')]; $event->tableAttributes['elementMap_outgoingReferences'] = ['label' => Craft::t('element-map', 'References To')]; }
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->view->renderTemplate('element-map/_table', ['elements' => count($elements)]); } else if ($event->attribute == 'elementMap_outgoingReferenceCount') { $event->handled = true; $entry = $event->sender; $elements = $this->renderer->getOutgoingElements($entry->id, $entry->site->id); $event->html = Craft::$app->view->renderTemplate('element-map/_table', ['elements' => count($elements)]); } else if ($event->attribute == 'elementMap_incomingReferences') { $event->handled = true; $entry = $event->sender; $elements = $this->renderer->getIncomingElements($entry->id, $entry->site->id); $event->html = Craft::$app->view->renderTemplate('element-map/_table', ['elements' => $elements]); } else if ($event->attribute == 'elementMap_outgoingReferences') { $event->handled = true; $entry = $event->sender; $elements = $this->renderer->getOutgoingElements($entry->id, $entry->site->id); $event->html = Craft::$app->view->renderTemplate('element-map/_table', ['elements' => $elements]); } }
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); $startMonth = date('M', $startTime); $startDayOfMonth = $startObj->DayOfMonth(true); $str = $startMonth . ' ' . $startDayOfMonth; if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) { //one date - str. has already been written } else { //two dates if ($endDateIsset) { $endMonth = date('M', $endTime); $endDayOfMonth = $endObj->DayOfMonth(true); if ($startMonth == $endMonth) { $str .= ' - ' . $endDayOfMonth; } else { $str .= ' - ' . $endMonth . ' ' . $endDayOfMonth; } } } return $str; }
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 null; } if ($endStr) { //time frame is only applicable if both start and end time is on the same day if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) { $str = date('g:ia', $startTime) . ' - ' . date('g:ia', $endTime); } } else { $str = date('g:ia', $startTime); } return $str; }
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 //echo 'request is numeric'; $cal = Calendar::get()->ByID((int) $request->param('ID')); //echo $cal->getLink(); //Public calendar via url } else { //calendar url is requested //echo 'request is a string'; $url = Convert::raw2url($idOrURL); $cal = Calendar::get() ->filter('URLSegment', $url) ->First(); } //If not public calendar is found we check for a private calendar if (!$cal) { echo $idOrURL; $member = Member::get() ->filter('Email', $idOrURL) ->filter('PrivateCalendarKey', $request->param('OtherID')) ->First(); if ($member && $member->exists()) { return $this->memberCalendar($member); } } if ($cal && $cal->exists()) { //everybody can access public calendars if ($cal->ClassName == 'PublicCalendar') { $ics = ICSExport::ics_from_sscal($cal); $calName = $cal->Title; } return $this->output($ics, $calName); } else { echo "calendar can't be found"; } }
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; $ics = new ICSExport($eventsArr); return $this->output($ics, 'all'); }
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($this->schema, $this->typeSchema, ['id' => $serializedValue]); }
@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 middleware if ($config->has('access_token') && $config->get('access_token') !== null ) { // Convert the JSON serialized token into an `AccessToken` instance. $config->set( 'access_token', new AccessToken(json_decode($config->get('access_token'), true)) ); } $this->addMiddleware(); }
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>', ""]); } $this->sendEmail($output, $message); }
{@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(['[email protected]' => 'Bldr']) ->setTo($this->getEmails()) ->setBody( "<p>Bldr has a new message for you from the most recent build</p>\n<br /><pre>{$content}</pre>\n", "text/html" ) ->addPart($content, 'text/plain') ; $result = $mailer->send($message); return $result; }
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( $name, 'guid', [ 'notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'length' => $definition->options()['length'] ?? null, 'unique' => $definition->options()['unique'] ?? false, ] ); $table->addForeignKeyConstraint( $this->tableName($schema, $definition->typeSchema()->name()), [$name], ['id'] ); }
@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, $pages = true, $content = true, $backend = false, $controllers = true ) { $output = $this->kickStarterService->generateFluidPoweredSite( $mass, $makeResources, $makeMountPoint, $extensionKey, $author, $title, $description, $useVhs, $useFluidcontentCore, $pages, $content, $backend, $controllers ); $this->outputLine($output); }
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 extension collection that suits your site. The "medium" option is approximately the same as the default except without the documentation-related extensions. Choose "large" if your site is targed at multiple editors, languages or otherwise requires many CMS features. @param boolean $makeResources Create resources: Check this checkbox to create a top-level page with preset template selections, three sub-pages, one domain record based on the current host name you use and one root TypoScript record in which the necessary static TypoScript templates are pre-included. @param boolean $makeMountPoint Create FAL mount point: Check this to create a file system mount point allowing you to access your templates and asset files using the "File list" module" and reference your templates and asset files from "file" type fields in your pages and content properties. @param string $extensionKey [ext:builder] The extension key which should be generated. Must not exist. @param string $author [ext:builder] The author of the extension, in the format "Name Lastname <[email protected]>" with optional company name, in which case form is "Name Lastname <[email protected]>, Company Name" @param string $title [ext:builder] The title of the resulting extension, by default "Provider extension for $enabledFeaturesList" @param string $description [ext:builder] The description of the resulting extension, by default "Provider extension for $enabledFeaturesList" @param boolean $useVhs [ext:builder] If TRUE, adds the VHS extension as dependency - recommended, on by default @param boolean $useFluidcontentCor [ext:builder] If TRUE, adds the FluidcontentCore extension as dependency - recommended, on by default @param boolean $pages [ext:builder] If TRUE, generates basic files for implementing Fluid Page templates @param boolean $content [ext:builder] IF TRUE, generates basic files for implementing Fluid Content templates @param boolean $backend [ext:builder] If TRUE, generates basic files for implementing Fluid Backend modules @param boolean $controllers [ext:builder] If TRUE, generates controllers for each enabled feature. Enabling $backend will always generate a controller regardless of this toggle. @return void
entailment