sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function execute($returnTransfer = TRUE) { //Need transfer return if($returnTransfer === TRUE) { $this->setOption(CURLOPT_RETURNTRANSFER, 1); } $result = curl_exec($this->handler); //Error handling if(curl_errno($this->handler)) { $format ...
Execute the prepared request and optionally returns the response @param bool $returnTransfer Returns the returned response @throws \BuildR\Foundation\Exception\RuntimeException @return array|\stdClass @codeCoverageIgnore
entailment
public function pushEndpointHandler($apiName, $handlerClassName) { if(!class_exists($handlerClassName)) { throw new RuntimeException('This handler class (' . $handlerClassName . ') not found!'); } $apiName = ucfirst(strtolower($apiName)); $this->uniqueEndpointHandlers[$apiN...
Pushes a unique handler to the stack. Unique handlers are preferred, over default handlers. One endpoint only have on unique handler, and if you push another it will overwrite the previous @param string $apiName @param string $handlerClassName The handler FQCN @throws \BuildR\Foundation\Exception\RuntimeException
entailment
protected function getEndpointHandler($apiName, ReflectionClass $endpointReflector) { if(isset($this->endpointObjectCache[$apiName])) { return $this->endpointObjectCache[$apiName]; } //Create a new instance and store it $endpointInstance = $endpointReflector->newInstanceArgs...
Returns a new instance from the given endpoint handler. In the instance creation the client is passed to tha handler as parameter. This method also do runtime caching. All endpoint handler cached by name @param string $apiName Used as cache key name @param \ReflectionClass $endpointReflector @return \Phabricator\End...
entailment
protected function getExecutorMethod($methodName, ReflectionClass $endpointReflector) { $neededMethod = strtolower($methodName) . "Executor"; if(!$endpointReflector->hasMethod($neededMethod)) { $neededMethod = "defaultExecutor"; } return $endpointReflector->getMethod($neede...
Return the reflector of the method that can execute the query on the endpoint. @param string $methodName Like "query" @param \ReflectionClass $endpointReflector @return \ReflectionMethod
entailment
protected function getHandlerClassName($apiName) { $apiName = ucfirst(strtolower($apiName)); $neededClass = __NAMESPACE__ . '\\' . 'Endpoints\\Defaults\\' . $apiName; if(isset($this->uniqueEndpointHandlers[$apiName])) { $neededClass = $this->uniqueEndpointHandlers[$apiName]; ...
Returns the FQCN of the handler class. Returns the default handler if no unique handler available for the given endpoint. @param string $apiName Like "Project" @return string
entailment
protected function getDataByArguments(array $arguments) { if(!isset($arguments[0])) { throw new RuntimeException('The arguments not contains the method name!'); } $methodName = (string) $arguments[0]; $methodArgs = []; if(isset($arguments[1]) && is_array($arguments[...
Get the base date by the passed array. The returned array contains the method name (on endpoint) and the arguments that the called method can give. Returned array keys: - (string) methodName - (array) methodArgs @param array $arguments The magic method argument array @throws \BuildR\Foundation\Exception\RuntimeExcep...
entailment
public function check(Request $request) { $this->response = $this->verify($request->input('g-recaptcha-response'), $request->ip()); return $this; }
Verify captcha @param \Illuminate\Http\Request $request @return $this
entailment
private function getMemory() { $memory = shmop_open($this->key, "c", 0644, self::LIMIT); if (!$memory) { throw new Exception("Unable to open the shared memory block"); } return $memory; }
Get the shared memory segment. @return resource
entailment
private function unserialize($memory): array { $data = shmop_read($memory, 0, self::LIMIT); $exceptions = unserialize($data); if (!is_array($exceptions)) { $exceptions = []; } return $exceptions; }
Get the exception details out of shared memory. @param resource $memory The shmop resource from shmop_open() @return \Throwable[]
entailment
public function addException(\Throwable $exception) { $memory = $this->getMemory(); $exceptions = $this->unserialize($memory); $exceptions[] = get_class($exception) . ": " . $exception->getMessage() . " (" . $exception->getFile() . ":" . $exception->getLine() . ")"; $data = serial...
Add an exception the shared memory. @param \Throwable $exception The exception instance to add @return void
entailment
public function getExceptions(): array { $memory = $this->getMemory(); $exceptions = $this->unserialize($memory); shmop_write($memory, serialize([]), 0); shmop_close($memory); return $exceptions; }
Get all the exceptions added to the shared memory. @return \Throwable[]
entailment
public function delete() { $memory = shmop_open($this->key, "a", 0, 0); if ($memory) { shmop_delete($memory); shmop_close($memory); } }
Delete the shared memory this instance represents. @return void
entailment
public function getGridCols() { $arrColumns = array(); // columns if($GLOBALS['EUF_GRID_SETTING']['cols']) { foreach($GLOBALS['EUF_GRID_SETTING']['cols'] as $option) { foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) { foreach($GLOBALS['EUF_GRID_SETTING']['colu...
Optionen für Select-Feld 'Grid-Spalten' aus config laden und zusammenbauen
entailment
public function getGridOptions() { $arrOptions = array(); // Offset if($GLOBALS['EUF_GRID_SETTING']['offset']) { foreach($GLOBALS['EUF_GRID_SETTING']['offset'] as $option) { foreach ($GLOBALS['EUF_GRID_SETTING']['viewports'] as $viewport) { foreach($GLOBALS['EUF_GRID_SETTING']...
Optionen für Select-Feld 'Grid-Optionen' aus config laden und zusammenbauen
entailment
public static function addClassesToLabels($arrRow, $return) { // Grid-Klassen dem Typ hinzufügen $grid = "("; if($arrRow['grid_columns'] != "" ) { $strField = "grid_columns"; $env = "BE"; $arrGridClasses = deserialize($arrRow['grid_columns']); // HOOK: create and manipulat...
Funktion zum Anzeigen der Grid-Klassen in der Übersicht im BE
entailment
protected function addLogosAndIcons(FieldList $fields) { $logoTypes = array('jpg', 'jpeg', 'png', 'gif'); $iconTypes = array('ico'); $appleTouchTypes = array('png'); $fields->findOrMakeTab( 'Root.LogosIcons', _t(__CLASS__ . '.LogosIconsTab', 'Logos/Icons') ...
Add fields for logo and icon uploads @param FieldList $fields @return $this
entailment
protected function addSearchOptions(FieldList $fields) { $fields->findOrMakeTab('Root.SearchOptions'); $fields->addFieldToTab( 'Root.SearchOptions', TextField::create( 'EmptySearch', _t( 'CWP.SITECONFIG.EmptySearch', ...
Add user configurable search field labels @param FieldList $fields @return $this
entailment
protected function addThemeColorPicker(FieldList $fields) { // Only show theme colour selector if enabled if (!$this->owner->config()->get('enable_theme_color_picker')) { return $this; } $fonts = $this->owner->config()->get('theme_fonts'); // Import each font vi...
Add fields for selecting the font theme colour for different areas of the site. @param FieldList $fields @return $this
entailment
public function getThemeOptionsExcluding($excludedColors = []) { $themeColors = $this->owner->config()->get('theme_colors'); $options = []; foreach ($themeColors as $themeColor) { if (in_array($themeColor['CSSClass'], $excludedColors)) { continue; } ...
Returns theme_colors used for ColorPickerField. @param array $excludedColors list of colours to exclude from the returned options based on the theme colour's 'CSSClass' value @return array
entailment
public function onBeforeWrite() { $colorPickerEnabled = $this->owner->config()->get('enable_theme_color_picker'); if ($colorPickerEnabled && !$this->owner->HeaderBackground) { $this->owner->update([ 'MainFontFamily' => FontPickerField::DEFAULT_VALUE, 'Hea...
If HeaderBackground is not set, assume no theme colours exist and populate some defaults if the colour picker is enabled. We don't use populateDefaults() because we don't want SiteConfig to re-populate its own defaults.
entailment
public function addGridClasses($objElement, $strBuffer) { // Init $strClasses = ""; // Bei diesen ContentElementen soll nichts verändert werden $arrWrongCE = array('rowStart', 'rowEnd', 'colEnd'); // Abfrage, ob anzupassenden CEs und Klassen gesetzt wurden if (!in_array($objElement->type, $a...
Grid-Klassen dem CE hinzufügen
entailment
public function addGridClassesToForms($objWidget, $strForm, $arrForm) { // Init $strClasses = ""; // Bei diesen ContentElementen soll nichts verändert werden $arrWrongFields = array('rowStart', 'rowEnd', 'colEnd', 'html', 'fieldsetfsStop'); // Abfrage, ob anzupassenden CEs und Klassen gesetzt wu...
Grid-Klassen dem CE hinzufügen
entailment
public function __isset($property) { switch ($property) { case 'mainLocation': case 'content': return true; } if (property_exists($this, $property) || property_exists($this->innerContentInfo, $property)) { return true; } r...
Magic isset for signaling existence of convenience properties. @param string $property @return bool
entailment
protected function extractValueObjects(SearchResult $searchResult) { return array_map( function (SearchHit $searchHit) { return $searchHit->valueObject; }, $searchResult->searchHits ); }
Extracts value objects from SearchResult. @param \eZ\Publish\API\Repository\Values\Content\Search\SearchResult $searchResult @return \eZ\Publish\API\Repository\Values\ValueObject[]
entailment
public function get_groups() { $groups = array( array( 'id' => 'actions', 'name' => __( 'Actions', 'icon-picker' ), ), array( 'id' => 'currency', 'name' => __( 'Currency', 'icon-picker' ), ), array( 'id' => 'media', 'name' => __( 'Media', 'icon-picker' ), ), array( ...
Get icon groups @since 0.1.0 @return array
entailment
public function get_items() { $items = array( array( 'group' => 'actions', 'id' => 'el-icon-adjust', 'name' => __( 'Adjust', 'icon-picker' ), ), array( 'group' => 'actions', 'id' => 'el-icon-adjust-alt', 'name' => __( 'Adjust', 'icon-picker' ), ), array( 'group' => '...
Get icon names @since 0.1.0 @return array
entailment
public static function exec($url, array $req = []) { usleep(120000); // generate the POST data string $postData = http_build_query($req, '', '&'); // curl handle (initialize if required) if (is_null(self::$ch)) { self::$ch = curl_init(); curl_setopt(self...
Executes curl request to the CoinMarketCap API. @param array $req Request parameters list. @return array JSON data. @throws \Exception If Curl error or CoinMarketCap API error occurred.
entailment
public static function json($url) { $opts = [ 'http' => [ 'method' => 'GET', 'timeout' => 10 ] ]; $context = stream_context_create($opts); $feed = file_get_contents($url, false, $context); $json = json_decode($feed, true); ...
Executes simple GET request to the CoinMarketCap public API. @param string $url API method URL. @return array JSON data.
entailment
public function mapContent(VersionInfo $versionInfo, $languageCode) { $contentInfo = $versionInfo->contentInfo; return new Content( [ 'id' => $contentInfo->id, 'mainLocationId' => $contentInfo->mainLocationId, 'name' => $versionInfo->getNa...
Maps Repository Content to the Site Content. @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo @param string $languageCode @return \Netgen\EzPlatformSiteApi\Core\Site\Values\Content
entailment
public function mapContentInfo(VersionInfo $versionInfo, $languageCode) { $contentInfo = $versionInfo->contentInfo; $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId); return new ContentInfo( [ 'name' => $versionInfo->getName($...
Maps Repository ContentInfo to the Site ContentInfo. @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo @param string $languageCode @return \Netgen\EzPlatformSiteApi\API\Values\ContentInfo
entailment
public function mapLocation(APILocation $location, VersionInfo $versionInfo, $languageCode) { return new Location( [ 'innerLocation' => $location, 'languageCode' => $languageCode, 'innerVersionInfo' => $versionInfo, 'site' => $this-...
Maps Repository Location to the Site Location. @param \eZ\Publish\API\Repository\Values\Content\Location $location @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo @param string $languageCode @return \Netgen\EzPlatformSiteApi\API\Values\Location
entailment
public function mapNode(APILocation $location, APIContent $content, $languageCode) { return new Node( [ 'contentInfo' => $this->mapContentInfo($content->versionInfo, $languageCode), 'innerLocation' => $location, 'content' => $this->mapContent($cont...
Maps Repository Content and Location to the Site Node. @param \eZ\Publish\API\Repository\Values\Content\Location $location @param \eZ\Publish\API\Repository\Values\Content\Content $content @param string $languageCode @return \Netgen\EzPlatformSiteApi\Core\Site\Values\Node
entailment
public function mapField(APIField $apiField, SiteContent $content) { $fieldDefinition = $content->contentInfo->innerContentType->getFieldDefinition($apiField->fieldDefIdentifier); $fieldTypeIdentifier = $fieldDefinition->fieldTypeIdentifier; $isEmpty = $this->fieldTypeService->getFieldType($...
Maps Repository Field to the Site Field. @param \eZ\Publish\API\Repository\Values\Content\Field $apiField @param \Netgen\EzPlatformSiteApi\API\Values\Content $content @return \Netgen\EzPlatformSiteApi\API\Values\Field
entailment
protected function getFilterCriteria(array $parameters) { /** @var \Netgen\EzPlatformSiteApi\API\Values\Location $location */ $location = $parameters['location']; return [ new ParentLocationId($location->parentLocationId), new LogicalNot(new LocationId($location->id)...
{@inheritdoc} @throws \InvalidArgumentException
entailment
protected function configureOptions(OptionsResolver $resolver) { $resolver->remove(['parent_location_id', 'subtree']); $resolver->setRequired(['location']); $resolver->setDefined([ 'exclude_self', 'relative_depth', ]); $resolver->setAllowedTypes('loca...
{@inheritdoc} @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException @throws \Symfony\Component\OptionsResolver\Exception\AccessException
entailment
protected function getFilterCriteria(array $parameters) { /** @var \Netgen\EzPlatformSiteApi\API\Values\Location $location */ $location = $parameters['location']; $criteria = []; $criteria[] = new SubtreeCriterion($location->pathString); if ($parameters['exclude_self']) { ...
{@inheritdoc} @throws \InvalidArgumentException
entailment
public function getNbResults() { if (isset($this->nbResults)) { return $this->nbResults; } return $this->nbResults = $this->getSearchResultWithLimitZero()->totalCount; }
Returns the number of results. @return int The number of results
entailment
public function getFacets() { if (isset($this->facets)) { return $this->facets; } return $this->facets = $this->getSearchResultWithLimitZero()->facets; }
Returns the facets of the results. @return \eZ\Publish\API\Repository\Values\Content\Search\Facet[] The facets of the results
entailment
public function getSlice($offset, $length) { $query = clone $this->query; $query->offset = $offset; $query->limit = $length; $query->performCount = false; $searchResult = $this->filterService->filterLocations($query); // Set count for further use if returned by sear...
Returns a slice of the results, as Site Location objects. @param int $offset The offset @param int $length The length @return \Netgen\EzPlatformSiteApi\API\Values\Location[]
entailment
public function get_items() { $items = array( array( 'group' => 'actions', 'id' => 'genericon-checkmark', 'name' => __( 'Checkmark', 'icon-picker' ), ), array( 'group' => 'actions', 'id' => 'genericon-close', 'name' => __( 'Close', 'icon-picker' ), ), array( 'group' ...
Get icon names @since 0.1.0 @return array
entailment
public function isValid($name, $password, $realm = null) { return ($name == $this->name) && ($password == $this->password); }
Checks for valid username & password @param string $name @param string $password @return boolean
entailment
public function parse() { if (array_key_exists('PHP_AUTH_USER', $_SERVER)) { // mod_php $this->name = $_SERVER['PHP_AUTH_USER']; $this->password = array_key_exists('PHP_AUTH_PW', $_SERVER) ? $_SERVER['PHP_AUTH_PW'] : null; } elseif (array_key_exists('HTTP_AUTHENTICATION', $_S...
Parses the User Information from server variables @return void
entailment
private function getQueryDefinitionCollection($context) { $variableName = ContentView::QUERY_DEFINITION_COLLECTION_NAME; if (is_array($context) && array_key_exists($variableName, $context)) { return $context[$variableName]; } throw new Twig_Error_Runtime( "C...
Returns the QueryDefinitionCollection variable from the given $context. @throws \Twig_Error_Runtime @param mixed $context @return \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinitionCollection
entailment
public function get($fieldTypeIdentifier) { if (isset($this->resolverMap[$fieldTypeIdentifier])) { return $this->resolverMap[$fieldTypeIdentifier]; } throw new OutOfBoundsException( "No relation resolver is registered for field type identifier '{$fieldTypeIdentifier}...
Returns Resolver for $fieldTypeIdentifier. @throws \OutOfBoundsException When there is no resolver for the given $fieldTypeIdentifier @param string $fieldTypeIdentifier @return \Netgen\EzPlatformSiteApi\Core\Site\Plugins\FieldType\RelationResolver\Resolver
entailment
public function buildView(array $parameters) { $view = new ContentView(null, [], $parameters['viewType']); $view->setIsEmbed($this->isEmbed($parameters)); if ($view->isEmbed() && $parameters['viewType'] === null) { $view->setViewType(EmbedView::DEFAULT_VIEW_TYPE); } ...
@throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException If both contentId and locationId parameters are missing @throws \eZ\Publish\Core\Base\Exceptions\UnauthorizedException @param array $parameters @return \eZ\Publish\Core\MVC\Symfony\View\ContentView|\eZ\Publish\Core\MVC\Symfony\View\View If both content...
entailment
private function loadEmbeddedContent($contentId, Location $location = null) { $repositoryLocation = null; /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */ $contentInfo = $this->repository->sudo( function (Repository $repository) use ($contentId) { ...
Loads the embedded content with id $contentId. Will load the content with sudo(), and check if the user can view_embed this content, for the given location if provided. @throws \eZ\Publish\Core\Base\Exceptions\UnauthorizedException @param string|int $contentId @param \Netgen\EzPlatformSiteApi\API\Values\Location $loc...
entailment
private function loadLocation($locationId, $checkVisibility = true) { $location = $this->repository->sudo( function (Repository $repository) use ($locationId) { return $this->site->getLoadService()->loadLocation($locationId); } ); if ($checkVisibility...
Loads a visible Location. @todo Do we need to handle permissions here ? @param string|int $locationId @param bool $checkVisibility @return \Netgen\EzPlatformSiteApi\API\Values\Location
entailment
private function canRead(ContentInfo $contentInfo, Location $location = null) { $limitations = ['valueObject' => $contentInfo]; if (isset($location)) { $limitations['targets'] = $location; } $readAttribute = new AuthorizationAttribute('content', 'read', $limitations); ...
Checks if a user can read a content, or view it as an embed. @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo @param $location @return bool
entailment
protected function getForwardRequest(Location $location, Content $content, SiteAccess $previewSiteAccess, Request $request, $language) { $request = parent::getForwardRequest($location, $content, $previewSiteAccess, $request, $language); $overrideViewAction = $this->configResolver->getParameter( ...
{@inheritdoc} @throws \Netgen\EzPlatformSiteApi\API\Exceptions\TranslationNotMatchedException
entailment
protected function injectSiteApiValueObjects(Request $request, $language) { /** @var \eZ\Publish\API\Repository\Values\Content\Content $content */ /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ $content = $request->attributes->get('content'); $location = $re...
Injects the Site API value objects into request, replacing the original eZ API value objects. @throws \Netgen\EzPlatformSiteApi\API\Exceptions\TranslationNotMatchedException @param \Symfony\Component\HttpFoundation\Request $request @param string $language
entailment
protected function isLegacyModeSiteAccess($siteAccessName) { if (!$this->configResolver->hasParameter('legacy_mode', 'ezsettings', $siteAccessName)) { return false; } return $this->configResolver->getParameter('legacy_mode', 'ezsettings', $siteAccessName); }
Returns if the provided siteaccess is running in legacy mode. @param string $siteAccessName @return bool
entailment
public static function instance( $args = array() ) { if ( is_null( self::$instance ) ) { self::$instance = new self( $args ); } return self::$instance; }
Get instance @since 0.1.0 @param array $args Arguments {@see Icon_Picker::__construct()}. @return Icon_Picker
entailment
protected function register_default_types() { require_once "{$this->dir}/includes/fontpack.php"; Icon_Picker_Fontpack::instance(); /** * Allow themes/plugins to disable one or more default types * * @since 0.1.0 * @param array $default_types Default icon types. */ $default_types = array_filter( ...
Register default icon types @since 0.1.0 @access protected
entailment
public function load() { if ( true === $this->is_admin_loaded ) { return; } $this->loader->load(); $this->is_admin_loaded = true; }
Load icon picker functionality on an admin page @since 0.1.0 @return void
entailment
protected function configureOptions(OptionsResolver $resolver) { $resolver->setRequired('content'); $resolver->setAllowedTypes('content', SiteContent::class); $resolver->setDefined('exclude_self'); $resolver->setAllowedTypes('exclude_self', ['bool']); $resolver->setDefaults(...
@inheritdoc @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException @throws \Symfony\Component\OptionsResolver\Exception\AccessException
entailment
protected function getFilterCriteria(array $parameters) { /** @var \Netgen\EzPlatformSiteApi\API\Values\Content $content */ $content = $parameters['content']; $tagIds = $this->extractTagIds($content); if (empty($tagIds)) { return new MatchNone(); } $crit...
{@inheritdoc} @throws \LogicException @throws \OutOfBoundsException @throws \InvalidArgumentException @throws \RuntimeException
entailment
private function extractTagIds(SiteContent $content) { $tagsIdsGrouped = [[]]; foreach ($content->fields as $field) { if ($field->fieldTypeIdentifier !== 'eztags') { continue; } /** @var \Netgen\TagsBundle\Core\FieldType\Tags\Value $value */ ...
Extract all Tag IDs from the given $content. @param \Netgen\EzPlatformSiteApi\API\Values\Content $content @return int[]|string[]
entailment
public function resolveTargets($name, array $parameters) { $definitionsGrouped = [[]]; foreach ($parameters as $target => $params) { $definitionsGrouped[] = $this->resolveForTarget($name, $target, $params); } return array_merge(...$definitionsGrouped); }
Resolve Field Criterion $parameters. @param string $name @param array $parameters @throws \InvalidArgumentException @return \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition[]
entailment
private function resolveForTarget($name, $target, $parameters) { if ($this->isOperatorMap($parameters)) { return $this->resolveOperatorMap($name, $target, $parameters); } return [ $this->buildDefinition($name, $target, null, $parameters), ]; }
Return CriterionDefinition instances for the given Field $target and its $parameters. @throws \InvalidArgumentException @param string $name @param string|null $target @param mixed $parameters @return \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition[]
entailment
private function resolveOperatorMap($name, $target, array $map) { $definitions = []; foreach ($map as $operator => $value) { if ('not' === $operator) { $definitions[] = $this->buildDefinition( 'not', null, null,...
Return CriterionDefinition instances for the given Field $target and its operator $map. @param string $name @param string|null $target @param array $map @return \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition[]
entailment
private function buildDefinition($name, $target, $operator, $value) { return new CriterionDefinition([ 'name' => $name, 'target' => $target, 'operator' => $this->resolveOperator($operator, $value), 'value' => $value, ]); }
Return CriterionDefinition instance from the given arguments. @param string $name @param string|null $target @param string|null $operator @param mixed $value @return \Netgen\EzPlatformSiteApi\Core\Site\QueryType\CriterionDefinition
entailment
private function isOperatorMap($parameters) { if (!is_array($parameters)) { return false; } $isOperatorMap = false; $isValueCollection = false; foreach (array_keys($parameters) as $key) { if (array_key_exists($key, self::$operatorMap) || 'not' === $k...
Decide if the given $parameters is an operator-value map (otherwise it's a value collection). @param mixed $parameters @throws \InvalidArgumentException @return bool
entailment
private function resolveOperator($symbol, $value) { if (null === $symbol) { return $this->getOperatorByValueType($value); } return self::$operatorMap[$symbol]; }
Resolve actual operator value from the given arguments. @param string|null $symbol @param mixed $value @return string
entailment
protected function getFilterCriteria(array $parameters) { $fields = (array) $parameters['relation_field']; if (empty($fields)) { return new MatchNone(); } /** @var \Netgen\EzPlatformSiteApi\API\Values\Content $content */ $content = $parameters['content']; ...
{@inheritdoc} @throws \LogicException @throws \OutOfBoundsException @throws \InvalidArgumentException @throws \RuntimeException
entailment
public function process(ContainerBuilder $container) { // 1. Register custom repositories with Aggregate repository $aggregateRepositoryDefinition = $container->findDefinition(static::$aggregateRepositoryId); $customRepositoryTags = $container->findTaggedServiceIds(static::$customRepositoryT...
@inheritdoc @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException @throws \Symfony\Component\DependencyInjection\Exception\OutOfBoundsException @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
entailment
private function validateUser(UserInterface $user) { return $user->isValid($this->username, $this->password, $this->realm); }
Checks for valid user @param User $user @return bool
entailment
private function getDirective() { switch (strtolower($this->type)) { case 'digest': return 'Digest ' . $this->buildDirectiveParameters(array( 'realm' => $this->realm, 'qop' => 'auth', 'nonce' => uniqid(), ...
Return Directive according the auth type @return string
entailment
private function buildDirectiveParameters($parameters = array()) { $result = array(); foreach ($parameters as $key => $value) { $result[] = $key.'="'.$value.'"'; } return implode(',', $result); }
Format given parameters @param array $parameters @return string
entailment
public function isValid($name, $password, $realm) { $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; $u1 = md5(sprintf('%s:%s:%s', $this->username, $realm, $password)); $u2 = md5(sprintf('%s:%s', $request_method, $this->uri)); $response = md5(...
Checks for valid username & password @param string $name @param string $password @return boolean
entailment
public function parse() { $digest = $this->getDigest(); $user = array(); $required = array( 'nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1 ); ...
Parses the User Information from server variables @return void
entailment
public function getDigest() { $digest = null; if (isset($_SERVER['PHP_AUTH_DIGEST'])) { $digest = $_SERVER['PHP_AUTH_DIGEST']; } elseif (isset($_SERVER['HTTP_AUTHORIZATION'])) { if (strpos(strtolower($_SERVER['HTTP_AUTHORIZATION']), 'digest') === 0) { ...
Fetch digest data from environment information @return string
entailment
public function renderField(Field $field, array $params = []) { $params = $this->getRenderFieldBlockParameters($field, $params); return $this->fieldBlockRenderer->renderContentFieldView( $field->innerField, $field->fieldTypeIdentifier, $params ); }
Renders the HTML for a given field. @throws InvalidArgumentException @param \Netgen\EzPlatformSiteApi\API\Values\Field $field @param array $params An array of parameters to pass to the field view @return string The HTML markup
entailment
private function getRenderFieldBlockParameters(Field $field, array $params = []) { // Merging passed parameters to default ones $params += [ 'parameters' => [], // parameters dedicated to template processing 'attr' => [], // attributes to add on the enclosing HTML tags ...
Generates the array of parameter to pass to the field template. @param \Netgen\EzPlatformSiteApi\API\Values\Field $field the Field to display @param array $params An array of parameters to pass to the field view @return array
entailment
protected function makeRequest($http_verb, $api_method, $args = [], $timeout = 10, $url = null) { $this->checkDependencies(); $url = $this->constructRequestUrl($url, $api_method); $ch = $this->createCurlSession($url, $timeout); switch ($http_verb) { case 'post': ...
Make the HTTP request @param string $http_verb HTTP method used: get, post, delete @param string $api_method Drip API method to call @param array $args Array of arguments to the API method @param int $timeout Connection timeout (seconds) @param string $url Optional URL to override the constructed ...
entailment
private function constructRequestUrl($url, $api_method) { if ($url !== null) { return $url; } if ($this->accountID === null) { throw new DripException("This method requires an account ID and none has been set.", 2); } return $this->api_endpoint . '/'...
@param string|null $url @param string $api_method @return string @throws DripException
entailment
private function createCurlSession($url, $timeout = 10) { $ch = curl_init(); if (!$ch) { throw new DripException("Unable to initialise curl", 3); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Accept: applicati...
Create a new CURL session (common setup etc) @param string $url @param int $timeout @return resource @throws DripException
entailment
private function executeRequest(&$ch) { $result = curl_exec($ch); if (!curl_errno($ch)) { $info = curl_getinfo($ch); curl_close($ch); return new Response($info, $result); } $errno = curl_errno($ch); $error = curl_error($ch); curl...
Execute and handle the request result @param resource $ch Curl handle @return Response @throws DripException
entailment
public function getGlobal($api_method, $args = [], $timeout = 10) { $url = $this->api_endpoint . '/' . $api_method; return $this->makeRequest('get', $api_method, $args, $timeout, $url); }
Make a GET request to a top-level method outside of this account @param string $api_method @param array $args @param int $timeout @return Response @throws DripException
entailment
protected function configureOptions(OptionsResolver $resolver) { $resolver->remove(['depth', 'parent_location_id', 'subtree']); $resolver->setRequired('location'); $resolver->setAllowedTypes('location', SiteLocation::class); $resolver->setDefault('sort', function (Options $options) ...
{@inheritdoc} @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException @throws \Symfony\Component\OptionsResolver\Exception\AccessException
entailment
protected function configureOptions(OptionsResolver $resolver) { $resolver->setRequired([ 'content', 'relation_field', ]); $resolver->setAllowedTypes('content', SiteContent::class); $resolver->setAllowedTypes('relation_field', ['string', 'array']); $r...
@inheritdoc @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException @throws \Symfony\Component\OptionsResolver\Exception\AccessException
entailment
private function extractTagIds(SiteContent $content, array $fields) { $tagsIdsGrouped = [[]]; foreach ($fields as $identifier) { if (!$content->hasField($identifier)) { throw new InvalidArgumentException( "Content does not contain field '{$identifier}...
Extract Tag IDs from $fields in the given $content. @param \Netgen\EzPlatformSiteApi\API\Values\Content $content @param string[] $fields @throws \InvalidArgumentException @return array
entailment
public function map(array $configuration, ContentView $view) { if (isset($configuration['named_query'])) { $namedQueryConfiguration = $this->getNamedQueryConfiguration($configuration['named_query']); $configuration = $this->overrideConfiguration($namedQueryConfiguration, $configurati...
Map given $configuration in $view context to a QueryDefinition instance. @param array $configuration @param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view @throws \InvalidArgumentException @return \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition
entailment
private function overrideConfiguration(array $configuration, array $override) { $configuration['parameters'] = array_replace( $configuration['parameters'], $override['parameters'] ); unset($override['parameters']); return array_replace($configuration, $overr...
Override $configuration parameters with $override. Only first level keys in main configuration and separately under 'parameters' key are replaced. @param array $configuration @param array $override @return array
entailment
private function getNamedQueryConfiguration($name) { if (array_key_exists($name, $this->namedQueryConfiguration)) { return $this->namedQueryConfiguration[$name]; } throw new InvalidArgumentException( "Could not find query configuration named '{$name}'" ); ...
Return named query configuration by the given $name. @param string $name @throws \InvalidArgumentException If no such configuration exist. @return array
entailment
private function buildQueryDefinition(array $configuration, ContentView $view) { $parameters = $this->processParameters($configuration['parameters'], $view); $this->injectSupportedParameters($parameters, $configuration['query_type'], $view); return new QueryDefinition([ 'name' ...
Build QueryDefinition instance from the given arguments. @param array $configuration @param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view @return \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\QueryDefinition
entailment
private function injectSupportedParameters(array &$parameters, $queryTypeName, ContentView $view) { $queryType = $this->queryTypeRegistry->getQueryType($queryTypeName); if (!$queryType instanceof SiteQueryType) { return; } if (!array_key_exists('content', $parameters) &...
Inject parameters into $parameters if available in the $view and supported by the QueryType. @param array $parameters @param string $queryTypeName @param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view
entailment
private function processParameters($parameters, ContentView $view) { if (!is_array($parameters)) { return $this->parameterProcessor->process($parameters, $view); } $processedParameters = []; foreach ($parameters as $name => $subParameters) { $processedParame...
Recursively process given $parameters using ParameterProcessor. @see \Netgen\Bundle\EzPlatformSiteApiBundle\QueryType\ParameterProcessor @param mixed $parameters @param \Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView $view @return array|string
entailment
public function getRelationIds(Field $field) { if (!$this->accept($field)) { $identifier = $this->getSupportedFieldTypeIdentifier(); throw new LogicException( "This resolver can only handle fields of '{$identifier}' type" ); } return $thi...
Return related Content IDs for the given $field. @throws \LogicException If the field can't be handled by the resolver @param \Netgen\EzPlatformSiteApi\API\Values\Field $field @return int[]|string[]
entailment
private function getRelatedContentItems(array $relatedContentIds, array $contentTypeIdentifiers) { if (count($relatedContentIds) === 0) { return []; } $criteria = new ContentId($relatedContentIds); if (!empty($contentTypeIdentifiers)) { $criteria = new Logic...
Return an array of related Content from the given arguments. @throws \InvalidArgumentException As thrown by the Search API @param array $relatedContentIds @param array $contentTypeIdentifiers @return \eZ\Publish\API\Repository\Values\Content\Content[]
entailment
private function sortByIdOrder(array &$relatedContentItems, array $relatedContentIds) { $sortedIdList = array_flip($relatedContentIds); $sorter = function (Content $content1, Content $content2) use ($sortedIdList) { if ($content1->id === $content2->id) { return 0; ...
Sorts $relatedContentItems to match order from $relatedContentIds. @param array $relatedContentItems @param array $relatedContentIds
entailment
public function add( Icon_Picker_Type $type ) { if ( $this->is_valid_type( $type ) ) { $this->types[ $type->id ] = $type; } }
Register icon type @since 0.1.0 @param Icon_Picker_Type $type Icon type. @return void
entailment
public function get( $id ) { if ( isset( $this->types[ $id ] ) ) { return $this->types[ $id ]; } return null; }
Get icon type @since 0.1.0 @param string $id Icon type ID. @return mixed Icon type or NULL if it's not registered.
entailment
protected function is_valid_type( Icon_Picker_Type $type ) { foreach ( array( 'id', 'controller' ) as $var ) { $value = $type->$var; if ( empty( $value ) ) { trigger_error( esc_html( sprintf( 'Icon Picker: "%s" cannot be empty.', $var ) ) ); return false; } } if ( isset( $this->types[ $type->id...
Check if icon type is valid @since 0.1.0 @param Icon_Picker_Type $type Icon type. @return bool
entailment
public function get_types_for_js() { $types = array(); $names = array(); foreach ( $this->types as $type ) { $types[ $type->id ] = $type->get_props(); $names[ $type->id ] = $type->name; } array_multisort( $names, SORT_ASC, $types ); return $types; }
Get all icon types for JS @since 0.1.0 @return array
entailment
public function register() { // merge default config $this->mergeConfigFrom( __DIR__.'/../../config/config.php', 'httpauth' ); $this->app->singleton('httpauth', function ($app) { return new Httpauth($app['config']->get('httpauth')); }); ...
Register the service provider. @return void
entailment
public function get_props() { $props = array( 'id' => $this->id, 'name' => $this->name, 'controller' => $this->controller, 'templateId' => $this->template_id, 'data' => $this->get_props_data(), ); /** * Filter icon type properties * * @since 0.1.0 * @param array ...
Get properties @since 0.1.0 @return array
entailment
public function register() { $this->app['httpauth'] = $this->app->share(function ($app) { return new Httpauth($app['config']->get('httpauth::config')); }); }
Register the service provider. @return void
entailment
public function load(array $configs, ContainerBuilder $container) { $activatedBundles = array_keys($container->getParameter('kernel.bundles')); $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $coreFile...
{@inheritdoc} @throws \Exception
entailment
public function getSlice($offset, $length) { $query = clone $this->query; $query->offset = $offset; $query->limit = $length; $query->performCount = false; $searchResult = $this->filterService->filterContent($query); // Set count for further use if returned by search...
Returns a slice of the results, as Site Content objects. @param int $offset The offset @param int $length The length @return \Netgen\EzPlatformSiteApi\API\Values\Location[]
entailment
protected function get_image_mime_types() { $mime_types = get_allowed_mime_types(); foreach ( $mime_types as $id => $type ) { if ( false === strpos( $type, 'image/' ) ) { unset( $mime_types[ $id ] ); } } /** * Filter image mime types * * @since 0.1.0 * @param array $mime_types Image mime...
Get image mime types @since 0.1.0 @return array
entailment