repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
BabDev/Transifex-API
src/Transifex.php
Transifex.get
public function get(string $name): ApiConnector { return $this->apiFactory->createApiConnector($name, $this->options); }
php
public function get(string $name): ApiConnector { return $this->apiFactory->createApiConnector($name, $this->options); }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "ApiConnector", "{", "return", "$", "this", "->", "apiFactory", "->", "createApiConnector", "(", "$", "name", ",", "$", "this", "->", "options", ")", ";", "}" ]
Factory method to fetch API objects. @param string $name Name of the API object to retrieve @return ApiConnector @throws Exception\UnknownApiConnectorException
[ "Factory", "method", "to", "fetch", "API", "objects", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Transifex.php#L48-L51
train
hiqdev/hipanel-module-finance
src/models/DomainService.php
DomainService.tryResourceAssignation
public function tryResourceAssignation(DomainResource $resource) { if ($type = $this->matchType($resource)) { $this->resources[$type] = $resource; return true; } return false; }
php
public function tryResourceAssignation(DomainResource $resource) { if ($type = $this->matchType($resource)) { $this->resources[$type] = $resource; return true; } return false; }
[ "public", "function", "tryResourceAssignation", "(", "DomainResource", "$", "resource", ")", "{", "if", "(", "$", "type", "=", "$", "this", "->", "matchType", "(", "$", "resource", ")", ")", "{", "$", "this", "->", "resources", "[", "$", "type", "]", "...
Tries to assign a resource in this service, if the type is correct. @param DomainResource $resource @return bool
[ "Tries", "to", "assign", "a", "resource", "in", "this", "service", "if", "the", "type", "is", "correct", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/models/DomainService.php#L51-L60
train
mmoreram/ControllerExtraBundle
DependencyInjection/ControllerExtraExtension.php
ControllerExtraExtension.getConfigFiles
protected function getConfigFiles(array $config) : array { return [ 'providers', 'annotations_resolver', ['resolver_form', $config['form']['active']], ['resolver_flush', $config['flush']['active']], ['resolver_entity', $config['entity']['active']], ['resolver_log', $config['log']['active']], ['resolver_json_response', $config['json_response']['active']], ['resolver_paginator', $config['paginator']['active']], ['resolver_get', $config['get']['active']], ['resolver_post', $config['post']['active']], ]; }
php
protected function getConfigFiles(array $config) : array { return [ 'providers', 'annotations_resolver', ['resolver_form', $config['form']['active']], ['resolver_flush', $config['flush']['active']], ['resolver_entity', $config['entity']['active']], ['resolver_log', $config['log']['active']], ['resolver_json_response', $config['json_response']['active']], ['resolver_paginator', $config['paginator']['active']], ['resolver_get', $config['get']['active']], ['resolver_post', $config['post']['active']], ]; }
[ "protected", "function", "getConfigFiles", "(", "array", "$", "config", ")", ":", "array", "{", "return", "[", "'providers'", ",", "'annotations_resolver'", ",", "[", "'resolver_form'", ",", "$", "config", "[", "'form'", "]", "[", "'active'", "]", "]", ",", ...
Config files to load. Each array position can be a simple file name if must be loaded always, or an array, with the filename in the first position, and a boolean in the second one. As a parameter, this method receives all loaded configuration, to allow setting this boolean value from a configuration value. return array( 'file1.yml', 'file2.yml', ['file3.yml', $config['my_boolean'], ... ); @param array $config Config definitions @return array Config files
[ "Config", "files", "to", "load", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/DependencyInjection/ControllerExtraExtension.php#L72-L86
train
MetaModels/filter_perimetersearch
src/Helper/SphericalDistance.php
SphericalDistance.validateCoordinate
public static function validateCoordinate($coordinate): bool { if (!(is_numeric($coordinate) && (3 >= \strlen((int) \abs($coordinate))) && (6 >= (\strlen($coordinate) - \strlen((int) $coordinate) - 1))) ) { return false; } return true; }
php
public static function validateCoordinate($coordinate): bool { if (!(is_numeric($coordinate) && (3 >= \strlen((int) \abs($coordinate))) && (6 >= (\strlen($coordinate) - \strlen((int) $coordinate) - 1))) ) { return false; } return true; }
[ "public", "static", "function", "validateCoordinate", "(", "$", "coordinate", ")", ":", "bool", "{", "if", "(", "!", "(", "is_numeric", "(", "$", "coordinate", ")", "&&", "(", "3", ">=", "\\", "strlen", "(", "(", "int", ")", "\\", "abs", "(", "$", ...
Validate the coordinate. @param string|float $coordinate The latitude or longitude coordinate. @return bool
[ "Validate", "the", "coordinate", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/SphericalDistance.php#L154-L164
train
TYPO3-CMS/redirects
Classes/Service/UrlService.php
UrlService.getDefaultUrl
public function getDefaultUrl(): string { $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); $firstPageInTree = $connection->select(['uid'], 'pages', ['pid' => 0], [], ['sorting' => 'ASC'], 1)->fetchColumn(0); $url = BackendUtility::getViewDomain($firstPageInTree); return $url; }
php
public function getDefaultUrl(): string { $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); $firstPageInTree = $connection->select(['uid'], 'pages', ['pid' => 0], [], ['sorting' => 'ASC'], 1)->fetchColumn(0); $url = BackendUtility::getViewDomain($firstPageInTree); return $url; }
[ "public", "function", "getDefaultUrl", "(", ")", ":", "string", "{", "$", "connection", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getConnectionForTable", "(", "'pages'", ")", ";", "$", "firstPageInTree", "=", ...
Retrieves the first valid URL @return string a URL like "http://example.org"
[ "Retrieves", "the", "first", "valid", "URL" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Service/UrlService.php#L34-L41
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Common/Decorator/Base.php
Base.setView
public function setView( \Aimeos\MW\View\Iface $view ) { $this->client->setView( $view ); parent::setView( $view ); return $this; }
php
public function setView( \Aimeos\MW\View\Iface $view ) { $this->client->setView( $view ); parent::setView( $view ); return $this; }
[ "public", "function", "setView", "(", "\\", "Aimeos", "\\", "MW", "\\", "View", "\\", "Iface", "$", "view", ")", "{", "$", "this", "->", "client", "->", "setView", "(", "$", "view", ")", ";", "parent", "::", "setView", "(", "$", "view", ")", ";", ...
Sets the view object that will generate the admin output. @param \Aimeos\MW\View\Iface $view The view object which generates the admin output @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
[ "Sets", "the", "view", "object", "that", "will", "generate", "the", "admin", "output", "." ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Common/Decorator/Base.php#L159-L165
train
QoboLtd/cakephp-search
src/Utility.php
Utility.instance
public static function instance(Utility $utility = null) { if ($utility instanceof Utility) { static::$instance = $utility; } if (empty(static::$instance)) { static::$instance = new static(); } return static::$instance; }
php
public static function instance(Utility $utility = null) { if ($utility instanceof Utility) { static::$instance = $utility; } if (empty(static::$instance)) { static::$instance = new static(); } return static::$instance; }
[ "public", "static", "function", "instance", "(", "Utility", "$", "utility", "=", "null", ")", "{", "if", "(", "$", "utility", "instanceof", "Utility", ")", "{", "static", "::", "$", "instance", "=", "$", "utility", ";", "}", "if", "(", "empty", "(", ...
Returns the globally available instance of a Search\Utility. @param \Search\Utility|null $utility Utility instance @return static The global search utility
[ "Returns", "the", "globally", "available", "instance", "of", "a", "Search", "\\", "Utility", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L62-L73
train
QoboLtd/cakephp-search
src/Utility.php
Utility.getSearchableFields
public function getSearchableFields(RepositoryInterface $table, array $user) : array { $alias = $table->getAlias(); if (!empty($this->searchableFields[$alias])) { return $this->searchableFields[$alias]; } $event = new Event((string)EventName::MODEL_SEARCH_SEARCHABLE_FIELDS(), $this, [ 'table' => $table, 'user' => $user ]); EventManager::instance()->dispatch($event); $this->searchableFields[$alias] = $event->result ? $event->result : []; return $this->searchableFields[$alias]; }
php
public function getSearchableFields(RepositoryInterface $table, array $user) : array { $alias = $table->getAlias(); if (!empty($this->searchableFields[$alias])) { return $this->searchableFields[$alias]; } $event = new Event((string)EventName::MODEL_SEARCH_SEARCHABLE_FIELDS(), $this, [ 'table' => $table, 'user' => $user ]); EventManager::instance()->dispatch($event); $this->searchableFields[$alias] = $event->result ? $event->result : []; return $this->searchableFields[$alias]; }
[ "public", "function", "getSearchableFields", "(", "RepositoryInterface", "$", "table", ",", "array", "$", "user", ")", ":", "array", "{", "$", "alias", "=", "$", "table", "->", "getAlias", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->",...
Return Table's searchable fields. @param \Cake\Datasource\RepositoryInterface $table Table object @param mixed[] $user User info @return mixed[]
[ "Return", "Table", "s", "searchable", "fields", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L82-L99
train
QoboLtd/cakephp-search
src/Utility.php
Utility.formatter
public function formatter(ResultSetInterface $resultSet, array $fields, RepositoryInterface $table, array $user) : array { $result = []; if ($resultSet->isEmpty()) { return $result; } $cakeView = new View(); $registryAlias = $table->getRegistryAlias(); $alias = $table->getAlias(); foreach ($resultSet as $key => $entity) { foreach ($fields as $field) { list($tableName, $fieldName) = explode('.', $field); // current table field if ($alias === $tableName) { $result[$key][$field] = $entity->get($fieldName); continue; } if (!$entity->get('_matchingData')) { continue; } if (!isset($entity->_matchingData[$tableName])) { continue; } // associated table field $result[$key][$field] = $entity->_matchingData[$tableName]->get($fieldName); } $result[$key][static::MENU_PROPERTY_NAME] = $cakeView->element('Search.Menu/search-view-actions', [ 'entity' => $entity, 'model' => $registryAlias, 'user' => $user ]); } return $result; }
php
public function formatter(ResultSetInterface $resultSet, array $fields, RepositoryInterface $table, array $user) : array { $result = []; if ($resultSet->isEmpty()) { return $result; } $cakeView = new View(); $registryAlias = $table->getRegistryAlias(); $alias = $table->getAlias(); foreach ($resultSet as $key => $entity) { foreach ($fields as $field) { list($tableName, $fieldName) = explode('.', $field); // current table field if ($alias === $tableName) { $result[$key][$field] = $entity->get($fieldName); continue; } if (!$entity->get('_matchingData')) { continue; } if (!isset($entity->_matchingData[$tableName])) { continue; } // associated table field $result[$key][$field] = $entity->_matchingData[$tableName]->get($fieldName); } $result[$key][static::MENU_PROPERTY_NAME] = $cakeView->element('Search.Menu/search-view-actions', [ 'entity' => $entity, 'model' => $registryAlias, 'user' => $user ]); } return $result; }
[ "public", "function", "formatter", "(", "ResultSetInterface", "$", "resultSet", ",", "array", "$", "fields", ",", "RepositoryInterface", "$", "table", ",", "array", "$", "user", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "if", "(", "$", ...
Method that formats resultset. @param \Cake\Datasource\ResultSetInterface $resultSet ResultSet @param string[] $fields Display fields @param \Cake\Datasource\RepositoryInterface $table Table instance @param mixed[] $user User info @return mixed[]
[ "Method", "that", "formats", "resultset", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L110-L150
train
QoboLtd/cakephp-search
src/Utility.php
Utility.getAssociationLabels
public function getAssociationLabels(RepositoryInterface $table) : array { /** @var \Cake\ORM\Table */ $table = $table; $result = []; foreach ($table->associations() as $association) { if (!in_array($association->type(), $this->searchableAssociations)) { continue; } $result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey())); } return $result; }
php
public function getAssociationLabels(RepositoryInterface $table) : array { /** @var \Cake\ORM\Table */ $table = $table; $result = []; foreach ($table->associations() as $association) { if (!in_array($association->type(), $this->searchableAssociations)) { continue; } $result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey())); } return $result; }
[ "public", "function", "getAssociationLabels", "(", "RepositoryInterface", "$", "table", ")", ":", "array", "{", "/** @var \\Cake\\ORM\\Table */", "$", "table", "=", "$", "table", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "table", "->", "as...
Associations labels getter. @param \Cake\Datasource\RepositoryInterface $table Table instance @return mixed[]
[ "Associations", "labels", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility.php#L199-L214
train
mmoreram/ControllerExtraBundle
Resolver/AnnotationResolverCollector.php
AnnotationResolverCollector.analyzeRequest
public function analyzeRequest( Request $request, Reader $reader, ReflectionMethod $method ) { /** * Annotations load. */ $methodAnnotations = $reader->getMethodAnnotations($method); /** * Every annotation found is parsed. */ foreach ($methodAnnotations as $annotation) { if ($annotation instanceof Annotation) { $this->analyzeAnnotation( $request, $method, $annotation, $this->resolverStack ); } } }
php
public function analyzeRequest( Request $request, Reader $reader, ReflectionMethod $method ) { /** * Annotations load. */ $methodAnnotations = $reader->getMethodAnnotations($method); /** * Every annotation found is parsed. */ foreach ($methodAnnotations as $annotation) { if ($annotation instanceof Annotation) { $this->analyzeAnnotation( $request, $method, $annotation, $this->resolverStack ); } } }
[ "public", "function", "analyzeRequest", "(", "Request", "$", "request", ",", "Reader", "$", "reader", ",", "ReflectionMethod", "$", "method", ")", "{", "/**\n * Annotations load.\n */", "$", "methodAnnotations", "=", "$", "reader", "->", "getMethodAnno...
Evaluate request. @param Request $request @param Reader $reader @param ReflectionMethod $method
[ "Evaluate", "request", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/AnnotationResolverCollector.php#L121-L144
train
mmoreram/ControllerExtraBundle
Resolver/AnnotationResolverCollector.php
AnnotationResolverCollector.analyzeAnnotation
public function analyzeAnnotation( Request $request, ReflectionMethod $method, Annotation $annotation, array $resolverStack ) { /** * Every resolver must evaluate its logic. */ foreach ($resolverStack as $resolver) { $resolver->evaluateAnnotation($request, $annotation, $method); } }
php
public function analyzeAnnotation( Request $request, ReflectionMethod $method, Annotation $annotation, array $resolverStack ) { /** * Every resolver must evaluate its logic. */ foreach ($resolverStack as $resolver) { $resolver->evaluateAnnotation($request, $annotation, $method); } }
[ "public", "function", "analyzeAnnotation", "(", "Request", "$", "request", ",", "ReflectionMethod", "$", "method", ",", "Annotation", "$", "annotation", ",", "array", "$", "resolverStack", ")", "{", "/**\n * Every resolver must evaluate its logic.\n */", "...
Allow every available resolver to solve its own logic. @param Request $request @param ReflectionMethod $method @param Annotation $annotation @param array $resolverStack
[ "Allow", "every", "available", "resolver", "to", "solve", "its", "own", "logic", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/AnnotationResolverCollector.php#L154-L167
train
MetaModels/filter_perimetersearch
src/Helper/HaversineSphericalDistance.php
HaversineSphericalDistance.getFormulaAsQueryPart
public static function getFormulaAsQueryPart( $firstLatitude, $firstLongitude, $secondLatitude, $secondLongitude, $digits = 0, $earthRadius = self::EARTH_RADIUS_IN_KM ): string { return \sprintf( 'ROUND( SQRT( POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2) ), %5$s )', $firstLatitude, $firstLongitude, $secondLatitude, $secondLongitude, $digits, $earthRadius ); }
php
public static function getFormulaAsQueryPart( $firstLatitude, $firstLongitude, $secondLatitude, $secondLongitude, $digits = 0, $earthRadius = self::EARTH_RADIUS_IN_KM ): string { return \sprintf( 'ROUND( SQRT( POWER(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) - CAST(%3$s AS DECIMAL(9,6))) * %6$s, 2) + POWER(2 * PI() / 360 * (CAST(%2$s AS DECIMAL(9,6)) - CAST(%4$s AS DECIMAL(9,6))) * %6$s * COS(2 * PI() / 360 * (CAST(%1$s AS DECIMAL(9,6)) + CAST(%3$s AS DECIMAL(9,6))) * 0.5), 2) ), %5$s )', $firstLatitude, $firstLongitude, $secondLatitude, $secondLongitude, $digits, $earthRadius ); }
[ "public", "static", "function", "getFormulaAsQueryPart", "(", "$", "firstLatitude", ",", "$", "firstLongitude", ",", "$", "secondLatitude", ",", "$", "secondLongitude", ",", "$", "digits", "=", "0", ",", "$", "earthRadius", "=", "self", "::", "EARTH_RADIUS_IN_KM...
Get the spherical distance haversine formula for the database query part. @param string|float $firstLatitude The first latitude coordinate. You can a coordinate or a database field. @param string|float $firstLongitude The first longitude coordinate. You can a coordinate or a database field. @param string|float $secondLatitude The second latitude coordinate. You can a coordinate or a database field. @param string|float $secondLongitude The second longitude coordinate. You can a coordinate or a database field. @param int $digits The number of digits after the decimal point. @param int $earthRadius The earth radius. @return string
[ "Get", "the", "spherical", "distance", "haversine", "formula", "for", "the", "database", "query", "part", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/HaversineSphericalDistance.php#L42-L65
train
MetaModels/filter_perimetersearch
src/Helper/HaversineSphericalDistance.php
HaversineSphericalDistance.calculate
public static function calculate( float $firstLatitude, float $firstLongitude, float $secondLatitude, float $secondLongitude, int $digits = 0, int $earthRadius = self::EARTH_RADIUS_IN_KM ): float { $oneRad = ((2 * M_PI) / 360); return \round( \sqrt( (($oneRad * ($firstLatitude - $secondLatitude) * $earthRadius) ** 2) + (($oneRad * ($firstLongitude - $secondLongitude) * $earthRadius * \cos($oneRad * ($firstLatitude + $secondLatitude) * .5)) ** 2) ), $digits ); }
php
public static function calculate( float $firstLatitude, float $firstLongitude, float $secondLatitude, float $secondLongitude, int $digits = 0, int $earthRadius = self::EARTH_RADIUS_IN_KM ): float { $oneRad = ((2 * M_PI) / 360); return \round( \sqrt( (($oneRad * ($firstLatitude - $secondLatitude) * $earthRadius) ** 2) + (($oneRad * ($firstLongitude - $secondLongitude) * $earthRadius * \cos($oneRad * ($firstLatitude + $secondLatitude) * .5)) ** 2) ), $digits ); }
[ "public", "static", "function", "calculate", "(", "float", "$", "firstLatitude", ",", "float", "$", "firstLongitude", ",", "float", "$", "secondLatitude", ",", "float", "$", "secondLongitude", ",", "int", "$", "digits", "=", "0", ",", "int", "$", "earthRadiu...
Calculate the spherical distance with the haversine formula. @param float $firstLatitude The first latitude coordinate. @param float $firstLongitude The first longitude coordinate. @param float $secondLatitude The second latitude coordinate. @param float $secondLongitude The second longitude coordinate. @param int $digits The number of digits after the decimal point. @param int $earthRadius The earth radius. @return float
[ "Calculate", "the", "spherical", "distance", "with", "the", "haversine", "formula", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/Helper/HaversineSphericalDistance.php#L79-L97
train
QoboLtd/cakephp-search
src/Model/Table/AppWidgetsTable.php
AppWidgetsTable._saveAppWidgets
protected function _saveAppWidgets(): void { $widgets = $this->_getAppWidgets(); $found = []; foreach ($widgets as $widget) { $found[] = $widget['name']; // skip adding existing app widgets if ($this->exists(['AppWidgets.name' => $widget['name']])) { continue; } $entity = $this->newEntity(); $entity = $this->patchEntity($entity, $widget); $this->save($entity); } // soft delete non-existing app widgets $this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []); }
php
protected function _saveAppWidgets(): void { $widgets = $this->_getAppWidgets(); $found = []; foreach ($widgets as $widget) { $found[] = $widget['name']; // skip adding existing app widgets if ($this->exists(['AppWidgets.name' => $widget['name']])) { continue; } $entity = $this->newEntity(); $entity = $this->patchEntity($entity, $widget); $this->save($entity); } // soft delete non-existing app widgets $this->trashAll(! empty($found) ? ['AppWidgets.name NOT IN' => $found] : []); }
[ "protected", "function", "_saveAppWidgets", "(", ")", ":", "void", "{", "$", "widgets", "=", "$", "this", "->", "_getAppWidgets", "(", ")", ";", "$", "found", "=", "[", "]", ";", "foreach", "(", "$", "widgets", "as", "$", "widget", ")", "{", "$", "...
Store application scope widgets into the database. @return void
[ "Store", "application", "scope", "widgets", "into", "the", "database", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/AppWidgetsTable.php#L127-L147
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.getCountryInformation
protected function getCountryInformation() { // Get the country for the lookup. $country = null; if (('get' === $this->get('countrymode')) && $this->get('country_get')) { $getValue = Input::get($this->get('country_get')) ?: Input::post($this->get('country_get')); $getValue = \trim($getValue); if (!empty($getValue)) { $country = $getValue; } } elseif ('preset' === $this->get('countrymode')) { $country = $this->get('country_preset'); } return $country; }
php
protected function getCountryInformation() { // Get the country for the lookup. $country = null; if (('get' === $this->get('countrymode')) && $this->get('country_get')) { $getValue = Input::get($this->get('country_get')) ?: Input::post($this->get('country_get')); $getValue = \trim($getValue); if (!empty($getValue)) { $country = $getValue; } } elseif ('preset' === $this->get('countrymode')) { $country = $this->get('country_preset'); } return $country; }
[ "protected", "function", "getCountryInformation", "(", ")", "{", "// Get the country for the lookup.", "$", "country", "=", "null", ";", "if", "(", "(", "'get'", "===", "$", "this", "->", "get", "(", "'countrymode'", ")", ")", "&&", "$", "this", "->", "get",...
Try to get a valid country information. @return string|null The country short tag (2-letters) or null.
[ "Try", "to", "get", "a", "valid", "country", "information", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L200-L216
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.getSearchWidget
private function getSearchWidget(FrontendFilterOptions $frontendFilterOptions) { $widget = [ 'label' => [ ($this->get('label') ?: $this->getAttributeName()), 'GET: ' . $this->getParamName(), ], 'inputType' => 'text', 'count' => [], 'showCount' => $frontendFilterOptions->isShowCountValues(), 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamName(), 'template' => $this->get('template'), 'placeholder' => $this->get('placeholder') ] ]; return $widget; }
php
private function getSearchWidget(FrontendFilterOptions $frontendFilterOptions) { $widget = [ 'label' => [ ($this->get('label') ?: $this->getAttributeName()), 'GET: ' . $this->getParamName(), ], 'inputType' => 'text', 'count' => [], 'showCount' => $frontendFilterOptions->isShowCountValues(), 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamName(), 'template' => $this->get('template'), 'placeholder' => $this->get('placeholder') ] ]; return $widget; }
[ "private", "function", "getSearchWidget", "(", "FrontendFilterOptions", "$", "frontendFilterOptions", ")", "{", "$", "widget", "=", "[", "'label'", "=>", "[", "(", "$", "this", "->", "get", "(", "'label'", ")", "?", ":", "$", "this", "->", "getAttributeName"...
Get the widget information for the search field. @param FrontendFilterOptions $frontendFilterOptions The FE options. @return array
[ "Get", "the", "widget", "information", "for", "the", "search", "field", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L302-L321
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.getRangeWidget
private function getRangeWidget() { if ('selection' === $this->get('rangemode')) { // Get all range options. $rangeOptions = []; foreach (StringUtil::deserialize($this->get('range_selection'), true) as $rangeItem) { $rangeOptions[$rangeItem['range']] = $rangeItem['range'] . 'km'; } $rangeWidget = [ 'label' => [ ($this->get('range_label') ?: $this->getAttributeName() . ' Range '), 'GET: ' . $this->getParamNameRange() ], 'inputType' => 'select', 'options' => $rangeOptions, 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamNameRange(), 'template' => $this->get('range_template') ] ]; return $rangeWidget; } if ('free' === $this->get('rangemode')) { $rangeWidget = [ 'label' => [ ($this->get('range_label') ?: $this->getAttributeName() . ' Range '), 'GET: ' . $this->getParamNameRange() ], 'inputType' => 'text', 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamNameRange(), 'template' => $this->get('range_template'), 'placeholder' => $this->get('range_placeholder') ] ]; return $rangeWidget; } return null; }
php
private function getRangeWidget() { if ('selection' === $this->get('rangemode')) { // Get all range options. $rangeOptions = []; foreach (StringUtil::deserialize($this->get('range_selection'), true) as $rangeItem) { $rangeOptions[$rangeItem['range']] = $rangeItem['range'] . 'km'; } $rangeWidget = [ 'label' => [ ($this->get('range_label') ?: $this->getAttributeName() . ' Range '), 'GET: ' . $this->getParamNameRange() ], 'inputType' => 'select', 'options' => $rangeOptions, 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamNameRange(), 'template' => $this->get('range_template') ] ]; return $rangeWidget; } if ('free' === $this->get('rangemode')) { $rangeWidget = [ 'label' => [ ($this->get('range_label') ?: $this->getAttributeName() . ' Range '), 'GET: ' . $this->getParamNameRange() ], 'inputType' => 'text', 'eval' => [ 'colname' => $this->getColname(), 'urlparam' => $this->getParamNameRange(), 'template' => $this->get('range_template'), 'placeholder' => $this->get('range_placeholder') ] ]; return $rangeWidget; } return null; }
[ "private", "function", "getRangeWidget", "(", ")", "{", "if", "(", "'selection'", "===", "$", "this", "->", "get", "(", "'rangemode'", ")", ")", "{", "// Get all range options.", "$", "rangeOptions", "=", "[", "]", ";", "foreach", "(", "StringUtil", "::", ...
Get the widget for the distance. @return array|null
[ "Get", "the", "widget", "for", "the", "distance", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L329-L375
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.lookupGeo
protected function lookupGeo($address, $country) { // Trim the data. Better! $address = \trim($address); $country = \trim($country); // First check cache. $cacheResult = $this->getFromCache($address, $country); if (null !== $cacheResult) { return $cacheResult; } // If there is no data from the cache ask google. $lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true); if (!\count($lookupServices)) { return null; } foreach ($lookupServices as $lookupService) { try { $callback = $this->getObjectFromName($lookupService['lookupservice']); // Call the main function. if (null !== $callback) { /** @var Container $result */ $result = $callback ->getCoordinates( null, null, null, $country, $address, $lookupService['apiToken'] ?: null ); // Check if we have a result. if (!$result->hasError()) { $this->addToCache($address, $country, $result); return $result; } } } catch (\RuntimeException $exc) { // Okay, we have an error try next one. continue; } } // When we reach this point, we have no result, so return false. return null; }
php
protected function lookupGeo($address, $country) { // Trim the data. Better! $address = \trim($address); $country = \trim($country); // First check cache. $cacheResult = $this->getFromCache($address, $country); if (null !== $cacheResult) { return $cacheResult; } // If there is no data from the cache ask google. $lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true); if (!\count($lookupServices)) { return null; } foreach ($lookupServices as $lookupService) { try { $callback = $this->getObjectFromName($lookupService['lookupservice']); // Call the main function. if (null !== $callback) { /** @var Container $result */ $result = $callback ->getCoordinates( null, null, null, $country, $address, $lookupService['apiToken'] ?: null ); // Check if we have a result. if (!$result->hasError()) { $this->addToCache($address, $country, $result); return $result; } } } catch (\RuntimeException $exc) { // Okay, we have an error try next one. continue; } } // When we reach this point, we have no result, so return false. return null; }
[ "protected", "function", "lookupGeo", "(", "$", "address", ",", "$", "country", ")", "{", "// Trim the data. Better!", "$", "address", "=", "\\", "trim", "(", "$", "address", ")", ";", "$", "country", "=", "\\", "trim", "(", "$", "country", ")", ";", "...
User the provider classes to make a look up. @param string $address The full address to search for. @param string $country The country as 2-letters form. @return Container|null Return the container with all information or null on error.
[ "User", "the", "provider", "classes", "to", "make", "a", "look", "up", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L505-L555
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.getObjectFromName
protected function getObjectFromName($lookupClassName) { // Check if we know this class. if (!isset($GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName])) { return null; } $reflectionName = $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName]; $reflection = new \ReflectionClass($reflectionName); // Fetch singleton instance. if ($reflection->hasMethod('getInstance')) { $getInstanceMethod = $reflection->getMethod('getInstance'); // Create a new instance. if ($getInstanceMethod->isStatic()) { return $getInstanceMethod->invoke(null); } return $reflection->newInstance(); } // Create a normal object. return $reflection->newInstance(); }
php
protected function getObjectFromName($lookupClassName) { // Check if we know this class. if (!isset($GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName])) { return null; } $reflectionName = $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'][$lookupClassName]; $reflection = new \ReflectionClass($reflectionName); // Fetch singleton instance. if ($reflection->hasMethod('getInstance')) { $getInstanceMethod = $reflection->getMethod('getInstance'); // Create a new instance. if ($getInstanceMethod->isStatic()) { return $getInstanceMethod->invoke(null); } return $reflection->newInstance(); } // Create a normal object. return $reflection->newInstance(); }
[ "protected", "function", "getObjectFromName", "(", "$", "lookupClassName", ")", "{", "// Check if we know this class.", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'METAMODELS'", "]", "[", "'filters'", "]", "[", "'perimetersearch'", "]", "[", "'resolve_cla...
Try to get a object from the given class. @param string $lookupClassName The name of the class. @return null|object @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Try", "to", "get", "a", "object", "from", "the", "given", "class", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L567-L592
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.addToCache
protected function addToCache($address, $country, $result) { $this->connection->insert( 'tl_metamodel_perimetersearch', [ $this->connection->quoteIdentifier('search') => $address, $this->connection->quoteIdentifier('country') => $country, $this->connection->quoteIdentifier('geo_lat') => $result->getLatitude(), $this->connection->quoteIdentifier('geo_long') => $result->getLongitude() ] ); }
php
protected function addToCache($address, $country, $result) { $this->connection->insert( 'tl_metamodel_perimetersearch', [ $this->connection->quoteIdentifier('search') => $address, $this->connection->quoteIdentifier('country') => $country, $this->connection->quoteIdentifier('geo_lat') => $result->getLatitude(), $this->connection->quoteIdentifier('geo_long') => $result->getLongitude() ] ); }
[ "protected", "function", "addToCache", "(", "$", "address", ",", "$", "country", ",", "$", "result", ")", "{", "$", "this", "->", "connection", "->", "insert", "(", "'tl_metamodel_perimetersearch'", ",", "[", "$", "this", "->", "connection", "->", "quoteIden...
Add data to the cache. @param string $address The address which where use for the search. @param string $country The country. @param Container $result The container with all information. @return void @throws \Doctrine\DBAL\DBALException When insert fails.
[ "Add", "data", "to", "the", "cache", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L605-L616
train
MetaModels/filter_perimetersearch
src/FilterSetting/Perimetersearch.php
Perimetersearch.getFromCache
protected function getFromCache($address, $country) { $builder = $this->connection->createQueryBuilder(); $builder ->select('*') ->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch')) ->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search')) ->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country')) ->setParameter('search', $address) ->setParameter('country', $country); $statement = $builder->execute(); // If we have no data just return null. if (!$statement->rowCount()) { return null; } $result = $statement->fetch(\PDO::FETCH_OBJ); // Build a new container. $container = new Container(); $container->setLatitude($result->geo_lat); $container->setLongitude($result->geo_long); $container->setSearchParam( \strtr( $builder->getSQL(), [ ':search' => $this->connection->quote($address), ':country' => $this->connection->quote($country) ] ) ); return $container; }
php
protected function getFromCache($address, $country) { $builder = $this->connection->createQueryBuilder(); $builder ->select('*') ->from($this->connection->quoteIdentifier('tl_metamodel_perimetersearch')) ->where($builder->expr()->eq($this->connection->quoteIdentifier('search'), ':search')) ->andWhere($builder->expr()->eq($this->connection->quoteIdentifier('country'), ':country')) ->setParameter('search', $address) ->setParameter('country', $country); $statement = $builder->execute(); // If we have no data just return null. if (!$statement->rowCount()) { return null; } $result = $statement->fetch(\PDO::FETCH_OBJ); // Build a new container. $container = new Container(); $container->setLatitude($result->geo_lat); $container->setLongitude($result->geo_long); $container->setSearchParam( \strtr( $builder->getSQL(), [ ':search' => $this->connection->quote($address), ':country' => $this->connection->quote($country) ] ) ); return $container; }
[ "protected", "function", "getFromCache", "(", "$", "address", ",", "$", "country", ")", "{", "$", "builder", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "builder", "->", "select", "(", "'*'", ")", "->", "from", ...
Get data from cache. @param string $address The address which where use for the search. @param string $country The country. @return Container|null
[ "Get", "data", "from", "cache", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterSetting/Perimetersearch.php#L626-L661
train
MetaModels/filter_perimetersearch
src/FilterRules/Perimetersearch.php
Perimetersearch.getMetaModelTableName
private function getMetaModelTableName() { $attribute = ((int) $this->mode === self::MODE_SINGLE) ? $this->singleAttribute : $this->latitudeAttribute; return $attribute ->getMetaModel() ->getTableName(); }
php
private function getMetaModelTableName() { $attribute = ((int) $this->mode === self::MODE_SINGLE) ? $this->singleAttribute : $this->latitudeAttribute; return $attribute ->getMetaModel() ->getTableName(); }
[ "private", "function", "getMetaModelTableName", "(", ")", "{", "$", "attribute", "=", "(", "(", "int", ")", "$", "this", "->", "mode", "===", "self", "::", "MODE_SINGLE", ")", "?", "$", "this", "->", "singleAttribute", ":", "$", "this", "->", "latitudeAt...
Get the table name from the MetaModel. @return string
[ "Get", "the", "table", "name", "from", "the", "MetaModel", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L160-L167
train
MetaModels/filter_perimetersearch
src/FilterRules/Perimetersearch.php
Perimetersearch.checkAttributeTypes
private function checkAttributeTypes($latitudeAttribute, $longitudeAttribute, $singleAttribute) { if (null !== $singleAttribute) { $this->checkMultiAttribute($singleAttribute); $this->mode = self::MODE_SINGLE; return; } if ((null !== $latitudeAttribute) && (null !== $longitudeAttribute)) { $this->checkSingleAttributes($latitudeAttribute, $longitudeAttribute); $this->mode = self::MODE_MULTI; return; } // If we have no hit throw an exception. throw new \InvalidArgumentException( 'Need a pair of valid latitude and longitude attributes or a valid geolocation attribute.' ); }
php
private function checkAttributeTypes($latitudeAttribute, $longitudeAttribute, $singleAttribute) { if (null !== $singleAttribute) { $this->checkMultiAttribute($singleAttribute); $this->mode = self::MODE_SINGLE; return; } if ((null !== $latitudeAttribute) && (null !== $longitudeAttribute)) { $this->checkSingleAttributes($latitudeAttribute, $longitudeAttribute); $this->mode = self::MODE_MULTI; return; } // If we have no hit throw an exception. throw new \InvalidArgumentException( 'Need a pair of valid latitude and longitude attributes or a valid geolocation attribute.' ); }
[ "private", "function", "checkAttributeTypes", "(", "$", "latitudeAttribute", ",", "$", "longitudeAttribute", ",", "$", "singleAttribute", ")", "{", "if", "(", "null", "!==", "$", "singleAttribute", ")", "{", "$", "this", "->", "checkMultiAttribute", "(", "$", ...
Check the attribute. @param IAttribute $latitudeAttribute The attribute to be checked. @param IAttribute $longitudeAttribute The attribute to be checked. @param IAttribute $singleAttribute The attribute to be checked. @return void @throws \InvalidArgumentException If we have no single attribute or the lang/lot attribute is missing.
[ "Check", "the", "attribute", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L197-L215
train
MetaModels/filter_perimetersearch
src/FilterRules/Perimetersearch.php
Perimetersearch.checkSingleAttributes
private function checkSingleAttributes($latitudeAttribute, $longitudeAttribute) { // Check if both of the are simple if (!($latitudeAttribute instanceof ISimple) || !($longitudeAttribute instanceof ISimple)) { throw new \InvalidArgumentException('Only simple attributes are allowed.'); } if ($latitudeAttribute->getMetaModel() !== $longitudeAttribute->getMetaModel()) { throw new \InvalidArgumentException('The first and second attribute have to be from the same MetaModel.'); } }
php
private function checkSingleAttributes($latitudeAttribute, $longitudeAttribute) { // Check if both of the are simple if (!($latitudeAttribute instanceof ISimple) || !($longitudeAttribute instanceof ISimple)) { throw new \InvalidArgumentException('Only simple attributes are allowed.'); } if ($latitudeAttribute->getMetaModel() !== $longitudeAttribute->getMetaModel()) { throw new \InvalidArgumentException('The first and second attribute have to be from the same MetaModel.'); } }
[ "private", "function", "checkSingleAttributes", "(", "$", "latitudeAttribute", ",", "$", "longitudeAttribute", ")", "{", "// Check if both of the are simple", "if", "(", "!", "(", "$", "latitudeAttribute", "instanceof", "ISimple", ")", "||", "!", "(", "$", "longitud...
Check the single attributes. @param IAttribute $latitudeAttribute The attribute to be checked. @param IAttribute $longitudeAttribute The attribute to be checked. @return void @throws \InvalidArgumentException If one of the attribute is not from type ISimple.
[ "Check", "the", "single", "attributes", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L244-L254
train
MetaModels/filter_perimetersearch
src/FilterRules/Perimetersearch.php
Perimetersearch.runSimpleQuery
protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere) { $distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart( $this->latitude, $this->longitude, $this->connection->quoteIdentifier($latitudeField), $this->connection->quoteIdentifier($longitudeField), 2 ); $builder = $this->connection->createQueryBuilder(); $builder ->select($this->connection->quoteIdentifier($idField)) ->from($tableName) ->where($builder->expr()->lte($distanceCalculation, ':distance')) ->orderBy($distanceCalculation) ->setParameter('distance', $this->dist); if ($additionalWhere) { foreach ($additionalWhere as $index => $where) { if (0 === $index) { $builder->where($where); } $builder->andWhere($where); } $builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance')); } else { $builder->where($builder->expr()->lte($distanceCalculation, ':distance')); } $statement = $builder->execute(); if (!$statement->rowCount()) { return []; } return $statement->fetchAll(\PDO::FETCH_COLUMN); }
php
protected function runSimpleQuery($idField, $tableName, $latitudeField, $longitudeField, $additionalWhere) { $distanceCalculation = HaversineSphericalDistance::getFormulaAsQueryPart( $this->latitude, $this->longitude, $this->connection->quoteIdentifier($latitudeField), $this->connection->quoteIdentifier($longitudeField), 2 ); $builder = $this->connection->createQueryBuilder(); $builder ->select($this->connection->quoteIdentifier($idField)) ->from($tableName) ->where($builder->expr()->lte($distanceCalculation, ':distance')) ->orderBy($distanceCalculation) ->setParameter('distance', $this->dist); if ($additionalWhere) { foreach ($additionalWhere as $index => $where) { if (0 === $index) { $builder->where($where); } $builder->andWhere($where); } $builder->andWhere($builder->expr()->lte($distanceCalculation, ':distance')); } else { $builder->where($builder->expr()->lte($distanceCalculation, ':distance')); } $statement = $builder->execute(); if (!$statement->rowCount()) { return []; } return $statement->fetchAll(\PDO::FETCH_COLUMN); }
[ "protected", "function", "runSimpleQuery", "(", "$", "idField", ",", "$", "tableName", ",", "$", "latitudeField", ",", "$", "longitudeField", ",", "$", "additionalWhere", ")", "{", "$", "distanceCalculation", "=", "HaversineSphericalDistance", "::", "getFormulaAsQue...
Build the SQL and execute it. @param string $idField Name of the id field. @param string $tableName The name of the table. @param string $latitudeField The name of the latitude field. @param string $longitudeField The name of the longitude field. @param array|null $additionalWhere A list with additional where information. @return array A list with ID's or an empty array.
[ "Build", "the", "SQL", "and", "execute", "it", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L291-L329
train
MetaModels/filter_perimetersearch
src/FilterRules/Perimetersearch.php
Perimetersearch.buildAdditionalWhere
protected function buildAdditionalWhere($additionalWhere) { if (null === $additionalWhere) { return null; } $sql = \implode(' AND ', \array_keys((array) $additionalWhere)); return ('' !== $sql) ? $sql . ' AND ' : null; }
php
protected function buildAdditionalWhere($additionalWhere) { if (null === $additionalWhere) { return null; } $sql = \implode(' AND ', \array_keys((array) $additionalWhere)); return ('' !== $sql) ? $sql . ' AND ' : null; }
[ "protected", "function", "buildAdditionalWhere", "(", "$", "additionalWhere", ")", "{", "if", "(", "null", "===", "$", "additionalWhere", ")", "{", "return", "null", ";", "}", "$", "sql", "=", "\\", "implode", "(", "' AND '", ",", "\\", "array_keys", "(", ...
Build a where ... @param array $additionalWhere A list with additional where information. @return null|string @deprecated This is deprecated since 2.1 and where remove in 3.0.
[ "Build", "a", "where", "..." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/FilterRules/Perimetersearch.php#L340-L349
train
hiqdev/hipanel-module-finance
src/logic/AbstractTariffManager.php
AbstractTariffManager.determineParentTariff
protected function determineParentTariff() { if ($this->tariff === null) { if (!empty($this->parent_id)) { return $this->parent_id; } return null; } if ($this->tariff->parent_id !== null) { return $this->tariff->parent_id; } return $this->tariff->id; }
php
protected function determineParentTariff() { if ($this->tariff === null) { if (!empty($this->parent_id)) { return $this->parent_id; } return null; } if ($this->tariff->parent_id !== null) { return $this->tariff->parent_id; } return $this->tariff->id; }
[ "protected", "function", "determineParentTariff", "(", ")", "{", "if", "(", "$", "this", "->", "tariff", "===", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "parent_id", ")", ")", "{", "return", "$", "this", "->", "parent_id", "...
Finds parent tariff ID. @return int
[ "Finds", "parent", "tariff", "ID", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/logic/AbstractTariffManager.php#L112-L127
train
TYPO3-CMS/redirects
Classes/Http/Middleware/RedirectHandler.php
RedirectHandler.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $redirectService = GeneralUtility::makeInstance(RedirectService::class); $port = $request->getUri()->getPort(); $matchedRedirect = $redirectService->matchRedirect( $request->getUri()->getHost() . ($port ? ':' . $port : ''), $request->getUri()->getPath(), $request->getUri()->getQuery() ?? '' ); // If the matched redirect is found, resolve it, and check further if (is_array($matchedRedirect)) { $url = $redirectService->getTargetUrl($matchedRedirect, $request->getQueryParams(), $request->getAttribute('site', null)); if ($url instanceof UriInterface) { $this->logger->debug('Redirecting', ['record' => $matchedRedirect, 'uri' => $url]); $response = $this->buildRedirectResponse($url, $matchedRedirect); $this->incrementHitCount($matchedRedirect); return $response; } } return $handler->handle($request); }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $redirectService = GeneralUtility::makeInstance(RedirectService::class); $port = $request->getUri()->getPort(); $matchedRedirect = $redirectService->matchRedirect( $request->getUri()->getHost() . ($port ? ':' . $port : ''), $request->getUri()->getPath(), $request->getUri()->getQuery() ?? '' ); // If the matched redirect is found, resolve it, and check further if (is_array($matchedRedirect)) { $url = $redirectService->getTargetUrl($matchedRedirect, $request->getQueryParams(), $request->getAttribute('site', null)); if ($url instanceof UriInterface) { $this->logger->debug('Redirecting', ['record' => $matchedRedirect, 'uri' => $url]); $response = $this->buildRedirectResponse($url, $matchedRedirect); $this->incrementHitCount($matchedRedirect); return $response; } } return $handler->handle($request); }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "$", "redirectService", "=", "GeneralUtility", "::", "makeInstance", "(", "RedirectService", "::", "clas...
First hook within the Frontend Request handling @param ServerRequestInterface $request @param RequestHandlerInterface $handler @return ResponseInterface
[ "First", "hook", "within", "the", "Frontend", "Request", "handling" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L48-L71
train
TYPO3-CMS/redirects
Classes/Http/Middleware/RedirectHandler.php
RedirectHandler.buildRedirectResponse
protected function buildRedirectResponse(UriInterface $uri, array $redirectRecord): ResponseInterface { return new RedirectResponse( $uri, (int)$redirectRecord['target_statuscode'], ['X-Redirect-By' => 'TYPO3 Redirect ' . $redirectRecord['uid']] ); }
php
protected function buildRedirectResponse(UriInterface $uri, array $redirectRecord): ResponseInterface { return new RedirectResponse( $uri, (int)$redirectRecord['target_statuscode'], ['X-Redirect-By' => 'TYPO3 Redirect ' . $redirectRecord['uid']] ); }
[ "protected", "function", "buildRedirectResponse", "(", "UriInterface", "$", "uri", ",", "array", "$", "redirectRecord", ")", ":", "ResponseInterface", "{", "return", "new", "RedirectResponse", "(", "$", "uri", ",", "(", "int", ")", "$", "redirectRecord", "[", ...
Creates a PSR-7 compatible Response object @param UriInterface $uri @param array $redirectRecord @return ResponseInterface
[ "Creates", "a", "PSR", "-", "7", "compatible", "Response", "object" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L80-L87
train
TYPO3-CMS/redirects
Classes/Http/Middleware/RedirectHandler.php
RedirectHandler.incrementHitCount
protected function incrementHitCount(array $redirectRecord) { // Track the hit if not disabled if (!GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount') || $redirectRecord['disable_hitcount']) { return; } $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('sys_redirect'); $queryBuilder ->update('sys_redirect') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($redirectRecord['uid'], \PDO::PARAM_INT)) ) ->set('hitcount', $queryBuilder->quoteIdentifier('hitcount') . '+1', false) ->set('lasthiton', $GLOBALS['EXEC_TIME']) ->execute(); }
php
protected function incrementHitCount(array $redirectRecord) { // Track the hit if not disabled if (!GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount') || $redirectRecord['disable_hitcount']) { return; } $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('sys_redirect'); $queryBuilder ->update('sys_redirect') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($redirectRecord['uid'], \PDO::PARAM_INT)) ) ->set('hitcount', $queryBuilder->quoteIdentifier('hitcount') . '+1', false) ->set('lasthiton', $GLOBALS['EXEC_TIME']) ->execute(); }
[ "protected", "function", "incrementHitCount", "(", "array", "$", "redirectRecord", ")", "{", "// Track the hit if not disabled", "if", "(", "!", "GeneralUtility", "::", "makeInstance", "(", "Features", "::", "class", ")", "->", "isFeatureEnabled", "(", "'redirects.hit...
Updates the sys_record's hit counter by one @param array $redirectRecord
[ "Updates", "the", "sys_record", "s", "hit", "counter", "by", "one" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Http/Middleware/RedirectHandler.php#L94-L110
train
hiqdev/hipanel-module-finance
src/grid/BillGridView.php
BillGridView.objectLink
public function objectLink(Bill $model): string { return $model->class === 'device' ? Html::a($model->object, ['@server/view', 'id' => $model->object_id]) : Html::tag('b', $model->object); }
php
public function objectLink(Bill $model): string { return $model->class === 'device' ? Html::a($model->object, ['@server/view', 'id' => $model->object_id]) : Html::tag('b', $model->object); }
[ "public", "function", "objectLink", "(", "Bill", "$", "model", ")", ":", "string", "{", "return", "$", "model", "->", "class", "===", "'device'", "?", "Html", "::", "a", "(", "$", "model", "->", "object", ",", "[", "'@server/view'", ",", "'id'", "=>", ...
Creates link to object details page. @param Bill $model @return string
[ "Creates", "link", "to", "object", "details", "page", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/grid/BillGridView.php#L227-L232
train
TYPO3-CMS/redirects
Classes/FormDataProvider/ValuePickerItemDataProvider.php
ValuePickerItemDataProvider.getHosts
protected function getHosts(): array { $domains = []; foreach ($this->siteFinder->getAllSites() as $site) { foreach ($site->getAllLanguages() as $language) { $domains[] = $language->getBase()->getHost(); } } $domains = array_unique($domains); sort($domains, SORT_NATURAL); return $domains; }
php
protected function getHosts(): array { $domains = []; foreach ($this->siteFinder->getAllSites() as $site) { foreach ($site->getAllLanguages() as $language) { $domains[] = $language->getBase()->getHost(); } } $domains = array_unique($domains); sort($domains, SORT_NATURAL); return $domains; }
[ "protected", "function", "getHosts", "(", ")", ":", "array", "{", "$", "domains", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "siteFinder", "->", "getAllSites", "(", ")", "as", "$", "site", ")", "{", "foreach", "(", "$", "site", "->", "g...
Get all hosts from sites @return array domain records
[ "Get", "all", "hosts", "from", "sites" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/FormDataProvider/ValuePickerItemDataProvider.php#L68-L79
train
BabDev/Transifex-API
src/Connector/Translations.php
Translations.getTranslation
public function getTranslation( string $project, string $resource, string $lang, string $mode = '' ): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"); if (!empty($mode)) { $uri = $uri->withQuery("mode=$mode&file"); } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
php
public function getTranslation( string $project, string $resource, string $lang, string $mode = '' ): ResponseInterface { $uri = $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"); if (!empty($mode)) { $uri = $uri->withQuery("mode=$mode&file"); } return $this->client->sendRequest($this->createRequest('GET', $uri)); }
[ "public", "function", "getTranslation", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "string", "$", "lang", ",", "string", "$", "mode", "=", "''", ")", ":", "ResponseInterface", "{", "$", "uri", "=", "$", "this", "->", "createUri",...
Get translations on a specified resource. @param string $project The slug for the project to pull from @param string $resource The slug for the resource to pull from @param string $lang The language to return the translation for @param string $mode The mode of the downloaded file @return ResponseInterface
[ "Get", "translations", "on", "a", "specified", "resource", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Translations.php#L25-L38
train
BabDev/Transifex-API
src/Connector/Translations.php
Translations.updateTranslation
public function updateTranslation( string $project, string $resource, string $lang, string $content, string $type = 'string' ): ResponseInterface { return $this->updateResource( $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"), $content, $type ); }
php
public function updateTranslation( string $project, string $resource, string $lang, string $content, string $type = 'string' ): ResponseInterface { return $this->updateResource( $this->createUri("/api/2/project/$project/resource/$resource/translation/$lang"), $content, $type ); }
[ "public", "function", "updateTranslation", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "string", "$", "lang", ",", "string", "$", "content", ",", "string", "$", "type", "=", "'string'", ")", ":", "ResponseInterface", "{", "return", ...
Update the content of a translation within a project. @param string $project The project the resource is part of @param string $resource The resource slug within the project @param string $lang The language to return the translation for @param string $content The content of the resource, this can either be a string of data or a file path @param string $type The type of content in the $content variable, this should be either string or file @return ResponseInterface
[ "Update", "the", "content", "of", "a", "translation", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Translations.php#L51-L63
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getCriteria
public function getCriteria(string $value): array { if ('' === trim($value)) { return []; } $fields = $this->getFields(); if (empty($fields)) { return []; } $result = []; foreach ($fields as $field) { $criteria = $this->getFieldCriteria($field, $value); if (empty($criteria)) { continue; } $result[$field][] = $criteria; } return $result; }
php
public function getCriteria(string $value): array { if ('' === trim($value)) { return []; } $fields = $this->getFields(); if (empty($fields)) { return []; } $result = []; foreach ($fields as $field) { $criteria = $this->getFieldCriteria($field, $value); if (empty($criteria)) { continue; } $result[$field][] = $criteria; } return $result; }
[ "public", "function", "getCriteria", "(", "string", "$", "value", ")", ":", "array", "{", "if", "(", "''", "===", "trim", "(", "$", "value", ")", ")", "{", "return", "[", "]", ";", "}", "$", "fields", "=", "$", "this", "->", "getFields", "(", ")"...
Prepare basic search query's where statement @param string $value Search query value @return mixed[]
[ "Prepare", "basic", "search", "query", "s", "where", "statement" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L76-L98
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getFields
protected function getFields(): array { if (empty($this->searchFields)) { return []; } $event = new Event((string)EventName::MODEL_SEARCH_BASIC_SEARCH_FIELDS(), $this, [ 'table' => $this->table ]); EventManager::instance()->dispatch($event); $result = (array)$event->result; if (empty($result)) { $result = (array)$this->table->aliasField($this->table->getDisplayField()); } $result = $this->filterFields($result); if (!empty($result)) { return $result; } $result = $this->getDefaultFields(); return $result; }
php
protected function getFields(): array { if (empty($this->searchFields)) { return []; } $event = new Event((string)EventName::MODEL_SEARCH_BASIC_SEARCH_FIELDS(), $this, [ 'table' => $this->table ]); EventManager::instance()->dispatch($event); $result = (array)$event->result; if (empty($result)) { $result = (array)$this->table->aliasField($this->table->getDisplayField()); } $result = $this->filterFields($result); if (!empty($result)) { return $result; } $result = $this->getDefaultFields(); return $result; }
[ "protected", "function", "getFields", "(", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "this", "->", "searchFields", ")", ")", "{", "return", "[", "]", ";", "}", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::...
Method that broadcasts an Event to generate the basic search fields. If the Event result is empty then it falls back to using the display field. If the display field is a virtual one then if falls back to searchable fields, using the ones that their type matches the basicSearchFieldTypes list. @return mixed[]
[ "Method", "that", "broadcasts", "an", "Event", "to", "generate", "the", "basic", "search", "fields", ".", "If", "the", "Event", "result", "is", "empty", "then", "it", "falls", "back", "to", "using", "the", "display", "field", ".", "If", "the", "display", ...
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L108-L134
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.filterFields
protected function filterFields(array $fields): array { // get table columns, aliased $columns = $this->table->getSchema()->columns(); foreach ($columns as $index => $column) { $columns[$index] = $this->table->aliasField($column); } // filter out virtual fields foreach ($fields as $index => $field) { if (!in_array($field, $columns)) { unset($fields[$index]); } } return $fields; }
php
protected function filterFields(array $fields): array { // get table columns, aliased $columns = $this->table->getSchema()->columns(); foreach ($columns as $index => $column) { $columns[$index] = $this->table->aliasField($column); } // filter out virtual fields foreach ($fields as $index => $field) { if (!in_array($field, $columns)) { unset($fields[$index]); } } return $fields; }
[ "protected", "function", "filterFields", "(", "array", "$", "fields", ")", ":", "array", "{", "// get table columns, aliased", "$", "columns", "=", "$", "this", "->", "table", "->", "getSchema", "(", ")", "->", "columns", "(", ")", ";", "foreach", "(", "$"...
Filters basic search fields by removing virtual ones. @param mixed[] $fields Basic search fields @return mixed[]
[ "Filters", "basic", "search", "fields", "by", "removing", "virtual", "ones", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L142-L158
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getDefaultFields
protected function getDefaultFields(): array { $result = []; $types = Options::getBasicSearchFieldTypes(); foreach ($this->searchFields as $field => $properties) { if (in_array($properties['type'], $types)) { $result[] = $field; } } return $result; }
php
protected function getDefaultFields(): array { $result = []; $types = Options::getBasicSearchFieldTypes(); foreach ($this->searchFields as $field => $properties) { if (in_array($properties['type'], $types)) { $result[] = $field; } } return $result; }
[ "protected", "function", "getDefaultFields", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "$", "types", "=", "Options", "::", "getBasicSearchFieldTypes", "(", ")", ";", "foreach", "(", "$", "this", "->", "searchFields", "as", "$", "fie...
Default basic search fields getter. @return mixed[]
[ "Default", "basic", "search", "fields", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L165-L177
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getFieldCriteria
protected function getFieldCriteria(string $field, string $value): array { // not a searchable field if (!array_key_exists($field, $this->searchFields)) { return []; } // unsupported field type for basic search $type = $this->searchFields[$field]['type']; if (!in_array($type, Options::getBasicSearchFieldTypes())) { return []; } $result = []; switch ($type) { case 'related': $result = $this->getRelatedFieldValue($field, $value); break; default: $result = $this->getFieldValue($field, $value); break; } return $result; }
php
protected function getFieldCriteria(string $field, string $value): array { // not a searchable field if (!array_key_exists($field, $this->searchFields)) { return []; } // unsupported field type for basic search $type = $this->searchFields[$field]['type']; if (!in_array($type, Options::getBasicSearchFieldTypes())) { return []; } $result = []; switch ($type) { case 'related': $result = $this->getRelatedFieldValue($field, $value); break; default: $result = $this->getFieldValue($field, $value); break; } return $result; }
[ "protected", "function", "getFieldCriteria", "(", "string", "$", "field", ",", "string", "$", "value", ")", ":", "array", "{", "// not a searchable field", "if", "(", "!", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "searchFields", ")", ")...
Field criteria getter for basic search field. @param string $field Field name @param string $value Search query value @return mixed[]
[ "Field", "criteria", "getter", "for", "basic", "search", "field", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L186-L211
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getFieldValue
protected function getFieldValue(string $field, string $value): array { return [ 'type' => $this->searchFields[$field]['type'], 'operator' => key($this->searchFields[$field]['operators']), 'value' => $value ]; }
php
protected function getFieldValue(string $field, string $value): array { return [ 'type' => $this->searchFields[$field]['type'], 'operator' => key($this->searchFields[$field]['operators']), 'value' => $value ]; }
[ "protected", "function", "getFieldValue", "(", "string", "$", "field", ",", "string", "$", "value", ")", ":", "array", "{", "return", "[", "'type'", "=>", "$", "this", "->", "searchFields", "[", "$", "field", "]", "[", "'type'", "]", ",", "'operator'", ...
Field value getter for basic search criteria. @param string $field Field name @param string $value Search query value @return mixed[]
[ "Field", "value", "getter", "for", "basic", "search", "criteria", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L220-L227
train
QoboLtd/cakephp-search
src/Utility/BasicSearch.php
BasicSearch.getRelatedFieldValue
protected function getRelatedFieldValue(string $field, string $value): array { $table = TableRegistry::get($this->searchFields[$field]['source']); // avoid infinite recursion if ($this->table->getAlias() === $table->getAlias()) { return []; } $search = new Search($table, $this->user); $basicSearch = new BasicSearch($table, $this->user); $criteria = $basicSearch->getCriteria($value); if (empty($criteria)) { return []; } $data = [ 'aggregator' => 'OR', 'criteria' => $criteria ]; $resultSet = $search->execute($data)->all(); if ($resultSet->isEmpty()) { return []; } $result = []; foreach ($resultSet as $entity) { $result[] = $entity->id; } return [ 'type' => $this->searchFields[$field]['type'], 'operator' => key($this->searchFields[$field]['operators']), 'value' => $result ]; }
php
protected function getRelatedFieldValue(string $field, string $value): array { $table = TableRegistry::get($this->searchFields[$field]['source']); // avoid infinite recursion if ($this->table->getAlias() === $table->getAlias()) { return []; } $search = new Search($table, $this->user); $basicSearch = new BasicSearch($table, $this->user); $criteria = $basicSearch->getCriteria($value); if (empty($criteria)) { return []; } $data = [ 'aggregator' => 'OR', 'criteria' => $criteria ]; $resultSet = $search->execute($data)->all(); if ($resultSet->isEmpty()) { return []; } $result = []; foreach ($resultSet as $entity) { $result[] = $entity->id; } return [ 'type' => $this->searchFields[$field]['type'], 'operator' => key($this->searchFields[$field]['operators']), 'value' => $result ]; }
[ "protected", "function", "getRelatedFieldValue", "(", "string", "$", "field", ",", "string", "$", "value", ")", ":", "array", "{", "$", "table", "=", "TableRegistry", "::", "get", "(", "$", "this", "->", "searchFields", "[", "$", "field", "]", "[", "'sou...
Gets basic search values from Related module. This method is useful when you do a basic search on a related field, in which the values are always uuid's. What this method will do is run a search in the related module (recursively) to fetch and return the entities IDs matching the search string. @param string $field Field name @param string $value Search query value @return mixed[]
[ "Gets", "basic", "search", "values", "from", "Related", "module", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/BasicSearch.php#L241-L278
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.addCriteria
public function addCriteria(Criteria $criteria) : void { if (! $this->isValidFilter($criteria->getOperator())) { throw new \RuntimeException(sprintf('Invalid filter provided: %s', $criteria->getOperator())); } $this->criteria[] = $criteria; }
php
public function addCriteria(Criteria $criteria) : void { if (! $this->isValidFilter($criteria->getOperator())) { throw new \RuntimeException(sprintf('Invalid filter provided: %s', $criteria->getOperator())); } $this->criteria[] = $criteria; }
[ "public", "function", "addCriteria", "(", "Criteria", "$", "criteria", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isValidFilter", "(", "$", "criteria", "->", "getOperator", "(", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException"...
Add criteria to Search. @param \Search\Service\Criteria $criteria Criteria object @return void @throws \RuntimeException When invalid filter class is provided
[ "Add", "criteria", "to", "Search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L103-L110
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.setConjunction
public function setConjunction(string $conjunction = self::DEFAULT_CONJUNCTION) : void { if (! in_array($conjunction, self::CONJUNCTIONS)) { throw new \RuntimeException(sprintf('Invalid conjunction provided: %s', $conjunction)); } $this->conjunction = $conjunction; }
php
public function setConjunction(string $conjunction = self::DEFAULT_CONJUNCTION) : void { if (! in_array($conjunction, self::CONJUNCTIONS)) { throw new \RuntimeException(sprintf('Invalid conjunction provided: %s', $conjunction)); } $this->conjunction = $conjunction; }
[ "public", "function", "setConjunction", "(", "string", "$", "conjunction", "=", "self", "::", "DEFAULT_CONJUNCTION", ")", ":", "void", "{", "if", "(", "!", "in_array", "(", "$", "conjunction", ",", "self", "::", "CONJUNCTIONS", ")", ")", "{", "throw", "new...
Add conjunction to Search. @param string $conjunction Search conjunction @return void @throws \RuntimeException When invalid filter class is provided
[ "Add", "conjunction", "to", "Search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L119-L126
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.execute
public function execute() : Query { $this->applyFilters(); $this->applySelect(); $this->applyJoins(); $clause = $this->query->clause('where'); // adjust where clause conjunction if (null !== $clause) { $this->query->where($clause->setConjunction($this->conjunction), [], true); } return $this->query; }
php
public function execute() : Query { $this->applyFilters(); $this->applySelect(); $this->applyJoins(); $clause = $this->query->clause('where'); // adjust where clause conjunction if (null !== $clause) { $this->query->where($clause->setConjunction($this->conjunction), [], true); } return $this->query; }
[ "public", "function", "execute", "(", ")", ":", "Query", "{", "$", "this", "->", "applyFilters", "(", ")", ";", "$", "this", "->", "applySelect", "(", ")", ";", "$", "this", "->", "applyJoins", "(", ")", ";", "$", "clause", "=", "$", "this", "->", ...
Executes search logic. @return \Cake\ORM\Query
[ "Executes", "search", "logic", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L133-L146
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.applyFilters
private function applyFilters() : void { foreach ($this->criteria as $criteria) { $filterClass = $criteria->getOperator(); $filter = new $filterClass( $this->table->aliasField($criteria->getField()), $criteria->getValue() ); $filter->apply($this->query); } }
php
private function applyFilters() : void { foreach ($this->criteria as $criteria) { $filterClass = $criteria->getOperator(); $filter = new $filterClass( $this->table->aliasField($criteria->getField()), $criteria->getValue() ); $filter->apply($this->query); } }
[ "private", "function", "applyFilters", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "criteria", "as", "$", "criteria", ")", "{", "$", "filterClass", "=", "$", "criteria", "->", "getOperator", "(", ")", ";", "$", "filter", "=", "new", ...
Applies filters to the Query. @return void
[ "Applies", "filters", "to", "the", "Query", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L164-L176
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.applySelect
private function applySelect() : void { $group = $this->query->clause('group'); $group = array_filter($group); if (empty($group)) { return; } $this->query->select($group, true); $this->query->select([self::GROUP_BY_FIELD => $this->query->func()->count($group[0])]); }
php
private function applySelect() : void { $group = $this->query->clause('group'); $group = array_filter($group); if (empty($group)) { return; } $this->query->select($group, true); $this->query->select([self::GROUP_BY_FIELD => $this->query->func()->count($group[0])]); }
[ "private", "function", "applySelect", "(", ")", ":", "void", "{", "$", "group", "=", "$", "this", "->", "query", "->", "clause", "(", "'group'", ")", ";", "$", "group", "=", "array_filter", "(", "$", "group", ")", ";", "if", "(", "empty", "(", "$",...
Adjusts select clause in case a group_by clause is defined. @return void
[ "Adjusts", "select", "clause", "in", "case", "a", "group_by", "clause", "is", "defined", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L183-L193
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.applyJoins
private function applyJoins() : void { foreach ($this->getAssociations() as $association) { switch ($association->type()) { case Association::MANY_TO_ONE: $this->query->leftJoinWith($association->getName()); break; case Association::ONE_TO_ONE: case Association::ONE_TO_MANY: case Association::MANY_TO_MANY: default: break; } } }
php
private function applyJoins() : void { foreach ($this->getAssociations() as $association) { switch ($association->type()) { case Association::MANY_TO_ONE: $this->query->leftJoinWith($association->getName()); break; case Association::ONE_TO_ONE: case Association::ONE_TO_MANY: case Association::MANY_TO_MANY: default: break; } } }
[ "private", "function", "applyJoins", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "getAssociations", "(", ")", "as", "$", "association", ")", "{", "switch", "(", "$", "association", "->", "type", "(", ")", ")", "{", "case", "Associati...
Applies association joins to the Query. @return void
[ "Applies", "association", "joins", "to", "the", "Query", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L200-L215
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.getAssociations
private function getAssociations() : array { $result = []; foreach ($this->getQueryFields() as $field) { $association = $this->getAssociationByField($field); if (null === $association) { continue; } if (array_key_exists($association->getName(), $result)) { continue; } $result[$association->getName()] = $association; } return $result; }
php
private function getAssociations() : array { $result = []; foreach ($this->getQueryFields() as $field) { $association = $this->getAssociationByField($field); if (null === $association) { continue; } if (array_key_exists($association->getName(), $result)) { continue; } $result[$association->getName()] = $association; } return $result; }
[ "private", "function", "getAssociations", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getQueryFields", "(", ")", "as", "$", "field", ")", "{", "$", "association", "=", "$", "this", "->", "getAss...
Get required associations based on current search criteria. @return mixed[]
[ "Get", "required", "associations", "based", "on", "current", "search", "criteria", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L222-L239
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.getQueryFields
private function getQueryFields() : array { $result = []; foreach ($this->criteria as $criteria) { $field = $this->table->aliasField($criteria->getField()); if (! in_array($field, $result)) { $result[] = $field; } } foreach ($this->query->clause('select') as $field) { if (is_string($field) && ! in_array($field, $result)) { $result[] = $field; } } return $result; }
php
private function getQueryFields() : array { $result = []; foreach ($this->criteria as $criteria) { $field = $this->table->aliasField($criteria->getField()); if (! in_array($field, $result)) { $result[] = $field; } } foreach ($this->query->clause('select') as $field) { if (is_string($field) && ! in_array($field, $result)) { $result[] = $field; } } return $result; }
[ "private", "function", "getQueryFields", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "criteria", "as", "$", "criteria", ")", "{", "$", "field", "=", "$", "this", "->", "table", "->", "aliasField"...
Get search query fields from criteria and select clause. @return string[]
[ "Get", "search", "query", "fields", "from", "criteria", "and", "select", "clause", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L246-L263
train
QoboLtd/cakephp-search
src/Service/Search.php
Search.getAssociationByField
private function getAssociationByField(string $field) : ?Association { list($name) = explode('.', $this->table->aliasField($field), 2); if ($name === $this->table->getAlias()) { return null; } if (! $this->table->hasAssociation($name)) { throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name)); } return $this->table->getAssociation($name); }
php
private function getAssociationByField(string $field) : ?Association { list($name) = explode('.', $this->table->aliasField($field), 2); if ($name === $this->table->getAlias()) { return null; } if (! $this->table->hasAssociation($name)) { throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name)); } return $this->table->getAssociation($name); }
[ "private", "function", "getAssociationByField", "(", "string", "$", "field", ")", ":", "?", "Association", "{", "list", "(", "$", "name", ")", "=", "explode", "(", "'.'", ",", "$", "this", "->", "table", "->", "aliasField", "(", "$", "field", ")", ",",...
Retrieves table association by aliased field name. Example: 'Author.name' @param string $field Field name @return \Cake\ORM\Association|null @throws \RuntimeException When invalid association is found
[ "Retrieves", "table", "association", "by", "aliased", "field", "name", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Search.php#L274-L287
train
QoboLtd/cakephp-search
src/Model/Table/SavedSearchesTable.php
SavedSearchesTable.beforeMarshal
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) : void { // @todo this will be removed once saved searches table schema is adjusted $saved = Hash::get($data, 'content.saved', []); if (! empty($saved)) { $data['content']['latest'] = $saved; } }
php
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) : void { // @todo this will be removed once saved searches table schema is adjusted $saved = Hash::get($data, 'content.saved', []); if (! empty($saved)) { $data['content']['latest'] = $saved; } }
[ "public", "function", "beforeMarshal", "(", "Event", "$", "event", ",", "ArrayObject", "$", "data", ",", "ArrayObject", "$", "options", ")", ":", "void", "{", "// @todo this will be removed once saved searches table schema is adjusted", "$", "saved", "=", "Hash", "::"...
Structures "content" data to suported format. @param \Cake\Event\Event $event Event object @param \ArrayObject $data Request data @param \ArrayObject $options Marshaller options @return void
[ "Structures", "content", "data", "to", "suported", "format", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/SavedSearchesTable.php#L128-L135
train
TYPO3-CMS/redirects
Classes/Repository/Demand.php
Demand.createFromRequest
public static function createFromRequest(ServerRequestInterface $request): Demand { $page = (int)($request->getQueryParams()['page'] ?? $request->getParsedBody()['page'] ?? 1); $demand = $request->getQueryParams()['demand'] ?? $request->getParsedBody()['demand']; if (empty($demand)) { return new self($page); } $sourceHost = $demand['source_host'] ?? ''; $sourcePath = $demand['source_path'] ?? ''; $statusCode = (int)$demand['target_statuscode'] ?? 0; $target = $demand['target'] ?? ''; return new self($page, $sourceHost, $sourcePath, $target, $statusCode); }
php
public static function createFromRequest(ServerRequestInterface $request): Demand { $page = (int)($request->getQueryParams()['page'] ?? $request->getParsedBody()['page'] ?? 1); $demand = $request->getQueryParams()['demand'] ?? $request->getParsedBody()['demand']; if (empty($demand)) { return new self($page); } $sourceHost = $demand['source_host'] ?? ''; $sourcePath = $demand['source_path'] ?? ''; $statusCode = (int)$demand['target_statuscode'] ?? 0; $target = $demand['target'] ?? ''; return new self($page, $sourceHost, $sourcePath, $target, $statusCode); }
[ "public", "static", "function", "createFromRequest", "(", "ServerRequestInterface", "$", "request", ")", ":", "Demand", "{", "$", "page", "=", "(", "int", ")", "(", "$", "request", "->", "getQueryParams", "(", ")", "[", "'page'", "]", "??", "$", "request",...
Creates a Demand object from the current request. @param ServerRequestInterface $request @return Demand
[ "Creates", "a", "Demand", "object", "from", "the", "current", "request", "." ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Repository/Demand.php#L79-L91
train
QoboLtd/cakephp-search
src/Service/Criteria.php
Criteria.validate
private function validate(array $data) : void { $diff = array_diff(self::REQUIRED_PARAMS, array_keys($data)); if (! empty($diff)) { throw new \InvalidArgumentException( sprintf('Search criteria is missing required parameter(s): %s', implode(', ', $diff)) ); } if (! is_string($data['field'])) { throw new \InvalidArgumentException('Field parameter must be a string'); } if (! is_string($data['operator'])) { throw new \InvalidArgumentException('Operator parameter must be a string'); } if (! is_scalar($data['value']) && ! is_array($data['value'])) { throw new \InvalidArgumentException(sprintf('Unsupported value type provided: %s', gettype($data['value']))); } }
php
private function validate(array $data) : void { $diff = array_diff(self::REQUIRED_PARAMS, array_keys($data)); if (! empty($diff)) { throw new \InvalidArgumentException( sprintf('Search criteria is missing required parameter(s): %s', implode(', ', $diff)) ); } if (! is_string($data['field'])) { throw new \InvalidArgumentException('Field parameter must be a string'); } if (! is_string($data['operator'])) { throw new \InvalidArgumentException('Operator parameter must be a string'); } if (! is_scalar($data['value']) && ! is_array($data['value'])) { throw new \InvalidArgumentException(sprintf('Unsupported value type provided: %s', gettype($data['value']))); } }
[ "private", "function", "validate", "(", "array", "$", "data", ")", ":", "void", "{", "$", "diff", "=", "array_diff", "(", "self", "::", "REQUIRED_PARAMS", ",", "array_keys", "(", "$", "data", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "diff", ...
Validates search criteria. @param mixed[] $data Search criteria @return void @throws \InvalidArgumentException When invalid/incomplete data are provided
[ "Validates", "search", "criteria", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Service/Criteria.php#L68-L89
train
QoboLtd/cakephp-search
src/Model/Behavior/SearchableBehavior.php
SearchableBehavior.findSearch
public function findSearch(Query $query, array $options) : Query { $search = new Search($query, $this->getTable()); $search->setConjunction(Hash::get($options, 'conjunction', Search::DEFAULT_CONJUNCTION)); foreach (Hash::get($options, 'data', []) as $criteria) { if (! is_array($criteria)) { throw new \InvalidArgumentException(sprintf( 'Search criteria must be an array, %s provided instead', gettype($criteria) )); } $search->addCriteria(new Criteria($criteria)); } return $search->execute(); }
php
public function findSearch(Query $query, array $options) : Query { $search = new Search($query, $this->getTable()); $search->setConjunction(Hash::get($options, 'conjunction', Search::DEFAULT_CONJUNCTION)); foreach (Hash::get($options, 'data', []) as $criteria) { if (! is_array($criteria)) { throw new \InvalidArgumentException(sprintf( 'Search criteria must be an array, %s provided instead', gettype($criteria) )); } $search->addCriteria(new Criteria($criteria)); } return $search->execute(); }
[ "public", "function", "findSearch", "(", "Query", "$", "query", ",", "array", "$", "options", ")", ":", "Query", "{", "$", "search", "=", "new", "Search", "(", "$", "query", ",", "$", "this", "->", "getTable", "(", ")", ")", ";", "$", "search", "->...
Search finder method. @param \Cake\ORM\Query $query The query object to apply the finder options to @param mixed[] $options List of options to pass to the finder @return \Cake\ORM\Query
[ "Search", "finder", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Behavior/SearchableBehavior.php#L46-L64
train
php-enqueue/stomp
BufferedStompClient.php
BufferedStompClient.readMessageFrame
public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame { // pop up frame from the buffer if (isset($this->buffer[$subscriptionId]) && ($frame = array_shift($this->buffer[$subscriptionId]))) { --$this->currentBufferSize; return $frame; } // do nothing when buffer is full if ($this->currentBufferSize >= $this->bufferSize) { return null; } $startTime = microtime(true); $remainingTimeout = $timeout * 1000; while (true) { $this->getConnection()->setReadTimeout(0, $remainingTimeout); // there is nothing to read if (false === $frame = $this->readFrame()) { return null; } if ('MESSAGE' !== $frame->getCommand()) { throw new \LogicException(sprintf('Unexpected frame was received: "%s"', $frame->getCommand())); } $headers = $frame->getHeaders(); if (false == isset($headers['subscription'])) { throw new \LogicException('Got message frame with missing subscription header'); } // frame belongs to another subscription if ($headers['subscription'] !== $subscriptionId) { $this->buffer[$headers['subscription']][] = $frame; ++$this->currentBufferSize; $remainingTimeout -= (microtime(true) - $startTime) * 1000000; if ($remainingTimeout <= 0) { return null; } continue; } return $frame; } }
php
public function readMessageFrame(string $subscriptionId, int $timeout): ?Frame { // pop up frame from the buffer if (isset($this->buffer[$subscriptionId]) && ($frame = array_shift($this->buffer[$subscriptionId]))) { --$this->currentBufferSize; return $frame; } // do nothing when buffer is full if ($this->currentBufferSize >= $this->bufferSize) { return null; } $startTime = microtime(true); $remainingTimeout = $timeout * 1000; while (true) { $this->getConnection()->setReadTimeout(0, $remainingTimeout); // there is nothing to read if (false === $frame = $this->readFrame()) { return null; } if ('MESSAGE' !== $frame->getCommand()) { throw new \LogicException(sprintf('Unexpected frame was received: "%s"', $frame->getCommand())); } $headers = $frame->getHeaders(); if (false == isset($headers['subscription'])) { throw new \LogicException('Got message frame with missing subscription header'); } // frame belongs to another subscription if ($headers['subscription'] !== $subscriptionId) { $this->buffer[$headers['subscription']][] = $frame; ++$this->currentBufferSize; $remainingTimeout -= (microtime(true) - $startTime) * 1000000; if ($remainingTimeout <= 0) { return null; } continue; } return $frame; } }
[ "public", "function", "readMessageFrame", "(", "string", "$", "subscriptionId", ",", "int", "$", "timeout", ")", ":", "?", "Frame", "{", "// pop up frame from the buffer", "if", "(", "isset", "(", "$", "this", "->", "buffer", "[", "$", "subscriptionId", "]", ...
Timeout is in milliseconds.
[ "Timeout", "is", "in", "milliseconds", "." ]
b5c5742ba6c863bcc38396cc38110aa829e9336d
https://github.com/php-enqueue/stomp/blob/b5c5742ba6c863bcc38396cc38110aa829e9336d/BufferedStompClient.php#L53-L104
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.createLanguage
public function createLanguage( string $slug, string $langCode, array $coordinators, array $options = [], bool $skipInvalidUsername = false ): ResponseInterface { // Make sure the $coordinators array is not empty if (!\count($coordinators)) { throw new \InvalidArgumentException('The coordinators array must contain at least one username.'); } $uri = $this->createUri("/api/2/project/$slug/languages/"); if ($skipInvalidUsername) { $uri = $uri->withQuery('skip_invalid_username'); } // Build the required request data. $data = [ 'language_code' => $langCode, 'coordinators' => $coordinators, ]; // Valid options to check $validOptions = ['translators', 'reviewers', 'list']; // Loop through the valid options and if we have them, add them to the request data foreach ($validOptions as $option) { if (isset($options[$option])) { $data[$option] = $options[$option]; } } $request = $this->createRequest('POST', $uri); $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); return $this->client->sendRequest($request); }
php
public function createLanguage( string $slug, string $langCode, array $coordinators, array $options = [], bool $skipInvalidUsername = false ): ResponseInterface { // Make sure the $coordinators array is not empty if (!\count($coordinators)) { throw new \InvalidArgumentException('The coordinators array must contain at least one username.'); } $uri = $this->createUri("/api/2/project/$slug/languages/"); if ($skipInvalidUsername) { $uri = $uri->withQuery('skip_invalid_username'); } // Build the required request data. $data = [ 'language_code' => $langCode, 'coordinators' => $coordinators, ]; // Valid options to check $validOptions = ['translators', 'reviewers', 'list']; // Loop through the valid options and if we have them, add them to the request data foreach ($validOptions as $option) { if (isset($options[$option])) { $data[$option] = $options[$option]; } } $request = $this->createRequest('POST', $uri); $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); return $this->client->sendRequest($request); }
[ "public", "function", "createLanguage", "(", "string", "$", "slug", ",", "string", "$", "langCode", ",", "array", "$", "coordinators", ",", "array", "$", "options", "=", "[", "]", ",", "bool", "$", "skipInvalidUsername", "=", "false", ")", ":", "ResponseIn...
Create a language for a project. @param string $slug The slug for the project @param string $langCode The language code for the new language @param string[] $coordinators An array of coordinators for the language @param array $options Optional additional params to send with the request @param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames @return ResponseInterface @throws \InvalidArgumentException
[ "Create", "a", "language", "for", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L28-L66
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.deleteLanguage
public function deleteLanguage(string $project, string $langCode): ResponseInterface { return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/language/$langCode/"))); }
php
public function deleteLanguage(string $project, string $langCode): ResponseInterface { return $this->client->sendRequest($this->createRequest('DELETE', $this->createUri("/api/2/project/$project/language/$langCode/"))); }
[ "public", "function", "deleteLanguage", "(", "string", "$", "project", ",", "string", "$", "langCode", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "this", "->", "createRequest", "(", "'DELETE'", "...
Delete a language within a project. @param string $project The project to retrieve details for @param string $langCode The language code to retrieve details for @return ResponseInterface
[ "Delete", "a", "language", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L76-L79
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.getLanguages
public function getLanguages(string $project): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/languages/"))); }
php
public function getLanguages(string $project): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/languages/"))); }
[ "public", "function", "getLanguages", "(", "string", "$", "project", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "this", "->", "createRequest", "(", "'GET'", ",", "$", "this", "->", "createUri", ...
Get a list of languages for a specified project. @param string $project The project to retrieve details for @return ResponseInterface
[ "Get", "a", "list", "of", "languages", "for", "a", "specified", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L121-L124
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.updateCoordinators
public function updateCoordinators( string $project, string $langCode, array $coordinators, bool $skipInvalidUsername = false ): ResponseInterface { return $this->updateTeam($project, $langCode, $coordinators, $skipInvalidUsername, 'coordinators'); }
php
public function updateCoordinators( string $project, string $langCode, array $coordinators, bool $skipInvalidUsername = false ): ResponseInterface { return $this->updateTeam($project, $langCode, $coordinators, $skipInvalidUsername, 'coordinators'); }
[ "public", "function", "updateCoordinators", "(", "string", "$", "project", ",", "string", "$", "langCode", ",", "array", "$", "coordinators", ",", "bool", "$", "skipInvalidUsername", "=", "false", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->"...
Update the coordinators for a language team in a project. @param string $project The project to retrieve details for @param string $langCode The language code to retrieve details for @param string[] $coordinators An array of coordinators for the language @param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames @return ResponseInterface
[ "Update", "the", "coordinators", "for", "a", "language", "team", "in", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L162-L169
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.updateLanguage
public function updateLanguage( string $slug, string $langCode, array $coordinators, array $options = [] ): ResponseInterface { // Make sure the $coordinators array is not empty if (!\count($coordinators)) { throw new \InvalidArgumentException('The coordinators array must contain at least one username.'); } // Build the required request data. $data = ['coordinators' => $coordinators]; // Set the translators if present if (isset($options['translators'])) { $data['translators'] = $options['translators']; } // Set the reviewers if present if (isset($options['reviewers'])) { $data['reviewers'] = $options['reviewers']; } $request = $this->createRequest('PUT', $this->createUri("/api/2/project/$slug/language/$langCode/")); $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); $request = $request->withHeader('Content-Type', 'application/json'); return $this->client->sendRequest($request); }
php
public function updateLanguage( string $slug, string $langCode, array $coordinators, array $options = [] ): ResponseInterface { // Make sure the $coordinators array is not empty if (!\count($coordinators)) { throw new \InvalidArgumentException('The coordinators array must contain at least one username.'); } // Build the required request data. $data = ['coordinators' => $coordinators]; // Set the translators if present if (isset($options['translators'])) { $data['translators'] = $options['translators']; } // Set the reviewers if present if (isset($options['reviewers'])) { $data['reviewers'] = $options['reviewers']; } $request = $this->createRequest('PUT', $this->createUri("/api/2/project/$slug/language/$langCode/")); $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); $request = $request->withHeader('Content-Type', 'application/json'); return $this->client->sendRequest($request); }
[ "public", "function", "updateLanguage", "(", "string", "$", "slug", ",", "string", "$", "langCode", ",", "array", "$", "coordinators", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ResponseInterface", "{", "// Make sure the $coordinators array is not emp...
Update a language within a project. @param string $slug The slug for the project @param string $langCode The language code for the new language @param string[] $coordinators An array of coordinators for the language @param array $options Optional additional params to send with the request @return ResponseInterface @throws \InvalidArgumentException
[ "Update", "a", "language", "within", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L183-L212
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.updateReviewers
public function updateReviewers(string $project, string $langCode, array $reviewers, bool $skipInvalidUsername = false): ResponseInterface { return $this->updateTeam($project, $langCode, $reviewers, $skipInvalidUsername, 'reviewers'); }
php
public function updateReviewers(string $project, string $langCode, array $reviewers, bool $skipInvalidUsername = false): ResponseInterface { return $this->updateTeam($project, $langCode, $reviewers, $skipInvalidUsername, 'reviewers'); }
[ "public", "function", "updateReviewers", "(", "string", "$", "project", ",", "string", "$", "langCode", ",", "array", "$", "reviewers", ",", "bool", "$", "skipInvalidUsername", "=", "false", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "u...
Update the reviewers for a language team in a project. @param string $project The project to retrieve details for @param string $langCode The language code to retrieve details for @param string[] $reviewers An array of reviewers for the language @param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames @return ResponseInterface
[ "Update", "the", "reviewers", "for", "a", "language", "team", "in", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L224-L227
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.updateTeam
protected function updateTeam( string $project, string $langCode, array $members, bool $skipInvalidUsername, string $team ): ResponseInterface { // Make sure the $members array is not empty if (!\count($members)) { throw new \InvalidArgumentException("The $team array must contain at least one username."); } $uri = $this->createUri("/api/2/project/$project/language/$langCode/$team/"); if ($skipInvalidUsername) { $uri = $uri->withQuery('skip_invalid_username'); } $request = $this->createRequest('PUT', $uri); $request = $request->withBody($this->streamFactory->createStream(\json_encode($members))); $request = $request->withHeader('Content-Type', 'application/json'); return $this->client->sendRequest($request); }
php
protected function updateTeam( string $project, string $langCode, array $members, bool $skipInvalidUsername, string $team ): ResponseInterface { // Make sure the $members array is not empty if (!\count($members)) { throw new \InvalidArgumentException("The $team array must contain at least one username."); } $uri = $this->createUri("/api/2/project/$project/language/$langCode/$team/"); if ($skipInvalidUsername) { $uri = $uri->withQuery('skip_invalid_username'); } $request = $this->createRequest('PUT', $uri); $request = $request->withBody($this->streamFactory->createStream(\json_encode($members))); $request = $request->withHeader('Content-Type', 'application/json'); return $this->client->sendRequest($request); }
[ "protected", "function", "updateTeam", "(", "string", "$", "project", ",", "string", "$", "langCode", ",", "array", "$", "members", ",", "bool", "$", "skipInvalidUsername", ",", "string", "$", "team", ")", ":", "ResponseInterface", "{", "// Make sure the $member...
Base method to update a given language team in a project. @param string $project The project to retrieve details for @param string $langCode The language code to retrieve details for @param string[] $members An array of the team members for the language @param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames @param string $team The team to update @return ResponseInterface @throws \InvalidArgumentException
[ "Base", "method", "to", "update", "a", "given", "language", "team", "in", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L242-L265
train
BabDev/Transifex-API
src/Connector/Languages.php
Languages.updateTranslators
public function updateTranslators( string $project, string $langCode, array $translators, bool $skipInvalidUsername = false ): ResponseInterface { return $this->updateTeam($project, $langCode, $translators, $skipInvalidUsername, 'translators'); }
php
public function updateTranslators( string $project, string $langCode, array $translators, bool $skipInvalidUsername = false ): ResponseInterface { return $this->updateTeam($project, $langCode, $translators, $skipInvalidUsername, 'translators'); }
[ "public", "function", "updateTranslators", "(", "string", "$", "project", ",", "string", "$", "langCode", ",", "array", "$", "translators", ",", "bool", "$", "skipInvalidUsername", "=", "false", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", ...
Update the translators for a language team in a project. @param string $project The project to retrieve details for @param string $langCode The language code to retrieve details for @param string[] $translators An array of translators for the language @param bool $skipInvalidUsername If true, the API call does not fail and instead will return a list of invalid usernames @return ResponseInterface
[ "Update", "the", "translators", "for", "a", "language", "team", "in", "a", "project", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Languages.php#L277-L284
train
BabDev/Transifex-API
src/Connector/Statistics.php
Statistics.getStatistics
public function getStatistics(string $project, string $resource, string $lang = ''): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/resource/$resource/stats/$lang"))); }
php
public function getStatistics(string $project, string $resource, string $lang = ''): ResponseInterface { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/api/2/project/$project/resource/$resource/stats/$lang"))); }
[ "public", "function", "getStatistics", "(", "string", "$", "project", ",", "string", "$", "resource", ",", "string", "$", "lang", "=", "''", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "client", "->", "sendRequest", "(", "$", "this", ...
Get statistics on a specified resource. @param string $project The slug for the project to pull from @param string $resource The slug for the resource to pull from @param string $lang An optional language code to return data only for a specified language @return ResponseInterface
[ "Get", "statistics", "on", "a", "specified", "resource", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Statistics.php#L24-L27
train
TYPO3-CMS/redirects
Classes/Controller/ManagementController.php
ManagementController.handleRequest
public function handleRequest(ServerRequestInterface $request): ResponseInterface { $this->request = $request; $action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview'; $this->initializeView($action); $result = call_user_func_array([$this, $action . 'Action'], [$request]); if ($result instanceof ResponseInterface) { return $result; } $this->moduleTemplate->setContent($this->view->render()); return new HtmlResponse($this->moduleTemplate->renderContent()); }
php
public function handleRequest(ServerRequestInterface $request): ResponseInterface { $this->request = $request; $action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview'; $this->initializeView($action); $result = call_user_func_array([$this, $action . 'Action'], [$request]); if ($result instanceof ResponseInterface) { return $result; } $this->moduleTemplate->setContent($this->view->render()); return new HtmlResponse($this->moduleTemplate->renderContent()); }
[ "public", "function", "handleRequest", "(", "ServerRequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "$", "this", "->", "request", "=", "$", "request", ";", "$", "action", "=", "$", "request", "->", "getQueryParams", "(", ")", "[", "'act...
Injects the request object for the current request, and renders the overview of all redirects @param ServerRequestInterface $request the current request @return ResponseInterface the response with the content
[ "Injects", "the", "request", "object", "for", "the", "current", "request", "and", "renders", "the", "overview", "of", "all", "redirects" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L81-L93
train
TYPO3-CMS/redirects
Classes/Controller/ManagementController.php
ManagementController.overviewAction
protected function overviewAction(ServerRequestInterface $request) { $this->getButtons(); $demand = Demand::createFromRequest($request); $redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand); $count = $redirectRepository->countRedirectsByByDemand(); $this->view->assignMultiple([ 'redirects' => $redirectRepository->findRedirectsByDemand(), 'hosts' => $redirectRepository->findHostsOfRedirects(), 'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(), 'demand' => $demand, 'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(), 'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'), 'pagination' => $this->preparePagination($demand, $count), ]); }
php
protected function overviewAction(ServerRequestInterface $request) { $this->getButtons(); $demand = Demand::createFromRequest($request); $redirectRepository = GeneralUtility::makeInstance(RedirectRepository::class, $demand); $count = $redirectRepository->countRedirectsByByDemand(); $this->view->assignMultiple([ 'redirects' => $redirectRepository->findRedirectsByDemand(), 'hosts' => $redirectRepository->findHostsOfRedirects(), 'statusCodes' => $redirectRepository->findStatusCodesOfRedirects(), 'demand' => $demand, 'defaultUrl' => GeneralUtility::makeInstance(UrlService::class)->getDefaultUrl(), 'showHitCounter' => GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount'), 'pagination' => $this->preparePagination($demand, $count), ]); }
[ "protected", "function", "overviewAction", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "this", "->", "getButtons", "(", ")", ";", "$", "demand", "=", "Demand", "::", "createFromRequest", "(", "$", "request", ")", ";", "$", "redirectRepository...
Show all redirects, and add a button to create a new redirect @param ServerRequestInterface $request
[ "Show", "all", "redirects", "and", "add", "a", "button", "to", "create", "a", "new", "redirect" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L99-L115
train
TYPO3-CMS/redirects
Classes/Controller/ManagementController.php
ManagementController.preparePagination
protected function preparePagination(Demand $demand, int $count): array { $numberOfPages = ceil($count / $demand->getLimit()); $endRecord = $demand->getOffset() + $demand->getLimit(); if ($endRecord > $count) { $endRecord = $count; } $pagination = [ 'current' => $demand->getPage(), 'numberOfPages' => $numberOfPages, 'hasLessPages' => $demand->getPage() > 1, 'hasMorePages' => $demand->getPage() < $numberOfPages, 'startRecord' => $demand->getOffset() + 1, 'endRecord' => $endRecord ]; if ($pagination['current'] < $pagination['numberOfPages']) { $pagination['nextPage'] = $pagination['current'] + 1; } if ($pagination['current'] > 1) { $pagination['previousPage'] = $pagination['current'] - 1; } return $pagination; }
php
protected function preparePagination(Demand $demand, int $count): array { $numberOfPages = ceil($count / $demand->getLimit()); $endRecord = $demand->getOffset() + $demand->getLimit(); if ($endRecord > $count) { $endRecord = $count; } $pagination = [ 'current' => $demand->getPage(), 'numberOfPages' => $numberOfPages, 'hasLessPages' => $demand->getPage() > 1, 'hasMorePages' => $demand->getPage() < $numberOfPages, 'startRecord' => $demand->getOffset() + 1, 'endRecord' => $endRecord ]; if ($pagination['current'] < $pagination['numberOfPages']) { $pagination['nextPage'] = $pagination['current'] + 1; } if ($pagination['current'] > 1) { $pagination['previousPage'] = $pagination['current'] - 1; } return $pagination; }
[ "protected", "function", "preparePagination", "(", "Demand", "$", "demand", ",", "int", "$", "count", ")", ":", "array", "{", "$", "numberOfPages", "=", "ceil", "(", "$", "count", "/", "$", "demand", "->", "getLimit", "(", ")", ")", ";", "$", "endRecor...
Prepares information for the pagination of the module @param Demand $demand @param int $count @return array
[ "Prepares", "information", "for", "the", "pagination", "of", "the", "module" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L124-L147
train
TYPO3-CMS/redirects
Classes/Controller/ManagementController.php
ManagementController.getButtons
protected function getButtons() { /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); // Create new $newRecordButton = $buttonBar->makeLinkButton() ->setHref((string)$uriBuilder->buildUriFromRoute( 'record_edit', [ 'edit' => ['sys_redirect' => ['new'], ], 'returnUrl' => (string)$uriBuilder->buildUriFromRoute('site_redirects'), ] )) ->setTitle($this->getLanguageService()->getLL('redirect_add_text')) ->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)); $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10); // Reload $reloadButton = $buttonBar->makeLinkButton() ->setHref(GeneralUtility::getIndpEnv('REQUEST_URI')) ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload')) ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)); $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT); // Shortcut $mayMakeShortcut = $this->getBackendUserAuthentication()->mayMakeShortcut(); if ($mayMakeShortcut) { $getVars = ['id', 'route']; $shortcutButton = $buttonBar->makeShortcutButton() ->setModuleName('site_redirects') ->setGetVariables($getVars); $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT); } }
php
protected function getButtons() { /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); // Create new $newRecordButton = $buttonBar->makeLinkButton() ->setHref((string)$uriBuilder->buildUriFromRoute( 'record_edit', [ 'edit' => ['sys_redirect' => ['new'], ], 'returnUrl' => (string)$uriBuilder->buildUriFromRoute('site_redirects'), ] )) ->setTitle($this->getLanguageService()->getLL('redirect_add_text')) ->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)); $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10); // Reload $reloadButton = $buttonBar->makeLinkButton() ->setHref(GeneralUtility::getIndpEnv('REQUEST_URI')) ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload')) ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)); $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT); // Shortcut $mayMakeShortcut = $this->getBackendUserAuthentication()->mayMakeShortcut(); if ($mayMakeShortcut) { $getVars = ['id', 'route']; $shortcutButton = $buttonBar->makeShortcutButton() ->setModuleName('site_redirects') ->setGetVariables($getVars); $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT); } }
[ "protected", "function", "getButtons", "(", ")", "{", "/** @var UriBuilder $uriBuilder */", "$", "uriBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "UriBuilder", "::", "class", ")", ";", "$", "buttonBar", "=", "$", "this", "->", "moduleTemplate", "->"...
Create document header buttons
[ "Create", "document", "header", "buttons" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Controller/ManagementController.php#L164-L202
train
rinvex/cortex-pages
src/Http/Controllers/Managerarea/PagesController.php
PagesController.import
public function import(Page $page, ImportRecordsDataTable $importRecordsDataTable) { return $importRecordsDataTable->with([ 'resource' => $page, 'tabs' => 'managerarea.pages.tabs', 'url' => route('managerarea.pages.stash'), 'id' => "managerarea-pages-{$page->getRouteKey()}-import-table", ])->render('cortex/foundation::managerarea.pages.datatable-dropzone'); }
php
public function import(Page $page, ImportRecordsDataTable $importRecordsDataTable) { return $importRecordsDataTable->with([ 'resource' => $page, 'tabs' => 'managerarea.pages.tabs', 'url' => route('managerarea.pages.stash'), 'id' => "managerarea-pages-{$page->getRouteKey()}-import-table", ])->render('cortex/foundation::managerarea.pages.datatable-dropzone'); }
[ "public", "function", "import", "(", "Page", "$", "page", ",", "ImportRecordsDataTable", "$", "importRecordsDataTable", ")", "{", "return", "$", "importRecordsDataTable", "->", "with", "(", "[", "'resource'", "=>", "$", "page", ",", "'tabs'", "=>", "'managerarea...
Import pages. @param \Cortex\Pages\Models\Page $page @param \Cortex\Foundation\DataTables\ImportRecordsDataTable $importRecordsDataTable @return \Illuminate\View\View
[ "Import", "pages", "." ]
7229fedb34d352fda0e721f950c55074f0fb0dce
https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Managerarea/PagesController.php#L65-L73
train
rinvex/cortex-pages
src/Http/Controllers/Managerarea/PagesController.php
PagesController.destroy
public function destroy(Page $page) { $page->delete(); return intend([ 'url' => route('managerarea.pages.index'), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/pages::common.page'), 'identifier' => $page->name])], ]); }
php
public function destroy(Page $page) { $page->delete(); return intend([ 'url' => route('managerarea.pages.index'), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/pages::common.page'), 'identifier' => $page->name])], ]); }
[ "public", "function", "destroy", "(", "Page", "$", "page", ")", "{", "$", "page", "->", "delete", "(", ")", ";", "return", "intend", "(", "[", "'url'", "=>", "route", "(", "'managerarea.pages.index'", ")", ",", "'with'", "=>", "[", "'warning'", "=>", "...
Destroy given page. @param \Cortex\Pages\Models\Page $page @throws \Exception @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "Destroy", "given", "page", "." ]
7229fedb34d352fda0e721f950c55074f0fb0dce
https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Managerarea/PagesController.php#L217-L225
train
mmoreram/ControllerExtraBundle
Resolver/EntityAnnotationResolver.php
EntityAnnotationResolver.evaluateMapping
private function evaluateMapping( LoadEntity $annotation, string $entityNamespace ) { if (!empty($annotation->getMapping())) { $mapping = $annotation->getMapping(); $mappingFallback = !is_null($annotation->getMappingFallback()) ? $annotation->getMappingFallback() : $this->mappingFallback; /** * Each value of the mapping array is computed and analyzed. * * If the format is something like %value%, this service will * look for the real request attribute value */ foreach ($mapping as $mappingKey => $mappingValue) { $parameterValue = $this ->providerCollector ->provide($mappingValue); /** * Defined field is not found in current route, and we have * enabled the "mapping fallback" setting. In that case we * assume that the mapping definition is wrong, and we return * the entity itself. */ if ($mappingFallback && ($parameterValue === $mappingValue)) { return null; } $mapping[$mappingKey] = $parameterValue; } $instance = $this ->resolveRepositoryLookup( $annotation, $entityNamespace, $mapping ); if (!$instance instanceof $entityNamespace) { throw new EntityNotFoundException( 'Entity of type ' . $entityNamespace . ' with mapping ' . json_encode($mapping) . ' was not found.' ); } return $instance; } return null; }
php
private function evaluateMapping( LoadEntity $annotation, string $entityNamespace ) { if (!empty($annotation->getMapping())) { $mapping = $annotation->getMapping(); $mappingFallback = !is_null($annotation->getMappingFallback()) ? $annotation->getMappingFallback() : $this->mappingFallback; /** * Each value of the mapping array is computed and analyzed. * * If the format is something like %value%, this service will * look for the real request attribute value */ foreach ($mapping as $mappingKey => $mappingValue) { $parameterValue = $this ->providerCollector ->provide($mappingValue); /** * Defined field is not found in current route, and we have * enabled the "mapping fallback" setting. In that case we * assume that the mapping definition is wrong, and we return * the entity itself. */ if ($mappingFallback && ($parameterValue === $mappingValue)) { return null; } $mapping[$mappingKey] = $parameterValue; } $instance = $this ->resolveRepositoryLookup( $annotation, $entityNamespace, $mapping ); if (!$instance instanceof $entityNamespace) { throw new EntityNotFoundException( 'Entity of type ' . $entityNamespace . ' with mapping ' . json_encode($mapping) . ' was not found.' ); } return $instance; } return null; }
[ "private", "function", "evaluateMapping", "(", "LoadEntity", "$", "annotation", ",", "string", "$", "entityNamespace", ")", "{", "if", "(", "!", "empty", "(", "$", "annotation", "->", "getMapping", "(", ")", ")", ")", "{", "$", "mapping", "=", "$", "anno...
Resolve doctrine mapping and return entity given or mapped instance. @param LoadEntity $annotation @param string $entityNamespace @return null|object @throws EntityNotFoundException
[ "Resolve", "doctrine", "mapping", "and", "return", "entity", "given", "or", "mapped", "instance", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L189-L241
train
mmoreram/ControllerExtraBundle
Resolver/EntityAnnotationResolver.php
EntityAnnotationResolver.evaluateSetters
private function evaluateSetters( ParameterBag $attributes, $entity, array $setters ) { foreach ($setters as $method => $value) { $entity->$method($attributes->get($value)); } }
php
private function evaluateSetters( ParameterBag $attributes, $entity, array $setters ) { foreach ($setters as $method => $value) { $entity->$method($attributes->get($value)); } }
[ "private", "function", "evaluateSetters", "(", "ParameterBag", "$", "attributes", ",", "$", "entity", ",", "array", "$", "setters", ")", "{", "foreach", "(", "$", "setters", "as", "$", "method", "=>", "$", "value", ")", "{", "$", "entity", "->", "$", "...
Evaluate setters. @param ParameterBag $attributes @param object $entity @param array $setters
[ "Evaluate", "setters", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L250-L258
train
mmoreram/ControllerExtraBundle
Resolver/EntityAnnotationResolver.php
EntityAnnotationResolver.resolveRepositoryLookup
private function resolveRepositoryLookup( LoadEntity $annotation, string $entityClass, array $mapping ) { $annotationRepository = $annotation->getRepository(); $annotationHasRepository = !is_null($annotationRepository) && is_array($annotationRepository); if ($annotationHasRepository) { $class = $annotation->getRepository()['class']; $repository = $this ->container ->has($class) ? $this ->container ->get($class) : new $class(); } else { $repository = $this ->doctrine ->getManagerForClass($entityClass) ->getRepository($entityClass); } $method = $annotationHasRepository && isset($annotationRepository['method']) ? $annotationRepository['method'] : 'findOneBy'; return $repository->$method($mapping); }
php
private function resolveRepositoryLookup( LoadEntity $annotation, string $entityClass, array $mapping ) { $annotationRepository = $annotation->getRepository(); $annotationHasRepository = !is_null($annotationRepository) && is_array($annotationRepository); if ($annotationHasRepository) { $class = $annotation->getRepository()['class']; $repository = $this ->container ->has($class) ? $this ->container ->get($class) : new $class(); } else { $repository = $this ->doctrine ->getManagerForClass($entityClass) ->getRepository($entityClass); } $method = $annotationHasRepository && isset($annotationRepository['method']) ? $annotationRepository['method'] : 'findOneBy'; return $repository->$method($mapping); }
[ "private", "function", "resolveRepositoryLookup", "(", "LoadEntity", "$", "annotation", ",", "string", "$", "entityClass", ",", "array", "$", "mapping", ")", "{", "$", "annotationRepository", "=", "$", "annotation", "->", "getRepository", "(", ")", ";", "$", "...
Resolve repository lookup. @param LoadEntity $annotation @param string $entityClass @param array $mapping @return object|null
[ "Resolve", "repository", "lookup", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L269-L297
train
mmoreram/ControllerExtraBundle
Resolver/EntityAnnotationResolver.php
EntityAnnotationResolver.resolvePersist
private function resolvePersist(LoadEntity $annotation, $entity) { /** * Persist block. * * This block defines if entity must be persisted using desired * manager. * * Given the entity we can find which manager manages it * * Same logic in perisist option. This variable is defined in bundle * parameters and can be overwritten there. Can also be defined in * every single annotation */ /** * Get the persist variable. If not defined, is set as defined in * parameters. */ $persist = !is_null($annotation->getPersist()) ? $annotation->getPersist() : $this->defaultPersist; if ($persist) { /** * Loading locally desired Doctrine manager. */ $this ->doctrine ->getManagerForClass(get_class($entity)) ->persist($entity); } }
php
private function resolvePersist(LoadEntity $annotation, $entity) { /** * Persist block. * * This block defines if entity must be persisted using desired * manager. * * Given the entity we can find which manager manages it * * Same logic in perisist option. This variable is defined in bundle * parameters and can be overwritten there. Can also be defined in * every single annotation */ /** * Get the persist variable. If not defined, is set as defined in * parameters. */ $persist = !is_null($annotation->getPersist()) ? $annotation->getPersist() : $this->defaultPersist; if ($persist) { /** * Loading locally desired Doctrine manager. */ $this ->doctrine ->getManagerForClass(get_class($entity)) ->persist($entity); } }
[ "private", "function", "resolvePersist", "(", "LoadEntity", "$", "annotation", ",", "$", "entity", ")", "{", "/**\n * Persist block.\n *\n * This block defines if entity must be persisted using desired\n * manager.\n *\n * Given the entity we c...
Persist block. This block defines if entity must be persisted using desired manager. This manager is defined as default in bundle parameters, but can be overwritten in each annotation Same logic in perisist option. This variable is defined in bundle parameters and can be overwritten there. Can also be defined in every single annotation @param LoadEntity $annotation @param object $entity
[ "Persist", "block", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/EntityAnnotationResolver.php#L315-L348
train
QoboLtd/cakephp-search
src/Utility/Export.php
Export.execute
public function execute(int $page, int $limit): void { $page = $page <= 1 ? 1 : $page; $rows = $this->getRows($page, $limit); $headers = []; $mode = 'a'; if (1 === $page) { $headers = $this->getHeaders(); $mode = 'w'; } // Prepend columns to result if (!empty($headers)) { array_unshift($rows, $headers); } $this->create($rows, $mode); }
php
public function execute(int $page, int $limit): void { $page = $page <= 1 ? 1 : $page; $rows = $this->getRows($page, $limit); $headers = []; $mode = 'a'; if (1 === $page) { $headers = $this->getHeaders(); $mode = 'w'; } // Prepend columns to result if (!empty($headers)) { array_unshift($rows, $headers); } $this->create($rows, $mode); }
[ "public", "function", "execute", "(", "int", "$", "page", ",", "int", "$", "limit", ")", ":", "void", "{", "$", "page", "=", "$", "page", "<=", "1", "?", "1", ":", "$", "page", ";", "$", "rows", "=", "$", "this", "->", "getRows", "(", "$", "p...
Execute export. @param int $page Pagination page @param int $limit Pagination limit @return void
[ "Execute", "export", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L123-L141
train
QoboLtd/cakephp-search
src/Utility/Export.php
Export.getRows
protected function getRows(int $page, int $limit): array { $displayColumns = $this->getDisplayColumns(); if (empty($displayColumns)) { return []; } $query = $this->query->page($page, $limit); $entities = $query->all(); if ($entities->isEmpty()) { return []; } $table = TableRegistry::get($this->search->get('model')); $event = new Event((string)EventName::MODEL_SEARCH_AFTER_FIND(), $this, [ 'entities' => $entities, 'table' => $table ]); EventManager::instance()->dispatch($event); if ($event->result) { $entities = $event->result; } $displayColumns = array_map('strval', $displayColumns); $entities = $entities ? Utility::instance()->toCsv($entities, $displayColumns, $table) : []; if (empty($entities)) { return []; } $result = []; foreach ($entities as $k => $entity) { $result[$k] = []; foreach ($displayColumns as $column) { $value = trim(strip_tags(html_entity_decode($entity[$column], ENT_QUOTES)), " \t\n\r\0\x0B\xC2\xA0"); $result[$k][] = $value; } } return $result; }
php
protected function getRows(int $page, int $limit): array { $displayColumns = $this->getDisplayColumns(); if (empty($displayColumns)) { return []; } $query = $this->query->page($page, $limit); $entities = $query->all(); if ($entities->isEmpty()) { return []; } $table = TableRegistry::get($this->search->get('model')); $event = new Event((string)EventName::MODEL_SEARCH_AFTER_FIND(), $this, [ 'entities' => $entities, 'table' => $table ]); EventManager::instance()->dispatch($event); if ($event->result) { $entities = $event->result; } $displayColumns = array_map('strval', $displayColumns); $entities = $entities ? Utility::instance()->toCsv($entities, $displayColumns, $table) : []; if (empty($entities)) { return []; } $result = []; foreach ($entities as $k => $entity) { $result[$k] = []; foreach ($displayColumns as $column) { $value = trim(strip_tags(html_entity_decode($entity[$column], ENT_QUOTES)), " \t\n\r\0\x0B\xC2\xA0"); $result[$k][] = $value; } } return $result; }
[ "protected", "function", "getRows", "(", "int", "$", "page", ",", "int", "$", "limit", ")", ":", "array", "{", "$", "displayColumns", "=", "$", "this", "->", "getDisplayColumns", "(", ")", ";", "if", "(", "empty", "(", "$", "displayColumns", ")", ")", ...
Get export rows. @param int $page Pagination page @param int $limit Pagination limit @return mixed[]
[ "Get", "export", "rows", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L160-L201
train
QoboLtd/cakephp-search
src/Utility/Export.php
Export.getHeaders
protected function getHeaders(): array { $displayColumns = $this->getDisplayColumns(); if (empty($displayColumns)) { return []; } $table = TableRegistry::get($this->search->get('model')); $associationLabels = Utility::instance()->getAssociationLabels($table); $searchableFields = Utility::instance()->getSearchableFields($table, $this->user); $result = []; foreach ($displayColumns as $column) { $label = $column; if (array_key_exists($label, $searchableFields)) { $label = $searchableFields[$label]['label']; } list($fieldModel, ) = pluginSplit($column); if (array_key_exists($fieldModel, $associationLabels)) { $label .= ' (' . $associationLabels[$fieldModel] . ')'; } $result[] = $label; } return $result; }
php
protected function getHeaders(): array { $displayColumns = $this->getDisplayColumns(); if (empty($displayColumns)) { return []; } $table = TableRegistry::get($this->search->get('model')); $associationLabels = Utility::instance()->getAssociationLabels($table); $searchableFields = Utility::instance()->getSearchableFields($table, $this->user); $result = []; foreach ($displayColumns as $column) { $label = $column; if (array_key_exists($label, $searchableFields)) { $label = $searchableFields[$label]['label']; } list($fieldModel, ) = pluginSplit($column); if (array_key_exists($fieldModel, $associationLabels)) { $label .= ' (' . $associationLabels[$fieldModel] . ')'; } $result[] = $label; } return $result; }
[ "protected", "function", "getHeaders", "(", ")", ":", "array", "{", "$", "displayColumns", "=", "$", "this", "->", "getDisplayColumns", "(", ")", ";", "if", "(", "empty", "(", "$", "displayColumns", ")", ")", "{", "return", "[", "]", ";", "}", "$", "...
Get export headers. @return mixed[]
[ "Get", "export", "headers", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L208-L237
train
QoboLtd/cakephp-search
src/Utility/Export.php
Export.create
protected function create(array $data, string $mode = 'a'): void { // create file path $file = new File($this->path, true); // skip if file is not writable if (! $file->writable()) { $this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR); return; } /** * @var resource */ $handler = fopen($file->pwd(), $mode); if (! is_resource($handler)) { $this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR); } foreach ($data as $row) { if (false === fputcsv($handler, $row)) { $this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR); return; } } fclose($handler); }
php
protected function create(array $data, string $mode = 'a'): void { // create file path $file = new File($this->path, true); // skip if file is not writable if (! $file->writable()) { $this->log(sprintf('Export file is not writable: %s', $file->pwd()), LogLevel::ERROR); return; } /** * @var resource */ $handler = fopen($file->pwd(), $mode); if (! is_resource($handler)) { $this->log(sprintf('Export interrupted: failed to bind resource to a stream'), LogLevel::ERROR); } foreach ($data as $row) { if (false === fputcsv($handler, $row)) { $this->log(sprintf('Export interrupted: failed to write data into the file'), LogLevel::ERROR); return; } } fclose($handler); }
[ "protected", "function", "create", "(", "array", "$", "data", ",", "string", "$", "mode", "=", "'a'", ")", ":", "void", "{", "// create file path", "$", "file", "=", "new", "File", "(", "$", "this", "->", "path", ",", "true", ")", ";", "// skip if file...
Create export file. @param mixed[] $data CSV data @param string $mode File mode @return void
[ "Create", "export", "file", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Export.php#L271-L300
train
mmoreram/ControllerExtraBundle
Provider/EntityProvider.php
EntityProvider.create
public function create(AnnotationWithEntityReference $annotation) { return null !== $annotation->getFactory() ? $this->evaluateEntityInstanceFactory($annotation->getFactory()) : $this->evaluateEntityInstanceNamespace($annotation->getNamespace()); }
php
public function create(AnnotationWithEntityReference $annotation) { return null !== $annotation->getFactory() ? $this->evaluateEntityInstanceFactory($annotation->getFactory()) : $this->evaluateEntityInstanceNamespace($annotation->getNamespace()); }
[ "public", "function", "create", "(", "AnnotationWithEntityReference", "$", "annotation", ")", "{", "return", "null", "!==", "$", "annotation", "->", "getFactory", "(", ")", "?", "$", "this", "->", "evaluateEntityInstanceFactory", "(", "$", "annotation", "->", "g...
Class provider, given several formats. Accepted formats: class = "my.class.parameter", class = "\My\Class\Namespace", class = "MmoreramCustomBundle:User", factory = { "factory": "Mmoreram\ControllerExtraBundle\Factory\EntityFactory", "factory": "my_factory_service", "method": "create", "static": true } @param AnnotationWithEntityReference $annotation @return object|null
[ "Class", "provider", "given", "several", "formats", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L101-L106
train
mmoreram/ControllerExtraBundle
Provider/EntityProvider.php
EntityProvider.evaluateEntityInstanceFactory
public function evaluateEntityInstanceFactory(array $factory) { if (!isset($factory['class'])) { throw new InvalidArgumentException(); } $factoryReference = $factory['class']; $factoryMethod = isset($factory['method']) ? $factory['method'] : $this->defaultFactoryMethod; $factoryStatic = isset($factory['static']) ? (bool) $factory['static'] : (bool) $this->defaultFactoryStatic; $factory = class_exists($factoryReference) ? ( $factoryStatic ? $factoryReference : new $factoryReference() ) : $this ->container ->get($factoryReference); return $factoryStatic ? $factory::$factoryMethod() : $factory->$factoryMethod(); }
php
public function evaluateEntityInstanceFactory(array $factory) { if (!isset($factory['class'])) { throw new InvalidArgumentException(); } $factoryReference = $factory['class']; $factoryMethod = isset($factory['method']) ? $factory['method'] : $this->defaultFactoryMethod; $factoryStatic = isset($factory['static']) ? (bool) $factory['static'] : (bool) $this->defaultFactoryStatic; $factory = class_exists($factoryReference) ? ( $factoryStatic ? $factoryReference : new $factoryReference() ) : $this ->container ->get($factoryReference); return $factoryStatic ? $factory::$factoryMethod() : $factory->$factoryMethod(); }
[ "public", "function", "evaluateEntityInstanceFactory", "(", "array", "$", "factory", ")", "{", "if", "(", "!", "isset", "(", "$", "factory", "[", "'class'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", ")", ";", "}", "$", "factoryRe...
Evaluates entity instance using a factory. @param array $factory @return object Entity instance @throws InvalidArgumentException if the service is not defined @throws ServiceCircularReferenceException When a circular reference is detected @throws ServiceNotFoundException When the service is not found
[ "Evaluates", "entity", "instance", "using", "a", "factory", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L119-L148
train
mmoreram/ControllerExtraBundle
Provider/EntityProvider.php
EntityProvider.evaluateEntityNamespace
public function evaluateEntityNamespace(string $namespace) { /** * Trying to generate new entity given that the class is the entity * namespace. */ if (class_exists($namespace)) { return $namespace; } /** * Trying to generate new entity given that the namespace is defined in * as a Container parameter. */ $container = $this->container; if ( $container->hasParameter($namespace) && class_exists($container->getParameter($namespace)) ) { $namespaceParameter = $container->getParameter($namespace); return $namespaceParameter; } $resolvedNamespace = explode(':', $namespace, 2); $bundles = $this->kernel->getBundles(); /** * Trying to get entity using Doctrine short format. * * MyBundle:MyEntity * * To accept this format, entities must be at Entity/ folder in the * bundle root dir * * /MyBundle/Entity/MyEntity * * If entity definition is wrong, throw exception * If bundle not exists or is not actived, throw Exception */ if ( !( isset($resolvedNamespace[0]) && isset($bundles[$resolvedNamespace[0]]) && $bundles[$resolvedNamespace[0]] instanceof Bundle && isset($resolvedNamespace[1]) ) ) { throw new ClassNotFoundException( $namespace, new ErrorException() ); } /** * @var Bundle $bundle */ $bundle = $bundles[$resolvedNamespace[0]]; $bundleNamespace = $bundle->getNamespace(); $namespace = $bundleNamespace . '\\Entity\\' . $resolvedNamespace[1]; if (!class_exists($namespace)) { throw new ClassNotFoundException( $namespace, new ErrorException() ); } /** * Otherwise, assume that class is namespace of class. */ return $namespace; }
php
public function evaluateEntityNamespace(string $namespace) { /** * Trying to generate new entity given that the class is the entity * namespace. */ if (class_exists($namespace)) { return $namespace; } /** * Trying to generate new entity given that the namespace is defined in * as a Container parameter. */ $container = $this->container; if ( $container->hasParameter($namespace) && class_exists($container->getParameter($namespace)) ) { $namespaceParameter = $container->getParameter($namespace); return $namespaceParameter; } $resolvedNamespace = explode(':', $namespace, 2); $bundles = $this->kernel->getBundles(); /** * Trying to get entity using Doctrine short format. * * MyBundle:MyEntity * * To accept this format, entities must be at Entity/ folder in the * bundle root dir * * /MyBundle/Entity/MyEntity * * If entity definition is wrong, throw exception * If bundle not exists or is not actived, throw Exception */ if ( !( isset($resolvedNamespace[0]) && isset($bundles[$resolvedNamespace[0]]) && $bundles[$resolvedNamespace[0]] instanceof Bundle && isset($resolvedNamespace[1]) ) ) { throw new ClassNotFoundException( $namespace, new ErrorException() ); } /** * @var Bundle $bundle */ $bundle = $bundles[$resolvedNamespace[0]]; $bundleNamespace = $bundle->getNamespace(); $namespace = $bundleNamespace . '\\Entity\\' . $resolvedNamespace[1]; if (!class_exists($namespace)) { throw new ClassNotFoundException( $namespace, new ErrorException() ); } /** * Otherwise, assume that class is namespace of class. */ return $namespace; }
[ "public", "function", "evaluateEntityNamespace", "(", "string", "$", "namespace", ")", "{", "/**\n * Trying to generate new entity given that the class is the entity\n * namespace.\n */", "if", "(", "class_exists", "(", "$", "namespace", ")", ")", "{", "...
Evaluates entity instance using the namespace. @param string $namespace @return string @throws ClassNotFoundException if class is not found
[ "Evaluates", "entity", "instance", "using", "the", "namespace", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Provider/EntityProvider.php#L175-L248
train
hiqdev/hipanel-module-finance
src/cart/AbstractPurchase.php
AbstractPurchase.execute
public function execute() { if ($this->validate()) { $this->_result = static::perform(static::operation(), $this->getAttributes()); return true; } return false; }
php
public function execute() { if ($this->validate()) { $this->_result = static::perform(static::operation(), $this->getAttributes()); return true; } return false; }
[ "public", "function", "execute", "(", ")", "{", "if", "(", "$", "this", "->", "validate", "(", ")", ")", "{", "$", "this", "->", "_result", "=", "static", "::", "perform", "(", "static", "::", "operation", "(", ")", ",", "$", "this", "->", "getAttr...
Executes the purchase. Calls proper API commands to purchase the product. @throws ErrorPurchaseException in case of failed purchase @return true if the item was purchased successfully
[ "Executes", "the", "purchase", ".", "Calls", "proper", "API", "commands", "to", "purchase", "the", "product", "." ]
fa027420ddc1d6de22a6d830e14dde587c837220
https://github.com/hiqdev/hipanel-module-finance/blob/fa027420ddc1d6de22a6d830e14dde587c837220/src/cart/AbstractPurchase.php#L76-L85
train
TYPO3-CMS/redirects
Classes/Evaluation/SourceHost.php
SourceHost.evaluateFieldValue
public function evaluateFieldValue(string $value): string { // 1) Special case: * means any domain if ($value === '*') { return $value; } // 2) Check if value contains a protocol like http:// https:// etc... if (strpos($value, '://') !== false) { $tmp = $this->parseUrl($value); if (!empty($tmp)) { return $tmp; } } // 3) Check domain name // remove anything after the first "/" $checkValue = $value; if (strpos($value, '/') !== false) { $checkValue = substr($value, 0, strpos($value, '/')); } $validHostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/'; if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) { if (!empty($matches)) { return $checkValue; } } // 4) IPv4 or IPv6 $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value; if ($isIP) { return $value; } return ''; }
php
public function evaluateFieldValue(string $value): string { // 1) Special case: * means any domain if ($value === '*') { return $value; } // 2) Check if value contains a protocol like http:// https:// etc... if (strpos($value, '://') !== false) { $tmp = $this->parseUrl($value); if (!empty($tmp)) { return $tmp; } } // 3) Check domain name // remove anything after the first "/" $checkValue = $value; if (strpos($value, '/') !== false) { $checkValue = substr($value, 0, strpos($value, '/')); } $validHostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/'; if (preg_match_all($validHostnameRegex, $checkValue, $matches, PREG_SET_ORDER) !== false) { if (!empty($matches)) { return $checkValue; } } // 4) IPv4 or IPv6 $isIP = filter_var($value, FILTER_VALIDATE_IP) === $value; if ($isIP) { return $value; } return ''; }
[ "public", "function", "evaluateFieldValue", "(", "string", "$", "value", ")", ":", "string", "{", "// 1) Special case: * means any domain", "if", "(", "$", "value", "===", "'*'", ")", "{", "return", "$", "value", ";", "}", "// 2) Check if value contains a protocol l...
Server-side removing of protocol on save @param string $value The field value to be evaluated @return string Evaluated field value
[ "Server", "-", "side", "removing", "of", "protocol", "on", "save" ]
c617ec21dac92873bf9890fa0bfc1576afc86b5a
https://github.com/TYPO3-CMS/redirects/blob/c617ec21dac92873bf9890fa0bfc1576afc86b5a/Classes/Evaluation/SourceHost.php#L47-L82
train
mmoreram/ControllerExtraBundle
Resolver/JsonResponseAnnotationResolver.php
JsonResponseAnnotationResolver.createJsonResponseIfNeeded
private function createJsonResponseIfNeeded( GetResponseEvent $event, $result ) { /** * Only flushes if exists AnnotationFlush as a controller annotations. */ if ($this->returnJson) { if ($result instanceof Exception) { $this->status = $result instanceof HttpExceptionInterface ? $result->getStatusCode() : $this->defaultErrorStatus; $result = [ 'code' => $result->getCode(), 'namespace' => get_class($result), 'message' => $result->getMessage(), ]; } $response = JsonResponse::create( $result, $this->status, $this->headers ); $event->setResponse($response); } }
php
private function createJsonResponseIfNeeded( GetResponseEvent $event, $result ) { /** * Only flushes if exists AnnotationFlush as a controller annotations. */ if ($this->returnJson) { if ($result instanceof Exception) { $this->status = $result instanceof HttpExceptionInterface ? $result->getStatusCode() : $this->defaultErrorStatus; $result = [ 'code' => $result->getCode(), 'namespace' => get_class($result), 'message' => $result->getMessage(), ]; } $response = JsonResponse::create( $result, $this->status, $this->headers ); $event->setResponse($response); } }
[ "private", "function", "createJsonResponseIfNeeded", "(", "GetResponseEvent", "$", "event", ",", "$", "result", ")", "{", "/**\n * Only flushes if exists AnnotationFlush as a controller annotations.\n */", "if", "(", "$", "this", "->", "returnJson", ")", "{", ...
Create new Json Response if needed. @param GetResponseEvent $event @param mixed $result
[ "Create", "new", "Json", "Response", "if", "needed", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/JsonResponseAnnotationResolver.php#L154-L182
train
MetaModels/filter_perimetersearch
src/EventListener/DcGeneral/Table/FilterSetting/Base.php
Base.isAllowedProperty
protected function isAllowedProperty($event, $dataDefinitionName, $properties) { if ($event->getEnvironment()->getDataDefinition()->getName() !== $dataDefinitionName) { return false; } if (!\in_array($event->getPropertyName(), $properties)) { return false; } return true; }
php
protected function isAllowedProperty($event, $dataDefinitionName, $properties) { if ($event->getEnvironment()->getDataDefinition()->getName() !== $dataDefinitionName) { return false; } if (!\in_array($event->getPropertyName(), $properties)) { return false; } return true; }
[ "protected", "function", "isAllowedProperty", "(", "$", "event", ",", "$", "dataDefinitionName", ",", "$", "properties", ")", "{", "if", "(", "$", "event", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getName", "(", ")", "!...
Check if the current context is valid. @param GetPropertyOptionsEvent|GetOptionsEvent $event The event. @param string $dataDefinitionName The allowed name of the data definition. @param array $properties A list of allowed properties. @return bool
[ "Check", "if", "the", "current", "context", "is", "valid", "." ]
953d55881a1855972c5f47a7552863986702163c
https://github.com/MetaModels/filter_perimetersearch/blob/953d55881a1855972c5f47a7552863986702163c/src/EventListener/DcGeneral/Table/FilterSetting/Base.php#L59-L70
train
QoboLtd/cakephp-search
src/Utility/Options.php
Options.getDefaults
public static function getDefaults(RepositoryInterface $table): array { $result['display_columns'] = static::getListingFields($table); $result['sort_by_field'] = current($result['display_columns']); $result['sort_by_order'] = static::DEFAULT_SORT_BY_ORDER; $result['aggregator'] = static::DEFAULT_AGGREGATOR; return $result; }
php
public static function getDefaults(RepositoryInterface $table): array { $result['display_columns'] = static::getListingFields($table); $result['sort_by_field'] = current($result['display_columns']); $result['sort_by_order'] = static::DEFAULT_SORT_BY_ORDER; $result['aggregator'] = static::DEFAULT_AGGREGATOR; return $result; }
[ "public", "static", "function", "getDefaults", "(", "RepositoryInterface", "$", "table", ")", ":", "array", "{", "$", "result", "[", "'display_columns'", "]", "=", "static", "::", "getListingFields", "(", "$", "table", ")", ";", "$", "result", "[", "'sort_by...
Default search options. @param \Cake\Datasource\RepositoryInterface $table Table instance @return mixed[]
[ "Default", "search", "options", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L146-L154
train
QoboLtd/cakephp-search
src/Utility/Options.php
Options.getListingFields
public static function getListingFields(RepositoryInterface $table): array { // broadcast event to fetch display fields $event = new Event((string)EventName::MODEL_SEARCH_DISPLAY_FIELDS(), null, [ 'table' => $table ]); EventManager::instance()->dispatch($event); $result = (array)$event->result; if (empty($result)) { $result = static::getDefaultDisplayFields($table); } $result = array_diff($result, static::getSkippedDisplayFields($table, true)); // reset numeric indexes return array_values($result); }
php
public static function getListingFields(RepositoryInterface $table): array { // broadcast event to fetch display fields $event = new Event((string)EventName::MODEL_SEARCH_DISPLAY_FIELDS(), null, [ 'table' => $table ]); EventManager::instance()->dispatch($event); $result = (array)$event->result; if (empty($result)) { $result = static::getDefaultDisplayFields($table); } $result = array_diff($result, static::getSkippedDisplayFields($table, true)); // reset numeric indexes return array_values($result); }
[ "public", "static", "function", "getListingFields", "(", "RepositoryInterface", "$", "table", ")", ":", "array", "{", "// broadcast event to fetch display fields", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::", "MODEL_SEARCH_DISPLAY_FIE...
Current table display fields getter. @param \Cake\Datasource\RepositoryInterface $table Table instance @return mixed[]
[ "Current", "table", "display", "fields", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L162-L180
train
QoboLtd/cakephp-search
src/Utility/Options.php
Options.getDefaultDisplayFields
protected static function getDefaultDisplayFields(RepositoryInterface $table): array { /** @var \Cake\ORM\Table */ $table = $table; $result = (array)$table->getPrimaryKey(); array_push($result, $table->getDisplayField()); $result = array_merge($result, static::$defaultDisplayFields); // remove virtual fields foreach ($result as $k => $field) { if (!$table->hasField($field)) { unset($result[$k]); } } // alias fields foreach ($result as $k => $field) { $result[$k] = $table->aliasField($field); } return $result; }
php
protected static function getDefaultDisplayFields(RepositoryInterface $table): array { /** @var \Cake\ORM\Table */ $table = $table; $result = (array)$table->getPrimaryKey(); array_push($result, $table->getDisplayField()); $result = array_merge($result, static::$defaultDisplayFields); // remove virtual fields foreach ($result as $k => $field) { if (!$table->hasField($field)) { unset($result[$k]); } } // alias fields foreach ($result as $k => $field) { $result[$k] = $table->aliasField($field); } return $result; }
[ "protected", "static", "function", "getDefaultDisplayFields", "(", "RepositoryInterface", "$", "table", ")", ":", "array", "{", "/** @var \\Cake\\ORM\\Table */", "$", "table", "=", "$", "table", ";", "$", "result", "=", "(", "array", ")", "$", "table", "->", "...
Default display fields getter. @param \Cake\Datasource\RepositoryInterface $table Table instance @return mixed[]
[ "Default", "display", "fields", "getter", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Options.php#L188-L211
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.icon
public function icon() { $url = $this->_stub['website']; if (!$url) { return null; } $pieces = parse_url($url); $url = $pieces['host']; $icon = 'http://www.google.com/s2/favicons?domain='; $icon .= $url; $context = stream_context_create( ['http' => ['header' => 'Connection: close']]); // E.g. http://www.google.com/s2/favicons?domain=xyz.com $file = file_get_contents($icon, false, $context); if ($file === false) { return null; } // TODO: transform into 16x16 png return $file; }
php
public function icon() { $url = $this->_stub['website']; if (!$url) { return null; } $pieces = parse_url($url); $url = $pieces['host']; $icon = 'http://www.google.com/s2/favicons?domain='; $icon .= $url; $context = stream_context_create( ['http' => ['header' => 'Connection: close']]); // E.g. http://www.google.com/s2/favicons?domain=xyz.com $file = file_get_contents($icon, false, $context); if ($file === false) { return null; } // TODO: transform into 16x16 png return $file; }
[ "public", "function", "icon", "(", ")", "{", "$", "url", "=", "$", "this", "->", "_stub", "[", "'website'", "]", ";", "if", "(", "!", "$", "url", ")", "{", "return", "null", ";", "}", "$", "pieces", "=", "parse_url", "(", "$", "url", ")", ";", ...
Returns a png img @return string|null Resource content or null if not available
[ "Returns", "a", "png", "img" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L187-L208
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.setParam
public function setParam($param, $value = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if (is_array($param)) { foreach ($param as $p => $v) { $this->_iframeParams[$p] = $v; } } else { $this->_iframeParams[$param] = $value; } } else { if (is_array($param)) { foreach ($param as $p => $v) { $this->_objectParams[$p] = $v; } } else { $this->_objectParams[$param] = $value; } } return $this; }
php
public function setParam($param, $value = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if (is_array($param)) { foreach ($param as $p => $v) { $this->_iframeParams[$p] = $v; } } else { $this->_iframeParams[$param] = $value; } } else { if (is_array($param)) { foreach ($param as $p => $v) { $this->_objectParams[$p] = $v; } } else { $this->_objectParams[$param] = $value; } } return $this; }
[ "public", "function", "setParam", "(", "$", "param", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_stub", "[", "'iframe-player'", "]", ")", "&&", "$", "this", "->", "config", "[", "'prefer'", "]", "===...
Override a default object param value @param mixed $param The name of the param to be set or an array of multiple params to set @param string|null $value (optional) the value to set the param to if only one param is being set @return $this
[ "Override", "a", "default", "object", "param", "value" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L243-L264
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.setAttribute
public function setAttribute($param, $value = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if (is_array($param)) { foreach ($param as $p => $v) { $this->_iframeAttributes[$p] = $v; } } else { $this->_iframeAttributes[$param] = $value; } } else { if (is_array($param)) { foreach ($param as $p => $v) { $this->_objectAttributes[$p] = $v; } } else { $this->_objectAttributes[$param] = $value; } } return $this; }
php
public function setAttribute($param, $value = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if (is_array($param)) { foreach ($param as $p => $v) { $this->_iframeAttributes[$p] = $v; } } else { $this->_iframeAttributes[$param] = $value; } } else { if (is_array($param)) { foreach ($param as $p => $v) { $this->_objectAttributes[$p] = $v; } } else { $this->_objectAttributes[$param] = $value; } } return $this; }
[ "public", "function", "setAttribute", "(", "$", "param", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_stub", "[", "'iframe-player'", "]", ")", "&&", "$", "this", "->", "config", "[", "'prefer'", "]", ...
Override a default object attribute value @param mixed $param The name of the attribute to be set or an array of multiple attribs to be set @param string|int|null $value (optional) the value to set the param to if only one param is being set @return $this
[ "Override", "a", "default", "object", "attribute", "value" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L275-L296
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.setHeight
public function setHeight($height, $adjustWidth = false) { if ($adjustWidth && is_numeric($height)) { $this->_adjustDimensions('width', 'height', $height); } return $this->setAttribute('height', $height); }
php
public function setHeight($height, $adjustWidth = false) { if ($adjustWidth && is_numeric($height)) { $this->_adjustDimensions('width', 'height', $height); } return $this->setAttribute('height', $height); }
[ "public", "function", "setHeight", "(", "$", "height", ",", "$", "adjustWidth", "=", "false", ")", "{", "if", "(", "$", "adjustWidth", "&&", "is_numeric", "(", "$", "height", ")", ")", "{", "$", "this", "->", "_adjustDimensions", "(", "'width'", ",", "...
Set the height of the object @param mixed $height Height to set the object to @param bool $adjustWidth @return $this
[ "Set", "the", "height", "of", "the", "object" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L305-L310
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.setWidth
public function setWidth($width, $adjustHeight = false) { if ($adjustHeight && is_numeric($width)) { $this->_adjustDimensions('height', 'width', $width); } return $this->setAttribute('width', $width); }
php
public function setWidth($width, $adjustHeight = false) { if ($adjustHeight && is_numeric($width)) { $this->_adjustDimensions('height', 'width', $width); } return $this->setAttribute('width', $width); }
[ "public", "function", "setWidth", "(", "$", "width", ",", "$", "adjustHeight", "=", "false", ")", "{", "if", "(", "$", "adjustHeight", "&&", "is_numeric", "(", "$", "width", ")", ")", "{", "$", "this", "->", "_adjustDimensions", "(", "'height'", ",", "...
Set the width of the object @param mixed $width Width to set the object to @param bool $adjustHeight @return $this
[ "Set", "the", "width", "of", "the", "object" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L319-L324
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject._adjustDimensions
protected function _adjustDimensions($type, $fromType, $fromLength) { $currentLength = $this->getAttributes($type); $currentFromLength = $this->getAttributes($fromType); $ratio = $fromLength / $currentFromLength; $newLength = $currentLength * $ratio; $this->setAttribute($type, (int)$newLength); }
php
protected function _adjustDimensions($type, $fromType, $fromLength) { $currentLength = $this->getAttributes($type); $currentFromLength = $this->getAttributes($fromType); $ratio = $fromLength / $currentFromLength; $newLength = $currentLength * $ratio; $this->setAttribute($type, (int)$newLength); }
[ "protected", "function", "_adjustDimensions", "(", "$", "type", ",", "$", "fromType", ",", "$", "fromLength", ")", "{", "$", "currentLength", "=", "$", "this", "->", "getAttributes", "(", "$", "type", ")", ";", "$", "currentFromLength", "=", "$", "this", ...
Auto-adjusts one dimension from the other to keep the current ratio. @param string $type @param string $fromType @param int $fromLength @return void
[ "Auto", "-", "adjusts", "one", "dimension", "from", "the", "other", "to", "keep", "the", "current", "ratio", "." ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L334-L342
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.getParams
public function getParams($key = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if ($key === null) { return $this->_iframeParams; } if (!isset($this->_iframeParams[$key])) { return null; } return $this->_iframeParams[$key]; } if ($key === null) { return $this->_objectParams; } if (!isset($this->_objectParams[$key])) { return null; } return $this->_objectParams[$key]; }
php
public function getParams($key = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if ($key === null) { return $this->_iframeParams; } if (!isset($this->_iframeParams[$key])) { return null; } return $this->_iframeParams[$key]; } if ($key === null) { return $this->_objectParams; } if (!isset($this->_objectParams[$key])) { return null; } return $this->_objectParams[$key]; }
[ "public", "function", "getParams", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_stub", "[", "'iframe-player'", "]", ")", "&&", "$", "this", "->", "config", "[", "'prefer'", "]", "===", "'iframe'", ")", ...
Return object params about the video metadata @param string|null $key @return array|string|null Object params
[ "Return", "object", "params", "about", "the", "video", "metadata" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L350-L368
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.getAttributes
public function getAttributes($key = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if ($key === null) { return $this->_iframeAttributes; } if (!isset($this->_iframeAttributes[$key])) { return null; } return $this->_iframeAttributes[$key]; } if ($key === null) { return $this->_objectAttributes; } if (!isset($this->_objectAttributes[$key])) { return null; } return $this->_objectAttributes[$key]; }
php
public function getAttributes($key = null) { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { if ($key === null) { return $this->_iframeAttributes; } if (!isset($this->_iframeAttributes[$key])) { return null; } return $this->_iframeAttributes[$key]; } if ($key === null) { return $this->_objectAttributes; } if (!isset($this->_objectAttributes[$key])) { return null; } return $this->_objectAttributes[$key]; }
[ "public", "function", "getAttributes", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_stub", "[", "'iframe-player'", "]", ")", "&&", "$", "this", "->", "config", "[", "'prefer'", "]", "===", "'iframe'", ")"...
Return object attribute @param string|null $key @return mixed Object attribute
[ "Return", "object", "attribute" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L376-L394
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.getEmbedCode
public function getEmbedCode() { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { return $this->_buildIframe(); } return $this->_buildObject(); }
php
public function getEmbedCode() { if (!empty($this->_stub['iframe-player']) && $this->config['prefer'] === 'iframe') { return $this->_buildIframe(); } return $this->_buildObject(); }
[ "public", "function", "getEmbedCode", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_stub", "[", "'iframe-player'", "]", ")", "&&", "$", "this", "->", "config", "[", "'prefer'", "]", "===", "'iframe'", ")", "{", "return", "$", "thi...
Convert the url to an embeddable tag @return string The embed HTML
[ "Convert", "the", "url", "to", "an", "embeddable", "tag" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L401-L406
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject._getObjectSrc
protected function _getObjectSrc($type = 'embed-src') { if (empty($this->_stub['id']) || empty($this->_stub['slug'])) { return null; } $stubSrc = $this->_stub[$type]; if (strpos($stubSrc, '$r2') !== false) { $src = str_replace('$r2', $this->_stub['id'], $stubSrc); } else { $src = str_replace('$2', $this->_stub['id'], $stubSrc); } if (!empty($host['replace'])) { foreach ($host['replace'] as $placeholder => $replacement) { $src = str_replace($placeholder, $replacement, $src); } } return $src; }
php
protected function _getObjectSrc($type = 'embed-src') { if (empty($this->_stub['id']) || empty($this->_stub['slug'])) { return null; } $stubSrc = $this->_stub[$type]; if (strpos($stubSrc, '$r2') !== false) { $src = str_replace('$r2', $this->_stub['id'], $stubSrc); } else { $src = str_replace('$2', $this->_stub['id'], $stubSrc); } if (!empty($host['replace'])) { foreach ($host['replace'] as $placeholder => $replacement) { $src = str_replace($placeholder, $replacement, $src); } } return $src; }
[ "protected", "function", "_getObjectSrc", "(", "$", "type", "=", "'embed-src'", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_stub", "[", "'id'", "]", ")", "||", "empty", "(", "$", "this", "->", "_stub", "[", "'slug'", "]", ")", ")", "{",...
Get final src @param string $type @return string|null
[ "Get", "final", "src" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L432-L449
train
dereuromark/media-embed
src/Object/MediaObject.php
MediaObject.image
public function image() { if (empty($this->_stub['image-src'])) { return ''; } $thumb = $this->_stub['image-src']; $count = count($this->_match); for ($i = 1; $i <= $count; $i++) { $thumb = str_ireplace('$' . $i, $this->_match[$i - 1], $thumb); } return $thumb; }
php
public function image() { if (empty($this->_stub['image-src'])) { return ''; } $thumb = $this->_stub['image-src']; $count = count($this->_match); for ($i = 1; $i <= $count; $i++) { $thumb = str_ireplace('$' . $i, $this->_match[$i - 1], $thumb); } return $thumb; }
[ "public", "function", "image", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_stub", "[", "'image-src'", "]", ")", ")", "{", "return", "''", ";", "}", "$", "thumb", "=", "$", "this", "->", "_stub", "[", "'image-src'", "]", ";", "$",...
Return a thumbnail for the embeded video @return string - the thumbnail href
[ "Return", "a", "thumbnail", "for", "the", "embeded", "video" ]
bd940aafbaf4577a5dd61879e0601f278593f523
https://github.com/dereuromark/media-embed/blob/bd940aafbaf4577a5dd61879e0601f278593f523/src/Object/MediaObject.php#L477-L489
train