sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function process(MinifyContext $context) { $booleanAttributes = implode('|', (new HtmlBooleanAttributeRepository())->getAttributes()); return $context->setContents(preg_replace_callback( '/ \s # first match a whitespace which is an indicat...
Execute the minification rule. @param \ArjanSchouten\HtmlMinifier\MinifyContext $context @return \ArjanSchouten\HtmlMinifier\MinifyContext
entailment
public function handle() { if ((bool)GeneralUtility::_GP('juSecure')) { $this->forwardJumpUrlSecureFileData($this->url); } else { $this->redirectToJumpUrl($this->url); } }
Custom processing of the current URL. If a valid hash was submitted the user will either be redirected to the given jumpUrl or if it is a secure jumpUrl the file data will be passed to the user. If canHandle() has returned TRUE this method needs to take care of redirecting the user or generating custom output. This h...
entailment
protected function redirectToJumpUrl($jumpUrl) { $this->validateIfJumpUrlRedirectIsAllowed($jumpUrl); $pageTSconfig = $this->getTypoScriptFrontendController()->getPagesTSconfig(); if (is_array($pageTSconfig['TSFE.'])) { $pageTSconfig = $pageTSconfig['TSFE.']; } else { ...
Redirects the user to the given jump URL if all submitted values are valid @param string $jumpUrl The URL to which the user should be redirected @throws \Exception
entailment
protected function forwardJumpUrlSecureFileData($jumpUrl) { // Set the parameters required for handling a secure jumpUrl link // The locationData GET parameter, containing information about the record that created the URL $locationData = (string)GeneralUtility::_GP('locationData'); /...
If the submitted hash is correct and the user has access to the related content element the contents of the submitted file will be output to the user. @param string $jumpUrl The URL to the file that should be output to the user @throws \Exception
entailment
protected function isLocationDataValid($locationData) { $isValidLocationData = false; list($pageUid, $table, $recordUid) = explode(':', $locationData); $pageRepository = $this->getTypoScriptFrontendController()->sys_page; $timeTracker = $this->getTimeTracker(); if (empty($tab...
Checks if the given location data is valid and the connected record is accessible by the current user. @param string $locationData @return bool
entailment
protected function validateIfJumpUrlRedirectIsAllowed($jumpUrl) { $allowRedirect = false; if ($this->isJumpUrlHashValid($jumpUrl)) { $allowRedirect = true; } elseif ( isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler']...
This implements a hook, e.g. for direct mail to allow the redirects but only if the handler says it's alright But also checks against the common juHash parameter first @param string $jumpUrl the URL to check @throws \Exception thrown if no redirect is allowed
entailment
protected function readFileAndExit($file, $mimeType) { $file->getStorage()->dumpFileContents($file, true, null, $mimeType); exit; }
Calls the PHP readfile function and exits. @param FileInterface $file The file that should be read. @param string $mimeType Optional mime type override. If empty the automatically detected mime type will be used.
entailment
protected function addParametersToTransferSession($jumpUrl, $pageTSconfig) { // allow to send the current fe_user with the jump URL if (!empty($pageTSconfig['jumpUrl_transferSession'])) { $uParts = parse_url($jumpUrl); /** @noinspection PhpInternalEntityUsedInspection We need...
Modified the URL to go to by adding the session key information to it but only if TSFE.jumpUrl_transferSession = 1 is set via pageTSconfig. @param string $jumpUrl the URL to go to @param array $pageTSconfig the TSFE. part of the TS configuration @return string the modified URL
entailment
protected function getRedirectStatusCode($pageTSconfig) { $statusCode = HttpUtility::HTTP_STATUS_303; if (!empty($pageTSconfig['jumpURL_HTTPStatusCode'])) { switch ((int)$pageTSconfig['jumpURL_HTTPStatusCode']) { case 301: $statusCode = HttpUtility::H...
Returns one of the HTTP_STATUS_* constants of the HttpUtility that matches the configured HTTP status code in TSFE.jumpURL_HTTPStatusCode Page TSconfig. @param array $pageTSconfig @return string @throws \InvalidArgumentException If the configured status code is not valid.
entailment
public function run(Application $app) { $response = call_user_func_array($this->callback, array_merge($this->parameters, [$app])); parent::callAfterCallbacks($app); return $response; }
Run the given event. @param Application $app @return mixed
entailment
public function deauthorize($stripeUserId) { $request = $this->createRequest( self::METHOD_POST, $this->getBaseDeauthorizationUrl(), null, [ 'body' => $this->buildQueryString([ 'stripe_user_id' => $stripeUserId, ...
@param string $stripeUserId stripe account ID @return mixed
entailment
public function process(MinifyContext $context) { Collection::make($this->redundantAttributes)->each(function ($attributes, $element) use (&$context) { Collection::make($attributes)->each(function ($value, $attribute) use ($element, &$context) { $contents = preg_replace_callback(...
Minify redundant attributes which are not needed by the browser. @param \ArjanSchouten\HtmlMinifier\MinifyContext $context @return \ArjanSchouten\HtmlMinifier\MinifyContext
entailment
protected function removeAttribute($element, $attribute) { $replacement = Html::hasSurroundingAttributes($attribute) ? ' ' : ''; return str_replace($attribute, $replacement, $element); }
Remove the attribute from the element. @param string $element @param string $attribute @return string
entailment
public function GetCustomFromAddresses($select = 1000, $skip = 0) { $url = sprintf("custom-from-addresses?select=%s&skip=%s", $select, $skip); return new ApiCampaignFromAddressList($this->execute($url)); }
/* ========== custom-from-addresses ==========
entailment
public function GetProgramById(XsInt $programId) { $url = sprintf("programs/%s", $programId); return new ApiProgram($this->execute($url)); }
/* ========== programs and enrolments ==========
entailment
public function PostSegmentsRefresh(XsInt $segmentId) { $url = sprintf("segments/refresh/%s", $segmentId); return new ApiSegmentRefresh($this->execute($url, 'POST')); }
/* ========== segments ==========
entailment
public function PostSmsMessagesSendTo(XsString $telephoneNumber, ApiSms $apiSms) { $this->execute(sprintf("/sms-messages/send-to/%s", $telephoneNumber), 'POST', $apiSms->toJson()); }
/* ========== sms-messages ==========
entailment
public function createReferencePoint($inputSize, $keyname = null) { if ($keyname === null) { $keyname = 'Step: '.(count($this->referencePoints) + 1); } if (!array_key_exists($keyname, $this->referencePoints)) { $this->referencePoints[$keyname] = new ReferencePoint($k...
Add a step and measure the input size. @param int $inputSize @param string $keyname @return \ArjanSchouten\HtmlMinifier\Statistics\ReferencePoint[]
entailment
public function getTotalSavedBytes() { $initialStep = array_first($this->referencePoints); $lastStep = array_last($this->referencePoints); return $initialStep->getBytes() - $lastStep->getBytes(); }
Get the total saved bytes in bytes. @return int
entailment
public function actionRun() { $this->importScheduleFile(); $events = $this->schedule->dueEvents(Yii::$app); foreach ($events as $event) { $this->stdout('Running scheduled command: ' . $event->getSummaryForDisplay() . "\n"); $event->run(Yii::$app); } ...
Run scheduled commands
entailment
public function actionList() { $this->importScheduleFile(); $climate = new CLImate(); $data = []; $row = 0; foreach ($this->schedule->getEvents() as $event) { $data[] = [ '#' => ++$row, 'Task' => $event->getSummaryForDisplay(), ...
Render list of registered tasks
entailment
protected function importScheduleFile() { $scheduleFile = Yii::getAlias($this->scheduleFile); if (!file_exists($scheduleFile)) { throw new InvalidConfigException("Can not load schedule file {$this->scheduleFile}"); } $schedule = $this->schedule; call_user_func(f...
Import schedule file @throws InvalidConfigException
entailment
protected function getNextRunDate(Event $event) { $cron = CronExpression::factory($event->getExpression()); $date = Carbon::now(); if ($event->hasTimezone()) { $date->setTimezone($event->getTimezone()); } return $cron->getNextRunDate()->format('Y-m-d H:i:s'); ...
Get the next scheduled run date for this event @param Event $event @return string
entailment
public function setImage(\Imagick $image) { $this->originalImage = $image; // set base image dimensions $this->setBaseDimensions( $this->originalImage->getImageWidth(), $this->originalImage->getImageHeight() ); return $this; }
Sets the object Image to be croped @param \Imagick $image @return Crop
entailment
public function resizeAndCrop($targetWidth, $targetHeight) { if ($this->getAutoOrient()) { $this->autoOrient(); } // First get the size that we can use to safely trim down the image without cropping any sides $crop = $this->getSafeResizeOffset($this->originalImage, $targ...
Resize and crop the image so it dimensions matches $targetWidth and $targetHeight @param int $targetWidth @param int $targetHeight @return boolean|\Imagick
entailment
protected function getSafeResizeOffset(\Imagick $image, $targetWidth, $targetHeight) { $source = $image->getImageGeometry(); if (0 == $targetHeight || ($source['width'] / $source['height']) < ($targetWidth / $targetHeight)) { $scale = $source['width'] / $targetWidth; } else { ...
Returns width and height for resizing the image, keeping the aspect ratio and allow the image to be larger than either the width or height @param \Imagick $image @param int $targetWidth @param int $targetHeight @return array
entailment
protected function getBaseDimension($key) { if (isset($this->baseDimension)) { return $this->baseDimension[$key]; } elseif ($key == 'width') { return $this->originalImage->getImageWidth(); } else { return $this->originalImage->getImageHeight(); } ...
getBaseDimension @param string $key width|height @access protected @return int
entailment
protected function autoOrient() { // apply EXIF orientation to pixel data switch ($this->originalImage->getImageOrientation()) { case \Imagick::ORIENTATION_BOTTOMRIGHT: $this->originalImage->rotateimage('#000', 180); // rotate 180 degrees break; ...
Applies EXIF orientation metadata to pixel data and removes the EXIF rotation @access protected
entailment
public function getData() { $data = array(); /** @var eZContentClassAttribute $contentClassAttribute */ $contentClassAttribute = $this->ContentObjectAttribute->contentClassAttribute(); $keywordFieldName = parent::generateAttributeFieldName( $contentClassAttribute, 'lckeyword' ); ...
Returns the data from content object attribute which is sent to Solr backend @return array
entailment
static public function getFieldNameList( eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array() ) { $fieldsList = array(); if ( empty( $exclusiveTypeFilter ) || !in_array( 'lckeyword', $exclusiveTypeFilter ) ) $fieldsList[] = parent::generateAttributeFieldName( $classAt...
Returns the list of field names this handler sends to Solr backend @static @param eZContentClassAttribute $classAttribute @param array $exclusiveTypeFilter @return array
entailment
private function processTag( eZTagsObject $tag, array &$tagIDs, array &$keywords, $indexParentTags = false, $includeSynonyms = false ) { if ( !$this->indexSynonyms && $tag->isSynonym() ) $tag = $tag->getMainTag(); //get keyword in content's locale $keyword = $tag->getKeyword( $t...
Extracts data to be indexed from the tag @param eZTagsObject $tag @param array $tagIDs @param array $keywords @param bool $indexParentTags @param bool $includeSynonyms
entailment
private static function isBinaryOperator(TokenInterface $token): bool { return in_array($token->getType(), [ TokenInterface::TYPE_OPERATOR_ASSIGNMENT, TokenInterface::TYPE_OPERATOR_COPY, TokenInterface::TYPE_OPERATOR_MODIFY, TokenInterface::TYPE_OPERATOR_REFER...
Tests whether a token is a binary operator @param TokenInterface $token @return bool
entailment
private static function isWhitespaceOfLength(TokenInterface $token, int $length): bool { return static::isWhitespace($token) && strlen(trim($token->getValue(), "\n")) == $length; }
Tests whether a token is a whitespace of a given length @param TokenInterface $token @param int $length @return bool
entailment
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { parent::validateConfigurationForm($form, $form_state); $exploded_mime = explode('/', $form_state->getValue('mimetype')); if ($exploded_mime[0] != "image") { $form_state->setErrorByName( 'mimetype', ...
{@inheritdoc}
entailment
public function countIssues(): int { $count = 0; foreach ($this->files as $file) { $count += count($file->getIssues()); } return $count; }
Returns the number of issues for the entire report. @return int The number of issues for the entire report.
entailment
public function countIssuesBySeverity(string $severity): int { $count = 0; foreach ($this->files as $file) { $count += count($file->getIssuesBySeverity($severity)); } return $count; }
Returns the number of issues with a given severity for the entire report @param string $severity The severity. Should be one of the Issue class' SEVERITY_* constants @return int The number of issues for the entire report.
entailment
public function onResponse(FilterResponseEvent $event) { $response = $event->getResponse(); $node = $this->getObject($response, 'node'); if ($node === FALSE) { return; } $links = array_merge( $this->generateEntityReferenceLinks($node), $this->generateRelatedMediaLinks($node), ...
Adds node-specific link headers to appropriate responses. @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event Event containing the response.
entailment
protected function generateRelatedMediaLinks(NodeInterface $node) { $links = []; foreach ($this->utils->getMedia($node) as $media) { $url = $media->url('canonical', ['absolute' => TRUE]); foreach ($media->referencedEntities() as $term) { if ($term->getEntityTypeId() == 'taxonomy_term' && $te...
Generates link headers for media associated with a node.
entailment
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { if (isset($this->configuration['uri']) && !empty($this->configuration['uri'])) { $default = $this->utils->getTermForUri($this->configuration['uri']); } else { $default = NULL; } $form['term'] = [ ...
{@inheritdoc}
entailment
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { // Set URI for term if possible. $this->configuration['uri'] = NULL; $value = $form_state->getValue('term'); if (!empty($value)) { $tid = $value[0]['target_id']; $term = $this->entityTypeManager->getStora...
{@inheritdoc}
entailment
public function evaluate() { if (empty($this->configuration['uri']) && !$this->isNegated()) { return TRUE; } $node = $this->getContextValue('node'); if (!$node) { return FALSE; } return $this->evaluateEntity($node); }
{@inheritdoc}
entailment
protected function evaluateEntity(EntityInterface $entity) { foreach ($entity->referencedEntities() as $referenced_entity) { if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' && $referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) { $field = $referenced_entity->get(IslandoraUti...
Evaluates if an entity has the specified term(s). @param \Drupal\Core\Entity\EntityInterface $entity The entity to evalute. @return bool TRUE if entity has all the specified term(s), otherwise FALSE.
entailment
public function getParentNode(MediaInterface $media) { if (!$media->hasField(self::MEDIA_OF_FIELD)) { return NULL; } $field = $media->get(self::MEDIA_OF_FIELD); if ($field->isEmpty()) { return NULL; } $parent = $field->first() ->get('entity') ->getTarget(); if (!is_nu...
Gets nodes that a media belongs to. @param \Drupal\media\MediaInterface $media The Media whose node you are searching for. @return \Drupal\node\NodeInterface Parent node. @throws \Drupal\Core\TypedData\Exception\MissingDataException Method $field->first() throws if data structure is unset and no item can be created.
entailment
public function getMedia(NodeInterface $node) { if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) { return []; } $mids = $this->entityQuery->get('media')->condition(self::MEDIA_OF_FIELD, $node->id())->execute(); if (empty($mids)) { retu...
Gets media that belong to a node. @param \Drupal\node\NodeInterface $node The parent node. @return \Drupal\media\MediaInterface[] The children Media. @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException Calling getStorage() throws if the entity type doesn't exist. @throws \Drupal\Component\Plugin\Excep...
entailment
public function getMediaWithTerm(NodeInterface $node, TermInterface $term) { $mids = $this->getMediaReferencingNodeAndTerm($node, $term); if (empty($mids)) { return NULL; } return $this->entityTypeManager->getStorage('media')->load(reset($mids)); }
Gets media that belong to a node with the specified term. @param \Drupal\node\NodeInterface $node The parent node. @param \Drupal\taxonomy\TermInterface $term Taxonomy term. @return \Drupal\media\MediaInterface The child Media. @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException Calling getStorage() t...
entailment
public function getReferencingMedia($fid) { // Get media fields that reference files. $fields = $this->getReferencingFields('media', 'file'); // Process field names, stripping off 'media.' and appending 'target_id'. $conditions = array_map( function ($field) { return ltrim($field, 'media....
Gets Media that reference a File. @param int $fid File id. @return \Drupal\media\MediaInterface[] Array of media. @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException Calling getStorage() throws if the entity type doesn't exist. @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionExceptio...
entailment
public function getTermForUri($uri) { $results = $this->entityQuery->get('taxonomy_term') ->condition(self::EXTERNAL_URI_FIELD . '.uri', $uri) ->execute(); if (empty($results)) { return NULL; } return $this->entityTypeManager->getStorage('taxonomy_term')->load(reset($results)); }
Gets the taxonomy term associated with an external uri. @param string $uri External uri. @return \Drupal\taxonomy\TermInterface|null Term or NULL if not found. @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException Calling getStorage() throws if the entity type doesn't exist. @throws \Drupal\Component\Pl...
entailment
public function getUriForTerm(TermInterface $term) { if ($term && $term->hasField(self::EXTERNAL_URI_FIELD)) { $field = $term->get(self::EXTERNAL_URI_FIELD); if (!$field->isEmpty()) { $link = $field->first()->getValue(); return $link['uri']; } } return NULL; }
Gets the taxonomy term associated with an external uri. @param \Drupal\taxonomy\TermInterface $term Taxonomy term. @return string|null URI or NULL if not found. @throws \Drupal\Core\TypedData\Exception\MissingDataException Method $field->first() throws if data structure is unset and no item can be created.
entailment
public function executeNodeReactions($reaction_type, NodeInterface $node) { $provider = new NodeContextProvider($node); $provided = $provider->getRuntimeContexts([]); $this->contextManager->evaluateContexts($provided); // Fire off index reactions. foreach ($this->contextManager->getActiveReactions(...
Executes context reactions for a Node. @param string $reaction_type Reaction type. @param \Drupal\node\NodeInterface $node Node to evaluate contexts and pass to reaction.
entailment
public function executeMediaReactions($reaction_type, MediaInterface $media) { $provider = new MediaContextProvider($media); $provided = $provider->getRuntimeContexts([]); $this->contextManager->evaluateContexts($provided); // Fire off index reactions. foreach ($this->contextManager->getActiveReact...
Executes context reactions for a Media. @param string $reaction_type Reaction type. @param \Drupal\media\MediaInterface $media Media to evaluate contexts and pass to reaction.
entailment
public function executeFileReactions($reaction_type, FileInterface $file) { $provider = new FileContextProvider($file); $provided = $provider->getRuntimeContexts([]); $this->contextManager->evaluateContexts($provided); // Fire off index reactions. foreach ($this->contextManager->getActiveReactions(...
Executes context reactions for a File. @param string $reaction_type Reaction type. @param \Drupal\file\FileInterface $file File to evaluate contexts and pass to reaction.
entailment
public function executeTermReactions($reaction_type, TermInterface $term) { $provider = new TermContextProvider($term); $provided = $provider->getRuntimeContexts([]); $this->contextManager->evaluateContexts($provided); // Fire off index reactions. foreach ($this->contextManager->getActiveReactions(...
Executes context reactions for a File. @param string $reaction_type Reaction type. @param \Drupal\taxonomy\TermInterface $term Term to evaluate contexts and pass to reaction.
entailment
public function executeDerivativeReactions($reaction_type, NodeInterface $node, MediaInterface $media) { $provider = new MediaContextProvider($media); $provided = $provider->getRuntimeContexts([]); $this->contextManager->evaluateContexts($provided); // Fire off index reactions. foreach ($this->cont...
Executes derivative reactions for a Media and Node. @param string $reaction_type Reaction type. @param \Drupal\node\NodeInterface $node Node to pass to reaction. @param \Drupal\media\MediaInterface $media Media to evaluate contexts.
entailment
public function haveFieldsChanged(ContentEntityInterface $entity, ContentEntityInterface $original) { $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()); $ignore_list = ['vid' => 1, 'changed' => 1, 'path' => 1]; $field_definitions = array_dif...
Evaluates if fields have changed between two instances of a ContentEntity. @param \Drupal\Core\Entity\ContentEntityInterface $entity The updated entity. @param \Drupal\Core\Entity\ContentEntityInterface $original The original entity. @return bool TRUE if the fields have changed.
entailment
public function getFilesystemSchemes() { $schemes = ['public']; if (!empty(Settings::get('file_private_path'))) { $schemes[] = 'private'; } return array_merge($schemes, $this->flysystemFactory->getSchemes()); }
Returns a list of all available filesystem schemes. @return String[] List of all available filesystem schemes.
entailment
public function getMediaReferencingNodeAndTerm(NodeInterface $node, TermInterface $term) { $term_fields = $this->getReferencingFields('media', 'taxonomy_term'); if (count($term_fields) <= 0) { \Drupal::logger("No media fields reference a taxonomy term"); return NULL; } $node_fields = $this->...
Get array of media ids that have fields that reference $node and $term. @param \Drupal\node\NodeInterface $node The node to reference. @param \Drupal\taxonomy\TermInterface $term The term to reference. @return array|int|null Array of media IDs or NULL.
entailment
public function getReferencingFields($entity_type, $target_type) { $fields = $this->entityQuery->get('field_storage_config') ->condition('entity_type', $entity_type) ->condition('settings.target_type', $target_type) ->execute(); if (!is_array($fields)) { $fields = [$fields]; } re...
Get the fields on an entity of $entity_type that reference a $target_type. @param string $entity_type Type of entity to search for. @param string $target_type Type of entity the field references. @return array Array of fields.
entailment
private function getEntityQueryOrCondition(QueryInterface $query, array $fields, $value) { $condition = $query->orConditionGroup(); foreach ($fields as $field) { $condition->condition($field, $value); } return $condition; }
Make an OR condition for an array of fields and a value. @param \Drupal\Core\Entity\Query\QueryInterface $query The QueryInterface for the query. @param array $fields The array of field names. @param string $value The value to search the fields for. @return \Drupal\Core\Entity\Query\ConditionInterface The OR conditio...
entailment
public function createAndFilterSqlParts( $params ) { $returnArray = array( 'tables' => '', 'joins' => '', 'columns' => '' ); if ( !isset( $params['tag_id'] ) ) return $returnArray; if ( is_array( $params['tag_id'] ) ) { $tagIDsArray = $params['tag_id']; ...
Creates and returns SQL parts used in fetch functions @param array $params @return array
entailment
public function createAndMultipleFilterSqlParts( $params ) { $returnArray = array( 'tables' => '', 'joins' => '', 'columns' => '' ); if ( !isset( $params['tag_id'] ) ) return $returnArray; if ( is_array( $params['tag_id'] ) ) { $tagIDsArray = $params['tag_i...
Creates and returns SQL parts used in fetch functions @param array $params where 'tag_id' is an array of arrays; at least one tag ID from each array must match @return array
entailment
protected function alterRoutes(RouteCollection $collection) { if ($route = $collection->get('view.media_of.page_1')) { $route->setOption('_admin_route', 'TRUE'); } if ($route = $collection->get('view.manage_members.page_1')) { $route->setOption('_admin_route', 'TRUE'); } }
{@inheritdoc}
entailment
public function getPath() { $this->checkPathIndexNeeded(); if(empty($this->jsonValues) && empty($this->jsonText)) { throw new \Exception('JSON values must be given to the object\'s constructor.'); } return rawurlencode($this->options['index']).'/field/'; }
{@inheritdoc}
entailment
public function addQuery(Search $query, $modeManualAction = null) { if($modeManualAction && $this->data['mode'] != 'manual') { throw new \InvalidArgumentException('Query mode must be set to "manual" before using a batchAction for queries.'); } //add query data $queryArray = json_de...
Add one query to the batch @param Search $query @param String $modeManualAction Batch action to use for the query, if mode is "manual"
entailment
public function addQueries(array $queries = array()) { foreach($queries as $queryInfo) { $batchAction = (isset($queryInfo[1])) ? $queryInfo[1] : null; $this->addQuery($queryInfo[0], $batchAction); } }
Call query() for each item in the array @param array $queries An array of array: each sub array contains one required item, the query, and a second optionnal item, the batchAction to use for this query if mode is "manual"
entailment
public function defaultConfiguration() { $config = parent::defaultConfiguration(); $config['path'] = '[date:custom:Y]-[date:custom:m]/[node:nid]-[term:name].mp3'; $config['mimetype'] = 'audio/mpeg'; $config['queue'] = 'islandora-connector-homarus'; $config['destination_media_type'] = 'audio'; $c...
{@inheritdoc}
entailment
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $form['mimetype']['#description'] = t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)'); $form['args']['#description'] = t('Additional command line p...
{@inheritdoc}
entailment
public function load($resource, $type = null): array { try { $path = $this->locator->locate($resource); $file = $this->filesystem->openFile($path); $configValues = $this->yamlParser->parse($file->getContents()); return $configValues; } catch (FileLoca...
Loads a resource. @param mixed $resource The resource @param string $type The resource type @return array @suppress PhanUndeclaredClassCatch
entailment
public function supports($resource, $type = null): bool { return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), ['yml', 'yaml']); }
Returns true if this class supports the given resource. @param mixed $resource A resource @param string $type The resource type @return bool true if this class supports the given resource, false otherwise
entailment
static public function fetchTag( $tagID, $language = false ) { if ( $language ) { if ( !is_array( $language ) ) $language = array( $language ); eZContentLanguage::setPrioritizedLanguages( $language ); } $result = false; if ( is_numeric...
Fetches eZTagsObject object for the provided tag ID @static @param int $tagID @param mixed $language @return array
entailment
static public function fetchTagsByKeyword( $keyword, $language = false ) { if ( $language ) { if ( !is_array( $language ) ) $language = array( $language ); eZContentLanguage::setPrioritizedLanguages( $language ); } if ( strpos( $keyword, '*' )...
Fetches all tags named with provided keyword @static @param string $keyword @param mixed $language @return array
entailment
static public function fetchTagByRemoteID( $remoteID, $language = false ) { if ( $language ) { if ( !is_array( $language ) ) $language = array( $language ); eZContentLanguage::setPrioritizedLanguages( $language ); } $result = eZTagsObject::fet...
Fetches tag identified with provided remote ID @static @param string $remoteID @param mixed $language @return array
entailment
static public function fetchTagByUrl( $url, $language = false ) { if ( $language ) { if ( !is_array( $language ) ) $language = array( $language ); eZContentLanguage::setPrioritizedLanguages( $language ); } $result = eZTagsObject::fetchByUrl( $...
Fetches tag identified with provided URL @static @param string $url @param mixed $language @return array
entailment
static public function fetchTagTree( $parentTagID, $sortBy, $offset, $limit, $depth, $depthOperator, $includeSynonyms, $language = false ) { if ( !is_numeric( $parentTagID ) || (int) $parentTagID < 0 ) return array( 'result' => false ); $params = array( 'SortBy' => $sortBy, ...
Fetches subtree of tags by specified parameters @static @param int $parentTagID @param array $sortBy @param int $offset @param int $limit @param int $depth @param string $depthOperator @param bool $includeSynonyms @param mixed $language @return array
entailment
static public function fetchTagTreeCount( $parentTagID, $depth, $depthOperator, $includeSynonyms, $language = false ) { if ( !is_numeric( $parentTagID ) || (int) $parentTagID < 0 ) return array( 'result' => 0 ); $params = array( 'IncludeSynonyms' => $includeSynonyms ); if ( $de...
Fetches subtree tag count by specified parameters @static @param int $parentTagID @param int $depth @param string $depthOperator @param bool $includeSynonyms @param mixed $language @return array
entailment
public function getRuntimeContexts(array $unqualified_context_ids) { $context_definition = new ContextDefinition('entity:file', NULL, FALSE); $value = NULL; // Hack the file out of the route. $route_object = $this->routeMatch->getRouteObject(); if ($route_object) { $route_contexts = $route_ob...
{@inheritdoc}
entailment
public function getBodyAttribute($value){ $value = str_replace(':)', '<div class="smiley smile"></div>', $value); $value = str_replace(':-)', '<div class="smiley smile"></div>', $value); $value = str_replace('(angry)', '<div class="smiley angry"></div>', $value); $value = str_replace(':(...
mutator for message body that replaces smiley codes with smiley images @param $value @return string
entailment
public function verify(Payload $payload) { $response = $this->service->call($payload); $string = $response->getBody(); $pattern = sprintf('/(%s|%s)/', self::IPN_VERIFIED, self::IPN_INVALID); if (!preg_match($pattern, $string)) { throw new UnexpectedValueException( ...
Send HTTP Request to PayPal & verfify payload. @param Payload $payload @return mixed
entailment
public function createLogger(string $outputFormat, OutputInterface $reportOutput, OutputInterface $consoleOutput): LinterLoggerInterface { $errorOutput = ($consoleOutput instanceof ConsoleOutputInterface) ? $consoleOutput->getErrorOutput() : $consoleOutput; switch ($outputFo...
Builds a suitable logger for logging lint progress and results. @param string $outputFormat The desired output format, as specified by the user, e.g. via command-line parameter @param OutputInterface $reportOutput Output stream for the result report (usually STDOUT or a file) @param OutputInterface $console...
entailment
public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config(self::CONFIG_NAME); $form[self::BROKER_URL] = [ '#type' => 'textfield', '#title' => $this->t('Broker URL'), '#default_value' => $config->get(self::BROKER_URL) ? $config->get(self::BROKER_URL) : 't...
{@inheritdoc}
entailment
public function validateForm(array &$form, FormStateInterface $form_state) { // Validate broker url by actually connecting with a stomp client. $brokerUrl = $form_state->getValue(self::BROKER_URL); // Attempt to subscribe to a dummy queue. try { $stomp = new StatefulStomp( new Client( ...
{@inheritdoc}
entailment
public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->configFactory->getEditable(self::CONFIG_NAME); $pseudo_types = array_filter($form_state->getValue(self::GEMINI_PSEUDO)); $config ->set(self::BROKER_URL, $form_state->getValue(self::BROKER_URL)) ->set(se...
{@inheritdoc}
entailment
public function addDocument($document) { if(is_array($document)) { $this->addDocumentArray($document); } elseif ($document instanceof Document) { $this->addDocumentObject($document); } }
Add a document in list of documents to push to index @param array|string|OpenSearchServer\Document\Document $document
entailment
public function loadConfiguration(array $possibleConfigurationFiles = [], LinterConfiguration $configuration = null): LinterConfiguration { $configs = [$this->loader->load('typoscript-lint.dist.yml')]; foreach ($possibleConfigurationFiles as $configurationFile) { $loadedConfig = $this->l...
Loads the linter configuration. @param string[] $possibleConfigurationFiles A list of possible configuration files to load from. These files will be searched in the current working directory and in the typoscript-lint root directory. Contents from these files will also be merged with the typoscript-lin...
entailment
static public function fetchByTagID( $tagID ) { $objects = parent::fetchObjectList( self::definition(), null, array( 'keyword_id' => $tagID ) ); if ( is_array( $objects ) ) return $objects; return array(); }
Fetches the array of eZTagsAttributeLinkObject objects based on provided tag ID @static @param int $tagID @return eZTagsAttributeLinkObject[]
entailment
static public function fetchByObjectAttributeAndKeywordID( $objectAttributeID, $objectAttributeVersion, $objectID, $keywordID ) { $objects = parent::fetchObjectList( self::definition(), null, array( 'objectattribute_id' => $objectAttributeID, ...
Fetches the eZTagsAttributeLinkObject object based on provided content object params and keyword ID @static @param int $objectAttributeID @param int $objectAttributeVersion @param int $objectID @param int $keywordID @return eZTagsAttributeLinkObject if found, false otherwise
entailment
static public function removeByAttribute( $objectAttributeID, $objectAttributeVersion = null ) { if ( !is_numeric( $objectAttributeID ) ) return; $conditions = array( 'objectattribute_id' => (int) $objectAttributeID ); if ( is_numeric( $objectAttributeVersion ) ) $co...
Removes the objects from persistence which are related to content object attribute defined by attribute ID and attribute version @static @param int $objectAttributeID @param int|null $objectAttributeVersion
entailment
public function getPath() { $this->checkPathIndexNeeded(); if(empty($this->options['template'])) { throw new \Exception('Method "template($name)" must be called before submitting request.'); } return rawurlencode($this->options['index']).'/spellcheck/'.rawurlencode($this->options['template...
{@inheritdoc}
entailment
public function writeReport(Report $report): void { $count = 0; $this->output->writeln(''); $this->output->writeln('<comment>CHECKSTYLE REPORT</comment>'); $styleMap = [ Issue::SEVERITY_ERROR => 'error', Issue::SEVERITY_WARNING => 'comment', Is...
Writes a report in human-readable table form. @param Report $report The report to print. @return void
entailment
public function execute() { // Return the mode name by itself. $config = $this->getConfiguration(); $exploded = explode('.', $config[self::MODE]); return $exploded[1]; }
{@inheritdoc}
entailment
public function getVersion() { $current = dirname(__FILE__); while($current !== '/') { if (file_exists($current . '/composer.lock')) { $contents = file_get_contents($current . '/composer.lock'); if ($contents === false) { continue; ...
Gets the currently installed version number. In contrast to the overridden parent method, this variant is Composer-aware and will its own version from the first-best composer.lock file that it can find. @see https://github.com/martin-helmich/typo3-typoscript-lint/issues/35 @return string
entailment
public static function create(ConfigFactoryInterface $config, LoggerInterface $logger) { // Get broker url from config. $settings = $config->get(IslandoraSettingsForm::CONFIG_NAME); $geminiUrl = $settings->get(IslandoraSettingsForm::GEMINI_URL); // Only attempt if there is one. if (!empty($geminiUr...
Factory function. @param \Drupal\Core\Config\ConfigFactoryInterface $config Config. @param \Psr\Log\LoggerInterface $logger The logger channel. @return \Islandora\Crayfish\Commons\Client\GeminiClient Return GeminiClient @throws \Exception If there is no URL to connect to.
entailment
public function execute($entity = NULL) { // Include a token for later authentication in the message. $token = $this->auth->generateToken(); if (empty($token)) { // JWT isn't properly configured. Log and notify user. \Drupal::logger('islandora')->error( t('Error getting JWT token for me...
{@inheritdoc}
entailment
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['queue'] = [ '#type' => 'textfield', '#title' => t('Queue'), '#default_value' => $this->configuration['queue'], '#required' => TRUE, '#rows' => '8', '#description' => t('Name of queue to w...
{@inheritdoc}
entailment
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) { $result = AccessResult::allowed(); return $return_as_object ? $result : $result->isAllowed(); }
{@inheritdoc}
entailment
protected function getSpecialOffset(\Imagick $original, $targetWidth, $targetHeight) { return $this->getCenterOffset($original, $targetWidth, $targetHeight); }
get special offset for class @param \Imagick $original @param int $targetWidth @param int $targetHeight @return array
entailment
protected function getCenterOffset(\Imagick $image, $targetWidth, $targetHeight) { $size = $image->getImageGeometry(); $originalWidth = $size['width']; $originalHeight = $size['height']; $goalX = (int) (($originalWidth-$targetWidth)/2); $goalY = (int) (($originalHeight-$targe...
Get the cropping offset for the image based on the center of the image @param \Imagick $image @param int $targetWidth @param int $targetHeight @return array
entailment
protected function execute(InputInterface $input, OutputInterface $output): void { $filename = $input->getArgument('filename'); '@phan-var string $filename'; $output->writeln("Parsing input file <comment>{$filename}</comment>."); $tokens = $this->tokenizer->tokenizeStream($filenam...
Executes this command. @param InputInterface $input Input options. @param OutputInterface $output Output stream. @return void
entailment
public function initializeClassAttribute( $classAttribute ) { if ( $classAttribute->attribute( self::SUBTREE_LIMIT_FIELD ) === null ) $classAttribute->setAttribute( self::SUBTREE_LIMIT_FIELD, 0 ); if ( $classAttribute->attribute( self::HIDE_ROOT_TAG_FIELD ) === null ) $class...
Initializes the content class attribute @param eZContentClassAttribute $classAttribute
entailment
public function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute ) { if ( $currentVersion != false ) { $eZTags = eZTags::createFromAttribute( $originalContentObjectAttribute, $contentObjectAttribute->attribute( 'language_code' ) ); ...
Initializes content object attribute based on another attribute @param eZContentObjectAttribute $contentObjectAttribute @param eZContentObjectVersion $currentVersion @param eZContentObjectAttribute $originalContentObjectAttribute
entailment
private function validateObjectAttribute( $contentObjectAttribute, $idString, $keywordString, $parentString, $localeString ) { $classAttribute = $contentObjectAttribute->contentClassAttribute(); // we cannot use empty() here as there can be cases where $parentString or $idString can be "0", ...
Validates the data structure and returns true if it is valid for this datatype @param eZContentObjectAttribute $contentObjectAttribute @param string $idString @param string $keywordString @param string $parentString @param string $localeString @return bool
entailment