sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function getFilterPager(Query $query, $currentPage, $maxPerPage) { $adapter = new FilterAdapter($query, $this->getSite()->getFilterService()); $pager = new Pagerfanta($adapter); $pager->setNormalizeOutOfRangePages(true); $pager->setMaxPerPage($maxPerPage); $pager->...
Return Pagerfanta instance using FilterAdapter for the given $query. @param \eZ\Publish\API\Repository\Values\Content\Query $query @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
protected function getFindPager(Query $query, $currentPage, $maxPerPage) { $adapter = new FindAdapter($query, $this->getSite()->getFindService()); $pager = new Pagerfanta($adapter); $pager->setNormalizeOutOfRangePages(true); $pager->setMaxPerPage($maxPerPage); $pager->setCur...
Return Pagerfanta instance using FindAdapter for the given $query. @param \eZ\Publish\API\Repository\Values\Content\Query $query @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
public function getView(View $view) { if (($configHash = $this->matcherFactory->match($view)) === null) { return null; } // We can set the collection directly to the view, no need to go through DTO $view->addParameters([ ContentView::QUERY_DEFINITION_COLLECTI...
@inheritdoc Returns view as a data transfer object. @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
entailment
private function getDTO(array $viewConfig) { $dto = new CoreContentView(); $dto->setConfigHash($viewConfig); if (isset($viewConfig['template'])) { $dto->setTemplateIdentifier($viewConfig['template']); } if (isset($viewConfig['controller'])) { $dto->s...
Builds a ContentView object from $viewConfig. @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType @param array $viewConfig @return \eZ\Publish\Core\MVC\Symfony\View\ContentView
entailment
protected function register_assets() { $icon_picker = Icon_Picker::instance(); if ( defined( 'ICON_PICKER_SCRIPT_DEBUG' ) && ICON_PICKER_SCRIPT_DEBUG ) { $assets_url = '//localhost:8080'; $suffix = ''; } else { $assets_url = $icon_picker->url; $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_D...
Register scripts & styles @since 0.1.0 @since 0.5.0 Use webpack dev server's URL as the asset URL. @access protected @return void
entailment
public function load() { if ( ! is_admin() ) { _doing_it_wrong( __METHOD__, 'It should only be called on admin pages.', esc_html( Icon_Picker::VERSION ) ); return; } if ( ! did_action( 'icon_picker_loader_init' ) ) { _doing_it_wrong( __METHOD__, sprintf( 'It should not be ca...
Load admin functionalities @since 0.1.0 @return void
entailment
public function _enqueue_assets() { $icon_picker = Icon_Picker::instance(); wp_localize_script( 'icon-picker', 'iconPicker', array( 'types' => $icon_picker->registry->get_types_for_js(), ) ); // Some pages don't call this by default, so let's make sure. wp_enqueue_media(); foreach ( $this...
Enqueue scripts & styles @since 0.1.0 @wp_hook action admin_enqueue_scripts @return void
entailment
public function _media_templates() { $icon_picker = Icon_Picker::instance(); foreach ( $icon_picker->registry->types as $type ) { if ( empty( $type->templates ) ) { continue; } $template_id_prefix = "tmpl-iconpicker-{$type->template_id}"; if ( in_array( $template_id_prefix, $this->printed_template...
Media templates @since 0.1.0 @wp_hook action print_media_templates @return void
entailment
protected function collect_packs() { $iterator = new DirectoryIterator( $this->dir ); foreach ( $iterator as $pack_dir ) { if ( $pack_dir->isDot() || ! $pack_dir->isDir() || ! $pack_dir->isReadable() ) { continue; } $pack_dirname = $pack_dir->getFilename(); $pack_data = $this->get_pack_data( $p...
Collect icon packs @since 0.1.0 @access protected @return void
entailment
protected function register_packs() { if ( empty( $this->packs ) ) { return; } $icon_picker = Icon_Picker::instance(); require_once "{$icon_picker->dir}/includes/types/fontello.php"; foreach ( $this->packs as $pack_data ) { $icon_picker->registry->add( new Icon_Picker_Type_Fontello( $pack_data ) ); ...
Register icon packs @since 0.1.0 @access protected @return void
entailment
protected function get_pack_data( DirectoryIterator $pack_dir ) { $pack_dirname = $pack_dir->getFilename(); $pack_path = $pack_dir->getPathname(); $cache_id = "icon_picker_fontpack_{$pack_dirname}"; $cache_data = get_transient( $cache_id ); $config_file = "{$pack_path}/config.json"; if ( fal...
Get icon pack data @since 0.1.0 @access protected @param DirectoryIterator $pack_dir Icon pack directory object. @return array Icon pack data array or FALSE.
entailment
public function get($name) { if (array_key_exists($name, $this->queryDefinitionMap)) { return $this->queryDefinitionMap[$name]; } throw new OutOfBoundsException( "Could not find QueryDefinition with name '{$name}'" ); }
Return QueryDefinition by given $name. @throws \OutOfBoundsException If no QueryDefinition with given $name is found. @param $name @return \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition
entailment
protected function sendRequest($method, $url, $body) { $options = [ 'headers' => [ 'Accept-Encoding' => 'gzip', 'Content-Type' => 'application/json', ], 'body' => $body, ]; try { $response = $this->client->reque...
Send a HTTP request to the server @param string $method HTTP request method @param string $url Relative or absolute url @param string $body HTTP request body @return array JSON response @throws PredictionIOAPIError Request error
entailment
protected function getFilterCriteria(array $parameters) { /** @var \Netgen\EzPlatformSiteApi\API\Values\Content $content */ $content = $parameters['content']; $fields = (array) $parameters['relation_field']; $idsGrouped = [[]]; foreach ($fields as $identifier) { ...
{@inheritdoc} @throws \LogicException @throws \OutOfBoundsException @throws \InvalidArgumentException
entailment
public function setUser($uid, array $properties=array(), $eventTime=null) { $eventTime = $this->getEventTime($eventTime); // casting to object so that an empty array would be represented as {} if (empty($properties)) { $properties = (object)$properties; } $json ...
Set a user entity @param int|string User Id @param array Properties of the user entity to set @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function unsetUser($uid, array $properties, $eventTime=null) { $eventTime = $this->getEventTime($eventTime); if (empty($properties)) { throw new PredictionIOAPIError('Specify at least one property'); } $json = json_encode([ 'event' => '$unset', ...
Unset a user entity @param int|string User Id @param array Properties of the user entity to unset @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function deleteUser($uid, $eventTime=null) { $eventTime = $this->getEventTime($eventTime); $json = json_encode([ 'event' => '$delete', 'entityType' => 'user', 'entityId' => $uid, 'eventTime' => $eventTime, ]); return $this->sen...
Delete a user entity @param int|string User Id @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function setItem($iid, array $properties=array(), $eventTime=null) { $eventTime = $this->getEventTime($eventTime); if (empty($properties)) { $properties = (object)$properties; } $json = json_encode([ 'event' => '$set', 'entityType' => 'item'...
Set an item entity @param int|string Item Id @param array Properties of the item entity to set @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function unsetItem($iid, array $properties, $eventTime=null) { $eventTime = $this->getEventTime($eventTime); if (empty($properties)) { throw new PredictionIOAPIError('Specify at least one property'); } $json = json_encode([ 'event' => '$unset', ...
Unset an item entity @param int|string Item Id @param array Properties of the item entity to unset @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function deleteItem($iid, $eventTime=null) { $eventTime = $this->getEventTime($eventTime); $json = json_encode([ 'event' => '$delete', 'entityType' => 'item', 'entityId' => $iid, 'eventTime' => $eventTime, ]); return $this->sen...
Delete an item entity @param int|string Item Id @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIError Request error
entailment
public function recordUserActionOnItem( $event, $uid, $iid, array $properties=array(), $eventTime=null ) { $eventTime = $this->getEventTime($eventTime); if (empty($properties)) { $properties = (object)$properties; } $json = json_encode([ ...
Record a user action on an item @param string Event name @param int|string User Id @param int|string Item Id @param array Properties of the event @param string Time of the event in ISO 8601 format (e.g. 2014-09-09T16:17:42.937-08:00). Default is the current time. @return string JSON response @throws PredictionIOAPIE...
entailment
public function createEvent(array $data) { $json = json_encode($data); return $this->sendRequest('POST', $this->eventUrl, $json); }
Create an event @param array An array describing the event @return string JSON response @throws PredictionIOAPIError Request error
entailment
final public function getQuery(array $parameters = []) { $parameters = $this->getOptionsResolver()->resolve($parameters); $query = $this->buildQuery(); $sortDefinitions = $parameters['sort']; if (!is_array($sortDefinitions)) { $sortDefinitions = [$sortDefinitions]; ...
{@inheritdoc} @throws \InvalidArgumentException @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface|\InvalidArgumentException @throws \RuntimeException
entailment
protected function configureBaseOptions(OptionsResolver $resolver) { $resolver->setDefined([ 'content_type', 'field', 'publication_date', 'section', 'state', ]); $resolver->setDefaults([ 'sort' => [], 'limit'...
Configure $resolver for the QueryType. @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
entailment
private function buildBaseCriteria(array $parameters) { $criteriaGrouped = [[]]; foreach ($parameters as $name => $value) { switch ($name) { case 'content_type': case 'depth': case 'main': case 'parent_location_id': ...
Build criteria for the base supported options. @param array $parameters @throws \InvalidArgumentException @throws \RuntimeException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion[]
entailment
private function resolveFilterCriteria(array $parameters) { $baseCriteria = $this->buildBaseCriteria($parameters); $registeredCriteria = $this->buildRegisteredCriteria($parameters); $filterCriteria = $this->getFilterCriteria($parameters); if (null === $filterCriteria) { ...
@param array $parameters @throws \InvalidArgumentException @throws \RuntimeException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion|null
entailment
private function getSortClauses(array $parameters) { $sortClauses = []; foreach ($parameters as $parameter) { if (is_string($parameter)) { $parameter = $this->parseSortString($parameter); } if (is_string($parameter)) { $parameter ...
Return an array of SortClause instances from the given $parameters. @throws \InvalidArgumentException @param array $parameters @return \eZ\Publish\API\Repository\Values\Content\Query\SortClause[]
entailment
public function execute(QueryDefinition $queryDefinition, $usePager) { $queryType = $this->queryTypeRegistry->getQueryType($queryDefinition->name); $query = $queryType->getQuery($queryDefinition->parameters); if ($usePager) { return $this->getPager($query, $queryDefinition); ...
Execute the Query with the given $name and return the result. @throws \Pagerfanta\Exception\Exception @throws \RuntimeException @param \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition $queryDefinition @param bool $usePager @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult|\Pagerfa...
entailment
private function getPager(Query $query, QueryDefinition $queryDefinition) { if ($queryDefinition->useFilter) { $adapter = new FilterAdapter($query, $this->filterService); } else { $adapter = new FindAdapter($query, $this->findService); } $pager = new Pagerfan...
Return Pagerfanta instance by the given parameters. @throws \Pagerfanta\Exception\Exception @param \eZ\Publish\API\Repository\Values\Content\Query $query @param \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition $queryDefinition @return \Pagerfanta\Pagerfanta
entailment
private function getLocationResult(LocationQuery $query, QueryDefinition $queryDefinition) { if ($queryDefinition->useFilter) { return $this->filterService->filterLocations($query); } return $this->findService->findLocations($query); }
Return search result by the given parameters. @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query @param \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition $queryDefinition @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
entailment
private function getContentResult(Query $query, QueryDefinition $queryDefinition) { if ($queryDefinition->useFilter) { return $this->filterService->filterContent($query); } return $this->findService->findContent($query); }
Return search result by the given parameters. @param \eZ\Publish\API\Repository\Values\Content\Query $query @param \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition $queryDefinition @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
entailment
public function process($value, ContentView $view) { if (!is_string($value) || 0 !== strpos($value, '@=')) { return $value; } $language = new ExpressionLanguage(); $this->registerFunctions($language); return $language->evaluate( substr($value, 2), ...
Return given $value processed with ExpressionLanguage if needed. Parameter $view is used to provide values for evaluation. @param mixed $value @param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view @return mixed
entailment
private function registerFunctions(ExpressionLanguage $expressionLanguage) { $expressionLanguage->register( 'viewParam', function () {}, function ($arguments, $name, $default) { /** @var \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view */ ...
Register functions with the given $expressionLanguage. @param \Symfony\Component\ExpressionLanguage\ExpressionLanguage $expressionLanguage
entailment
public function addSemanticConfig(NodeBuilder $nodeBuilder) { $nodeBuilder ->arrayNode(static::NODE_KEY) ->info(static::INFO) ->useAttributeAsKey('key') ->normalizeKeys(false) ->prototype('array') ->useAttributeA...
Adds semantic configuration definition. @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
entailment
private function getQueryNode($name) { $queries = new ArrayNodeDefinition($name); $queries ->info('Query configuration') ->useAttributeAsKey('key') ->prototype('array') ->beforeNormalization() // String value is a shortcut to th...
@param string $name @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
entailment
public function build(array $definitions) { $criteria = []; foreach ($definitions as $definition) { $criterion = $this->dispatchBuild($definition); if ($criterion instanceof Criterion) { $criteria[] = $criterion; } } return $crit...
Build criteria for the given array of criterion $definitions. @param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition[] $definitions @throws \InvalidArgumentException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion[]
entailment
private function dispatchBuild(CriterionDefinition $definition) { switch ($definition->name) { case 'content_type': return $this->buildContentTypeIdentifier($definition); case 'depth': return $this->buildDepth($definition); case 'field': ...
Build criterion $name from the given criterion $definition. @param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return null|Criterion
entailment
private function buildField(CriterionDefinition $definition) { return new Field( $definition->target, $definition->operator, $definition->value ); }
@param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\Field
entailment
private function buildIsMainLocation(CriterionDefinition $definition) { if (null === $definition->value) { return null; } $isMainLocation = $definition->value ? IsMainLocation::MAIN : IsMainLocation::NOT_MAIN; return new IsMainLocation($isMainLocation); }
@param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return null|IsMainLocation
entailment
private function buildLogicalNot(CriterionDefinition $definition) { $criteria = $this->build($definition->value); if (1 === count($criteria)) { $criteria = reset($criteria); } else { $criteria = new LogicalAnd($criteria); } return new LogicalNot($cri...
@param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalNot
entailment
private function buildDateMetadataCreated(CriterionDefinition $definition) { return new DateMetadata( DateMetadata::CREATED, $definition->operator, $this->resolveTimeValues($definition->value) ); }
@param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return \eZ\Publish\API\Repository\Values\Content\Query\Criterion\DateMetadata
entailment
private function resolveTimeValues($valueOrValues) { if (!is_array($valueOrValues)) { return $this->resolveTimeValue($valueOrValues); } $returnValues = []; foreach ($valueOrValues as $key => $value) { $returnValues[$key] = $this->resolveTimeValue($value); ...
@param $valueOrValues @throws \InvalidArgumentException @return array|false|int
entailment
private function resolveTimeValue($value) { if (is_int($value)) { return $value; } $timestamp = strtotime($value); if (false === $timestamp) { throw new InvalidArgumentException( "'{$value}' is invalid time string" ); } ...
@param $value @throws \InvalidArgumentException @return int
entailment
private function buildVisibility(CriterionDefinition $definition) { if (null === $definition->value) { return null; } $isVisible = $definition->value ? Visibility::VISIBLE : Visibility::HIDDEN; return new Visibility($isVisible); }
@param \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition $definition @throws \InvalidArgumentException @return null|Visibility
entailment
protected function createContentSearchPager(Query $query, $currentPage, $maxPerPage) { @trigger_error( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.', E_USER_DEPRECATED ); $adapter = new ContentSearchAda...
Returns Pagerfanta pager that starts from first page configured with ContentSearchAdapter and FindService @param \eZ\Publish\API\Repository\Values\Content\Query $query @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
protected function createContentSearchHitPager(Query $query, $currentPage, $maxPerPage) { @trigger_error( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.', E_USER_DEPRECATED ); $adapter = new ContentSearch...
Returns Pagerfanta pager that starts from first page configured with ContentSearchHitAdapter and FindService @param \eZ\Publish\API\Repository\Values\Content\Query $query @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
protected function createLocationSearchPager(LocationQuery $locationQuery, $currentPage, $maxPerPage) { @trigger_error( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.', E_USER_DEPRECATED ); $adapter = new...
Returns Pagerfanta pager that starts from first page configured with LocationSearchAdapter and FindService @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $locationQuery @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
protected function createLocationSearchHitPager(LocationQuery $locationQuery, $currentPage, $maxPerPage) { @trigger_error( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.', E_USER_DEPRECATED ); $adapter = ...
Returns Pagerfanta pager that starts from first page configured with LocationSearchHitAdapter and FindService @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $locationQuery @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
protected function getPager(AdapterInterface $adapter, $currentPage, $maxPerPage) { @trigger_error( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.', E_USER_DEPRECATED ); $pager = new Pagerfanta($adapter);...
Shorthand method for creating Pagerfanta pager with preconfigured Adapter @param \Pagerfanta\Adapter\AdapterInterface $adapter @param int $currentPage @param int $maxPerPage @return \Pagerfanta\Pagerfanta
entailment
public function getNbResults() { if (isset($this->nbResults)) { return $this->nbResults; } $countQuery = clone $this->query; $countQuery->limit = 0; return $this->nbResults = $this->findService->findNodes($countQuery)->totalCount; }
Returns the number of results. @return int The number of results
entailment
public function getSlice($offset, $length) { $query = clone $this->query; $query->offset = $offset; $query->limit = $length; $query->performCount = false; $searchResult = $this->findService->findNodes($query); // Set count for further use if returned by search engin...
Returns a slice of the results, as SearchHit objects. @param int $offset The offset @param int $length The length @return \eZ\Publish\API\Repository\Values\Content\Search\SearchHit[]
entailment
public function get_groups() { $groups = array( array( 'id' => 'a11y', 'name' => __( 'Accessibility', 'icon-picker' ), ), array( 'id' => 'brand', 'name' => __( 'Brand', 'icon-picker' ), ), array( 'id' => 'chart', 'name' => __( 'Charts', 'icon-picker' ), ), array( ...
Get icon groups @since 0.1.0 @return array
entailment
public function get_items() { $items = array( /* Accessibility (a11y) */ array( 'group' => 'a11y', 'id' => ' fa-american-sign-language-interpreting', 'name' => __( 'American Sign Language', 'icon-picker' ), ), array( 'group' => 'a11y', 'id' => ' fa-audio-description', 'name'...
Get icon names @since 0.1.0 @return array
entailment
public function get_stylesheet_uri() { $stylesheet_uri = sprintf( '%1$s/css/types/%2$s%3$s.css', Icon_Picker::instance()->url, $this->stylesheet_id, ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ); /** * Filters icon type's stylesheet URI * * @since 0.4.0 * * @param str...
Get stylesheet URI @since 0.1.0 @return string
entailment
public function register_assets( Icon_Picker_Loader $loader ) { if ( empty( $this->stylesheet_uri ) ) { return; } $register = true; $deps = false; $styles = wp_styles(); /** * When the stylesheet ID of an icon type is already registered, * we'll compare its version with ours. If our stylesh...
Register assets @since 0.1.0 @wp_hook action icon_picker_loader_init @param Icon_Picker_Loader $loader Icon_Picker_Loader instance. @return void
entailment
public function __isset($property) { switch ($property) { case 'contentInfo': case 'contentId': case 'parent': case 'content': return true; } if (property_exists($this, $property) || property_exists($this->innerLocation, $prope...
Magic isset for signaling existence of convenience properties. @param string $property @return bool
entailment
public function parse($definition) { $values = explode(' ', $definition); $direction = $this->getDirection($values); $values = explode('/', $values[0]); $type = $values[0]; switch (strtolower($type)) { case 'depth': return new Depth($direction); ...
Return new sort clause instance by the given $definition string. @throws \InvalidArgumentException @param string $definition @return \eZ\Publish\API\Repository\Values\Content\Query\SortClause
entailment
private function buildFieldSortClause(array $values, $direction) { if (!array_key_exists(1, $values)) { throw new InvalidArgumentException( 'Field sort clause requires ContentType identifier' ); } if (!array_key_exists(2, $values)) { throw...
Build a new Field sort clause from the given arguments. @throws \InvalidArgumentException @param array $values @param mixed $direction @return \eZ\Publish\API\Repository\Values\Content\Query\SortClause\Field
entailment
private function getDirection(array $values) { $direction = 'asc'; if (array_key_exists(1, $values)) { $direction = $values[1]; } switch (strtolower($direction)) { case 'asc': return Query::SORT_ASC; case 'desc': r...
Resolve direction constant value from the given array of $values. @throws \InvalidArgumentException @param string[] $values @return mixed
entailment
private function registerResolver(Definition $resolverRegistryDefinition, $id, array $attributes) { foreach ($attributes as $attribute) { if (!isset($attribute['identifier'])) { throw new LogicException( "'{$this->resolverTag}' service tag needs an 'identifier...
Add method call to register resolver with given $id with resolver registry. @throws \LogicException @param \Symfony\Component\DependencyInjection\Definition $resolverRegistryDefinition @param string $id @param array $attributes
entailment
private function getSiteLocation(APILocation $location) { $versionInfo = $this->contentService->loadVersionInfoById($location->contentInfo->id); $languageCode = $this->getLanguage( $versionInfo->languageCodes, $versionInfo->contentInfo->mainLanguageCode, $version...
Returns Site Location object for the given Repository $location. @throws \Netgen\EzPlatformSiteApi\Core\Site\Exceptions\TranslationNotMatchedException @param \eZ\Publish\API\Repository\Values\Content\Location $location @return \Netgen\EzPlatformSiteApi\API\Values\Location
entailment
private function getSiteNode(APILocation $location) { $versionInfo = $this->contentService->loadVersionInfoById($location->contentInfo->id); $languageCode = $this->getLanguage( $versionInfo->languageCodes, $versionInfo->contentInfo->mainLanguageCode, $versionInfo...
Returns Site Node object for the given Repository $location. @throws \Netgen\EzPlatformSiteApi\Core\Site\Exceptions\TranslationNotMatchedException @param \eZ\Publish\API\Repository\Values\Content\Location $location @return \Netgen\EzPlatformSiteApi\API\Values\Node
entailment
private function getLanguage(array $languageCodes, $mainLanguageCode, $alwaysAvailable) { $languageCodesSet = array_flip($languageCodes); foreach ($this->settings->prioritizedLanguages as $languageCode) { if (isset($languageCodesSet[$languageCode])) { return $languageCod...
Returns the most prioritized language for the given parameters. Will return null if language could not be resolved. @param string[] $languageCodes @param string $mainLanguageCode @param bool $alwaysAvailable @return string|null
entailment
private function getContext(VersionInfo $versionInfo) { return [ 'prioritizedLanguages' => $this->settings->prioritizedLanguages, 'useAlwaysAvailable' => $this->settings->useAlwaysAvailable, 'availableTranslations' => $versionInfo->languageCodes, 'mainTranslat...
Returns an array describing language resolving context. To be used when throwing TranslationNotMatchedException. @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo @return array
entailment
public function createEvent( $event, $entityType, $entityId, $targetEntityType=null, $targetEntityId=null, array $properties=null, $eventTime=null ) { if (!isset($eventTime)) { $eventTime = new \DateTime(); } elseif (!($eventTime in...
Create and export a json-encoded event. @see \predictionio\EventClient::CreateEvent() @param $event @param $entityType @param $entityId @param null $targetEntityType @param null $targetEntityId @param array $properties @param $eventTime
entailment
public function build_signature($request, $consumer, $token) { $key_parts = array( $consumer->secret, ($token) ? $token->secret : "" ); $key_parts = OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key...
oauth_signature is set to the concatenated encoded values of the Consumer Secret and Token Secret, separated by a '&' character (ASCII code 38), even if either secret is empty. The result MUST be encoded again. - Chapter 9.4.1 ("Generating Signatures") Please note that the second encoding MUST NOT happen in the Signat...
entailment
public function createDictionary($entityId, $matchType = null, $caseInsensitive = null, $language = null) { $request = []; if ( ! is_string($entityId)) { throw new Exception('TextRazor Error: Custom Entity Dictionaries must have an ID.'); } if (isset($matchType)) { ...
Creates a new dictionary using properties provided in the dict $dictionaryProperties. See the properties of class Dictionary for valid options. @param $entityId @param null $matchType @param null $caseInsensitive @param null $language @return mixed @throws \Exception
entailment
protected function createCookieDriver() { $determiner = new Determiners\Cookie( $this->app['config']['localize-middleware']['cookie'] ); $determiner->setFallback($this->app['config']['app']['fallback_locale']); return $determiner; }
Get a cookie determiner instance. @return \BenConstable\Localize\Determiners\Cookie
entailment
protected function createHostDriver() { $determiner = new Determiners\Host( new Collection($this->app['config']['localize-middleware']['hosts']) ); $determiner->setFallback($this->app['config']['app']['fallback_locale']); return $determiner; }
Get a host determiner instance. @return \BenConstable\Localize\Determiners\Host
entailment
protected function createParameterDriver() { $determiner = new Determiners\Parameter( $this->app['config']['localize-middleware']['parameter'] ); $determiner->setFallback($this->app['config']['app']['fallback_locale']); return $determiner; }
Get a parameter determiner instance. @return \BenConstable\Localize\Determiners\Parameter
entailment
protected function createHeaderDriver() { $determiner = new Determiners\Header( $this->app['config']['localize-middleware']['header'] ); $determiner->setFallback($this->app['config']['app']['fallback_locale']); return $determiner; }
Get a header determiner instance. @return \BenConstable\Localize\Determiners\Header
entailment
protected function createSessionDriver() { $determiner = new Determiners\Session( $this->app['config']['localize-middleware']['session'] ); $determiner->setFallback($this->app['config']['app']['fallback_locale']); return $determiner; }
Get a session determiner instance. @return \BenConstable\Localize\Determiners\Session
entailment
protected function createStackDriver() { $determiners = (new Collection((array) $this->app['config']['localize-middleware']['driver'])) ->filter(function ($driver) { return $driver !== 'stack'; }) ->map(function ($driver) { return $this->dr...
Get a stack determiner instance. @return \BenConstable\Localize\Determiners\Stack
entailment
public function _set($name, $value) { $setMethod = 'set' . ucfirst($name); if (method_exists($this, $setMethod)) { $this->$setMethod($value); } else { throw new \InvalidArgumentException(sprintf('Setter does not exist for "%s" property', $name)); } ret...
Generic method setting value @throws \InvalidArgumentException @param string $name property name to set @param mixed $value property value to use @return self
entailment
public function _get($name) { $getMethod = 'get' . ucfirst($name); if (method_exists($this, $getMethod)) { return $this->$getMethod(); } throw new \InvalidArgumentException(sprintf('Getter does not exist for "%s" property', $name)); }
Generic method getting value @throws \InvalidArgumentException @param string $name property name to get @return mixed
entailment
public static function findByName(string $name, $guardName = null): PermissionContract { $guardName = $guardName ?? Guard::getDefaultName(static::class); $permission = static::getPermissions()->where('name', $name)->where('guard_name', $guardName)->first(); if (! $permission) { ...
Find a permission by its name (and optionally guardName). @param string $name @param string|null $guardName @throws \Konekt\Acl\Exceptions\PermissionDoesNotExist @return \Konekt\Acl\Contracts\Permission
entailment
public function scopeRole(Builder $query, $roles): Builder { if ($roles instanceof Collection) { $roles = $roles->all(); } if (! is_array($roles)) { $roles = [$roles]; } $roles = array_map(function ($role) { if ($role instanceof Role) { ...
Scope the model query to certain roles only. @param \Illuminate\Database\Eloquent\Builder $query @param string|array|Role|\Illuminate\Support\Collection $roles @return \Illuminate\Database\Eloquent\Builder
entailment
protected function convertToPermissionModels($permissions): array { if ($permissions instanceof Collection) { $permissions = $permissions->all(); } $permissions = array_wrap($permissions); return array_map(function ($permission) { if ($permission instanceof ...
@param string|array|\Spatie\Permission\Contracts\Permission|\Illuminate\Support\Collection $permissions @return array
entailment
public function assignRole(...$roles) { $roles = collect($roles) ->flatten() ->map(function ($role) { return $this->getStoredRole($role); }) ->each(function ($role) { $this->ensureModelSharesGuard($role); }) ...
Assign the given role to the model. @param array|string|\Konekt\Acl\Contracts\Role ...$roles @return $this
entailment
public function hasRole($roles): bool { if (is_string($roles) && false !== strpos($roles, '|')) { $roles = $this->convertPipeToArray($roles); } if (is_string($roles)) { return $this->roles->contains('name', $roles); } if ($roles instanceof Role) { ...
Determine if the model has (one of) the given role(s). @param string|array|\Konekt\Acl\Contracts\Role|\Illuminate\Support\Collection $roles @return bool
entailment
public function hasAllRoles($roles): bool { if (is_string($roles) && false !== strpos($roles, '|')) { $roles = $this->convertPipeToArray($roles); } if (is_string($roles)) { return $this->roles->contains('name', $roles); } if ($roles instanceof Role) ...
Determine if the model has all of the given role(s). @param string|array|\Konekt\Acl\Contracts\Role|\Illuminate\Support\Collection $roles @return bool
entailment
public function hasPermissionTo($permission, $guardName = null): bool { if (is_string($permission)) { $permission = PermissionProxy::findByName( $permission, $guardName ?? $this->getDefaultGuardName() ); } return $this->hasDirectPermis...
Determine if the model may perform the given permission. @param string|\Konekt\Acl\Contracts\Permission $permission @param string|null $guardName @return bool
entailment
public function hasDirectPermission($permission): bool { if (is_string($permission)) { $permission = PermissionProxy::findByName($permission, $this->getDefaultGuardName()); if (! $permission) { return false; } } return $this->permissions-...
Determine if the model has the given permission. @param string|\Konekt\Acl\Contracts\Permission $permission @return bool
entailment
public function get($key) { $env = $this->parseFile(); $result = $env->filter(function (Collection $value) use ($key) { return $value->first() == $key; })->first(); return $result instanceof Collection ? $result->get(1) : $result; }
Get an entry from the .env file by key. @param string $key @return string
entailment
public function set($key, $value, $linebreak = false) { $oldValue = $this->get($key); if (! preg_match('/\d/', $value) || preg_match('/=/', $value)) { $value = "\"$value\""; } $new = $linebreak ? "\n$key=$value" : "$key=$value"; if (! is_null($oldValue)) { ...
Set the value of the given key to the value supplied. @param string $key @param string $value @param bool $linebreak @return \Sven\FlexEnv\Env
entailment
public function all() { $env = $this->parseFile(); $result = []; $env->each(function (Collection $value) use (&$result) { return $result[$value->first()] = $value->get(1); }); return $result; }
Gets all the key/value pairs from the .env file. @return array
entailment
private function parseFile() { $contents = file_get_contents($this->getPath()); $lines = new Collection(explode("\n", $contents)); $result = new Collection(); $lines->filter(function ($value) { return $value; })->each(function ($value) use ($result) { ...
Parse the .env file contents for easier handling. @return \Illuminate\Support\Collection
entailment
public function replaceInFile($old, $new, $append = 0) { $contents = $this->previous; $replaceWith = preg_replace("~$old\n?~", "$new\n", $contents); file_put_contents($this->getPath(), $replaceWith, $append); return $this; }
Replace a part of the .env file. @param string $old @param string $new @param int $append @return \Sven\FlexEnv\Env
entailment
public function handle() { $env = new Env(base_path('.env')); $key = strtoupper($this->argument('key')); $result = str_replace('"', '', $env->get($key)); if ($result == '' || is_null($result)) { return $this->error("Could not find a value for [$key] in your .env file.");...
Execute the console command. @return void
entailment
public function givePermissionTo(...$permissions) { $permissions = collect($permissions) ->flatten() ->map(function ($permission) { return $this->getStoredPermission($permission); }) ->each(function ($permission) { $this->ensure...
Grant the given permission(s) to a role. @param string|array|\Konekt\Acl\Contracts\Permission|\Illuminate\Support\Collection $permissions @return $this
entailment
public function revokePermissionTo($permission) { $this->permissions()->detach($this->getStoredPermission($permission)); $this->forgetCachedPermissions(); return $this; }
Revoke the given permission. @param \Konekt\Acl\Contracts\Permission|\Konekt\Acl\Contracts\Permission[]|string|string[] $permission @return $this
entailment
protected function getStoredPermission($permissions) { if (is_string($permissions)) { return PermissionProxy::findByName($permissions, $this->getDefaultGuardName()); } if (is_array($permissions)) { return PermissionProxy::whereIn('name', $permissions) ...
@param string|array|\Konekt\Acl\Contracts\Permission|\Illuminate\Support\Collection $permissions @return \Konekt\Acl\Contracts\Permission|\Konekt\Acl\Contracts\Permission|\Illuminate\Support\Collection
entailment
public function determineLocale(Request $request) { return $request->session()->get($this->sessionKey, $this->fallback); }
Determine the locale from the session. @param \Illuminate\Http\Request $request @return string
entailment
public function determineLocale(Request $request) { $locale = $this->determiners ->map(function ($determiner) use ($request) { return $determiner->determineLocale($request); }) ->filter() ->first(); return $locale ?: $this->fallback; ...
Determine the locale from the underlying determiner stack. @param \Illuminate\Http\Request $request @return string|null
entailment
static function clear() { if ( empty(self::$_cache) || DEBUGKEEPTEMP ) return; foreach ( self::$_cache as $file ) { if (DEBUGPNG) print "[clear unlink $file]"; unlink($file); } }
Unlink all cached images (i.e. temporary images either downloaded or converted)
entailment
public function getLogsFromCurrentFile() { if ($this->currentFile === null) { return []; } if (File::size($this->currentFile) > $this->maxFileSize) { return; } $datePattern = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'; $pattern = "/\\[$datePattern...
Returns logs from current file. @return array|null
entailment
public function getCurrentDirectoryContent() { $content = File::glob($this->currentDir . DIRECTORY_SEPARATOR . '*'); $content = array_map(function ($item) { return (object) [ 'path' => $this->getPathRelativeToBaseDir($item), 'name' => Str::substr( ...
Returns content (files and folders) of current folder. @return array
entailment
public function setCurrentDirectory($directory) { $directory = $this->normalizePath("$this->baseDir/$directory"); $this->checkIfPathInBaseDir($directory); $this->currentDir = $directory; return $this; }
@param string $directory Relative path to directory from base path. @throws InvalidArgumentException @return $this
entailment
public function setCurrentFile($file) { $file = $this->normalizePath("$this->baseDir/$file"); $this->checkIfPathInBaseDir($file); $this->currentFile = $file; $dir = File::dirname($file); $this->currentDir = $dir; return $this; }
@param string $file Relative path to file from base directory. @throws InvalidArgumentException @return $this
entailment
public function getRelativePathToCurrentDirectoryParent() { if ($this->baseDir === $this->currentDir) { return DIRECTORY_SEPARATOR; } $path = realpath($this->currentDir . DIRECTORY_SEPARATOR . '..'); return $this->getPathRelativeToBaseDir($path) ?: DIRECTORY_SEPARATOR; ...
Returns path to parent of current directory. @return string
entailment