sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function deleteUser($data) { $response=CodeBank_ClientAPI::responseBase(); try { $member=Member::get()->filter('ID', intval($data->id))->filter('ID:not', Member::currentUserID())->First(); if(!empty($member) && $member!==false && $member->ID!=0) { ...
Deletes a user @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function changeUserPassword($data) { $response=CodeBank_ClientAPI::responseBase(); try { $member=Member::get()->byID(intval($data->id)); if(empty($member) || $member===false || $member->ID==0) { $response['status']='EROR'; $response...
Changes a users password @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function createUser($data) { $response=CodeBank_ClientAPI::responseBase(); try { if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) { $response['status']='EROR'; $response['message']=_t('CodeBankAPI.EMAIL_EXISTS', ...
Creates a user in the database @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function getAdminLanguages() { $response=CodeBank_ClientAPI::responseBase(); $languages=SnippetLanguage::get(); foreach($languages as $lang) { $response['data'][]=array( 'id'=>$lang->ID, 'language...
Gets the list of languages with snippet counts @return {array} Standard response base
entailment
public function createLanguage($data) { $response=CodeBank_ClientAPI::responseBase(); try { if(SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) { $response['status']='EROR'; $response['message']=_t('CodeBank...
Creates a language in the database @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function deleteLanguage($data) { $response=CodeBank_ClientAPI::responseBase(); try { $lang=SnippetLanguage::get()->byID(intval($data->id)); if(!empty($lang) && $lang!==false && $lang->ID!=0) { if($lang->canDelete()==false) { $re...
Deletes a language from the database @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function editLanguage($data) { $response=CodeBank_ClientAPI::responseBase(); try { if(SnippetLanguage::get()->filter('Name:nocase', Convert::raw2sql($data->language))->Count()>0) { $response['status']='EROR'; $response['message']=_t('CodeBankAP...
Edits a language @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public static function MakeOfType(array $esHit, $className = "", Client $esClient = null) { if ($className && strpos($className, '{type}') !== false) { $baseClassName = str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9]+/', ' ', $esHit['_type']))); $fullClassName = str_replace("{ty...
A custom factory method that will try to detect the correct model class and instantiate and object of it. @param array $esHit @param string $className a class name or pattern. @param Client $esClient ElasticSearch client @return Model
entailment
public function getAttributes() { $values = func_get_args(); if (count($values) === 1) { $result = []; foreach ($values as $value) { $result[$value] = @$this->attributes[$value]; } return $result; } elseif (count($values) > 1) { ...
Return attributes (actual document data) @return array
entailment
public function update(array $data, array $parameters = []) { if (!$this->canAlter()) { throw new Exception('Need index, type, and key to update a document'); } if (!$this->esClient) { throw new Exception('Need ElasticSearch client object for ALTER operations'); }...
Updates the document @param array $data the normal elastic update parameters to be used @param array $parameters the parameters array @return array @throws Exception
entailment
public function delete(array $parameters = []) { if (!$this->canAlter()) { throw new Exception('Need index, type, and key to delete a document'); } if (!$this->esClient) { throw new Exception('Need ElasticSearch client object for ALTER operations'); } $par...
Deletes a document @param array $parameters @return array @throws Exception
entailment
protected function buildGraphComponents(array $components) { $graphComponents = array_fill_keys( array_column($components, 'class'), [ 'class' => null, 'id' => null, 'type' => null, 'label' ...
Prepare the list of graph components @param array $components Components @return array Graph components
entailment
protected function addToComponentTree($componentId, array $componentPath, array &$tree) { // If the component has to be placed in a subpath if (count($componentPath)) { $subpath = array_shift($componentPath); if (empty($tree[$subpath])) { $tree[$subpath] = [];...
Add a component to the component tree @param string $componentId Component ID @param array $componentPath Component path @param array $tree Component base tree
entailment
protected function addToComponentTreeSubset(array &$pointer, $componentId) { foreach ($this->graphComponents[$componentId]['path'] as $node) { if (empty($pointer[$node])) { $pointer[$node] = []; } $pointer =& $pointer[$node]; } $pointer[] =...
Recursively add a single component to a component tree subset @param array $pointer Component tree subset @param string $componentId Component class @return array Component dependencies
entailment
protected function addComponents(BaseGraph $graph, array $components, Node $parentNode = null) { // Sort the components // uasort($components, function($component1, $component2) { // $isNode1 = is_array($component1); // $isNode2 = is_array($component2); // // // If bo...
Add a list of components to a graph @param BaseGraph $graph Graph @param array $components Component list @param Node $parentNode Parent node @return BaseGraph Graph
entailment
protected function addNode(BaseGraph $graph, $nodeId, array $components, Node $parentNode = null) { $absNodeId = (($parentNode instanceof Node) ? $parentNode->getId() : '/').$nodeId; $graph->node( $absNodeId, [ 'label' => $nodeId, 'shape' => 'n...
Add a node to a graph @param BaseGraph $graph Graph @param string $nodeId Node ID @param array $components Component list @param Node $parentNode Parent node @return BaseGraph Graph
entailment
protected function addComponent(BaseGraph $graph, $componentId, Node $parentNode = null) { $component = $this->graphComponents[$componentId]; $origComponentClass = $component['class']; // If this is a variant: Redirect to the master component if ($component['master']) { ...
Add a component to a graph @param BaseGraph $graph Graph @param string $componentId Component ID @param Node $parentNode Parent node @return BaseGraph Graph
entailment
protected function getComponentTitle($componentId) { $component =& $this->graphComponents[$componentId]; $componentTitle = implode('/', array_filter(array_merge($component['path'], [$component['id']]))); $componentTitle .= ' ('.$component['class'].')'; return $componentTitle; ...
Create and return an component title @param string $componentId Component ID @return string Component title
entailment
public function serialize(DomainEvent $event): string { $reflect = new ReflectionObject($event); $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PRIVATE); return json_encode([ 'eventName' => $this->eventNameForClass(get_class($event)), ...
serialize a domain event into event sourcery library storage conventions @param DomainEvent $event @return string
entailment
private function serializeFields($props, $event) { array_map(function (ReflectionProperty $prop) use (&$fields, $event) { /** @var ReflectionProperty $prop */ $prop->setAccessible(true); $fields[$prop->getName()] = $this->valueSerializer->serialize($prop->getValue($event)); ...
Serialize the fields of a domain event into a key => value hash @param $props @param $event @return mixed
entailment
public function deserialize(array $serialized): DomainEvent { $className = $this->classNameForEvent($serialized['eventName']); $reflect = new ReflectionClass($className); $const = $reflect->getConstructor(); // reflect on constructor to get name / type $constParams = []; ...
deserialize a domain event from event sourcery library storage conventions @param array $serialized @return DomainEvent @throws \ReflectionException @throws \Exception
entailment
public function sort($by, $direction = "asc", $override = false) { $this->assertInitiated("sort"); if ($override) { $this->query['sort'] = []; } $this->query['sort'][] = [$by => $direction]; return $this; }
Adds a sort clause to the query @param string $by the key to sort by it @param string|array $direction the direction of the sort. Can be an array for extra sort control. @param boolean $override false by default. if true it will reset the sort first, then add the new sort entry. @return QueryBuilder|static|self
entailment
public function where($key, $value, $compare = "=", $filter = null, $params = []) { //identify the bool part must|should|must_not $compare = trim($compare); $bool = substr($compare, 0, 1) == "!" ? "must_not" : (substr($compare, 0, 1) == "?" ? "should" : "must"); //get the correct compa...
The basic smart method to build queries. It will automatically identify the correct filter/query tool to use, as well the correct query part to be used in, depending on the content and type of the key, value, and comparison parameters. $comparison parameter will define what filter/query tool to use. @param string|st...
entailment
public function wildcard($key, $value, $bool = "must", $filter = false, array $params = []) { if (is_array($key)) { return $this->multiWildcard($key, $value, $bool, $filter, $params); } if (is_array($value)) { return $this->wildcards($key, $value, $bool, $filter, $params)...
Creates a wildcard query part. It will automatically detect the $key and $value types to create the required number of clauses, as follows: $key $value result single single {wildcard:{$key:{wildcard:$value}}} single array or:[wildcard($key, $value[1]), ...] array single ...
entailment
public function wildcards($key, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($values as $value) { $subQuery->wildcard($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; ...
Creates wildcard query for each $value grouped by OR clause @see QueryBuilder::wildcard() for more information @param string|string[] $key the key(s) to wildcard search in. @param string[] $values the value(s) to wildcard search against. @param string $bool severity of the query/filter. [must]|must_not|should @param ...
entailment
public function multiWildcard(array $keys, $value, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->wildcard($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; ...
Creates wildcard query for each $key grouped by OR clause @see QueryBuilder::wildcard() for more information @param string[] $keys the key(s) to wildcard search in. @param string|string[] $value the value(s) to wildcard search against. @param string $bool severity of the query/filter. [must]|must_not|should @param bo...
entailment
public function multiWildcards(array $keys, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->wildcards($key, $values, $bool, true, $params); } $subQuery->endSubQuery(); return...
Creates wildcard query for each $key/$value pair grouped by OR clause @see QueryBuilder::wildcard() for more information @param string[] $keys the key(s) to wildcard search in. @param string[] $values the value(s) to wildcard search against. @param string $bool severity of the query/filter. [must]|must_not|should @pa...
entailment
public function regexp($key, $value, $bool = "must", $filter = false, array $params = []) { if (is_array($key)) { return $this->multiRegexp($key, $value, $bool, $filter, $params); } if (is_array($value)) { return $this->regexps($key, $value, $bool, $filter, $params); ...
Creates a regexp query part. It will automatically detect the $key and $value types to create the required number of clauses, as follows: $key $value result single single {regexp:{$key:{regexp:$value}}} single array or:[regexp($key, $value[1]), ...] array single or:[re...
entailment
public function regexps($key, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($values as $value) { $subQuery->regexp($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Creates regexp query for each $value grouped by OR clause @see QueryBuilder::regexp() for more information @param string|string[] $key the key(s) to regexp search in. @param string[] $values the value(s) to regexp search against. @param string $bool severity of the query/filter. [must]|must_not|should @param bool $fi...
entailment
public function multiRegexp(array $keys, $value, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->regexp($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Creates regexp query for each $key grouped by OR clause @see QueryBuilder::regexp() for more information @param string[] $keys the key(s) to regexp search in. @param string|string[] $value the value(s) to regexp search against. @param string $bool severity of the query/filter. [must]|must_not|should @param bool $filt...
entailment
public function multiRegexps(array $keys, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->regexps($key, $values, $bool, true, $params); } $subQuery->endSubQuery(); return $th...
Creates regexp query for each $key/$value pair grouped by OR clause @see QueryBuilder::regexp() for more information @param string[] $keys the key(s) to regexp search in. @param string[] $values the value(s) to regexp search against. @param string $bool severity of the query/filter. [must]|must_not|should @param bool...
entailment
public function prefix($key, $value, $bool = "must", $filter = false, array $params = []) { if (is_array($key)) { return $this->multiPrefix($key, $value, $bool, $filter, $params); } if (is_array($value)) { return $this->prefixs($key, $value, $bool, $filter, $params); ...
Creates a prefix query part. It will automatically detect the $key and $value types to create the required number of clauses, as follows: $key $value result single single {prefix:{$key:{prefix:$value}}} single array or:[prefix($key, $value[1]), ...] array single or:[pr...
entailment
public function prefixs($key, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($values as $value) { $subQuery->prefix($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Creates prefix query for each $value grouped by OR clause @see QueryBuilder::prefix() for more information @param string|string[] $key the key(s) to prefix search in. @param string[] $values the value(s) to prefix search against. @param string $bool severity of the query/filter. [must]|must_not|should @param bool $fi...
entailment
public function multiPrefix(array $keys, $value, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->prefix($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Creates OR-joined multiple prefix queries for the list of keys Creates a prefix query for the $value for each key in the $keys @param array $keys @param type $value @param type $bool @param array $params @return QueryBuilder|static|self
entailment
public function multiPrefixs(array $keys, array $values, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->prefixs($key, $values, $bool, true, $params); } $subQuery->endSubQuery(); return $th...
Creates multiple prefixes queries for the list of keys Two keys and two values will results in 4 prefix queries @param array $keys @param array $values @param type $bool @param array $params @return QueryBuilder|static|self
entailment
public function term($key, $value, $bool = "must", $filter = false, array $params = []) { if (is_array($key)) { return $this->multiTerm($key, $value, $bool, $filter, $params); } $tool = "term" . (is_array($value) ? "s" : ""); $this->addBool([$tool => [$key => (is_array($value...
A normal term/terms query It will automatically use term or terms query depending on the type of $value parameter whether it is an array or not. @param type $key @param type $value @param type $bool @param type $filter @param array $params @return QueryBuilder|static|self
entailment
public function multiTerm(array $keys, $value, $bool = "must", $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->term($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Multiple OR joined term queries @param array $keys @param type $value @param type $bool @param type $filter @param array $params @return QueryBuilder|static|self
entailment
public function match($key, $value, $bool, $filter = false, array $params = []) { if (is_array($key)) { return $this->multiMatch($key, $value, $bool, $filter, $params); } if (is_array($value)) { return $this->matches($key, $value, $bool, $filter, $params); } ...
A match query @param type $key @param type $value @param type $bool @param boolean $filter @param array $params @return QueryBuilder|static|self
entailment
public function matches($key, array $values, $bool, $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($values as $value) { $subQuery->match($key, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; }
Creates multiple match queries for each value in the array Queries will be joined by an OR filter @param string $key the key to create the matches for @param array $values a list of values to create a match query for each @param type $bool @param array $params @return QueryBuilder|static|self
entailment
public function multiMatch(array $keys, $value, $bool, $filter = false, array $params = []) { $this->addBool($this->makeFilteredQuery(["multi_match" => ["query" => $value, "fields" => $keys] + $params], $filter), $bool, $filter); return $this; }
Creates a mutli_match query @param array $keys keys(fields) of the multimatch @param type $value @param type $bool @param array $params @return QueryBuilder|static|self
entailment
public function multiMatches(array $keys, array $values, $bool, $filter = false, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($values as $value) { $subQuery->multiMatch($keys, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this...
Creates multiple mutli_match queries for each value in the array Queries will be joined by an OR filter @param array $keys keys(fields) of the multimatch @param scalar[] $values a list of values to create a multimatch query for @param type $bool @param array $params @return QueryBuilder|static|self
entailment
public function range($key, $operator, $value, $bool, $filter, array $params = []) { if (is_array($operator) && !is_array($value) || !is_array($operator) && is_array($value) || is_array($operator) && count($operator) !== count($value)) { throw new \BadMethodCallException("Operator and value paramete...
Creates a range query @param string $key The key to create the range query for @param string|string[] $operator lt, gt, lte, gte. Can be an array of mixed lt,gt,lte,gte; and if so, it should match the number of elements in the $value array too. @param scalar|scalar[] $value the value for the range comparison. Should b...
entailment
public function multiRange(array $keys, $operator, $value, $bool, $filter, array $params = []) { $subQuery = $this->orWhere($bool); foreach ($keys as $key) { $subQuery->range($key, $operator, $value, $bool, true, $params); } $subQuery->endSubQuery(); return $this; ...
Creates multiple range queries joined by OR For each key in the keys, a new range query will be created @param array $keys keys to create a range query for each of them @param string|string[] $operator lt, gt, lte, gte. Can be an array of mixed lt,gt,lte,gte; and if so, it should match the number of elements in the $...
entailment
public function andWhere($bool = "must", array $params = []) { $callback = function(SubQueryBuilder $subQuery) use ($bool, $params) { return $this->_endChildSubQuery("and", $subQuery->toArray(), $bool, $params); }; return SubQueryBuilder::make($callback); }
Creates an AND filter subquery @param string $bool must, should, or must_not @param array $params extra params for and filter @return SubQueryBuilder
entailment
protected function _endChildSubQuery($tool, array $subQuery, $bool, array $params = []) { $this->addBool([$tool => $subQuery], $bool, true, $params); return $this; }
Receives the end signal from the sub query object @param string $tool [and|or] @param array $subQuery @param type $bool @param array $params @return QueryBuilder|static|self
entailment
protected function assertInitiated($key) { $current = &$this->query; $keys = explode(".", $key); foreach ($keys as $element) { if (!array_key_exists($element, $current)) { $current[$element] = []; } $current = &$current[$element]; } ...
Checks and creates the required structure @param string $key A dot [.] separated path to be created/checked @return void
entailment
protected function addBool(array $query, $bool, $filter = false, array $params = []) { $filtered = $filter ? "filter" : "query"; $key = "query.filtered.{$filtered}.bool.{$bool}"; if ($filter) { $this->assertInitiated($key); } $this->query["query"]["filtered"][$filtere...
Adds a new bool query part to the query array @param array $query the bool query part to be added @param string $bool the bool group (must, should, must_not) @param boolean $filter weither to be added to the filter or the query party @param array $params extra parameters for the query part (will be merged into the ori...
entailment
public function page($size, $from = null) { if ($from) { $this->from($from); } if ($size) { $this->size($size); } return $this; }
Set the from and size (paging) of the results @param integer $size @param integer $from @return QueryBuilder|static|self
entailment
public function authenticate(TokenInterface $token) { if($this->userProvider instanceof ChainUserProvider) { foreach ($this->userProvider->getProviders() as $provider) { $result = $this->doAuth($provider, $token); if($result !== false) { return ...
Attempts to authenticate a TokenInterface object. @param TokenInterface $token The TokenInterface instance to authenticate @return TokenInterface An authenticated TokenInterface instance, never null @throws AuthenticationException if the authentication fails
entailment
protected function doAuth($provider, TokenInterface $token) { if (! $provider instanceof ApiKeyUserProviderInterface) { return false; } /** @var UserInterface $user */ $user = $provider->loadUserByApiKey($token->getCredentials()); if ($user) { $authe...
@param UserProviderInterface $provider @param TokenInterface $token @return bool|ApiKeyUserToken @throws AuthenticationException
entailment
public function saveIPMessage($data) { $response=CodeBank_ClientAPI::responseBase(); if(!Permission::check('ADMIN')) { $response['status']='EROR'; $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied'); return $response; } ...
Saves the IP Message @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function savePreferences($data) { $response=CodeBank_ClientAPI::responseBase(); try { $member=Member::currentUser(); if($member && $member->ID!=0) { $member->UseHeartbeat=($data->heartbeat==1 ? true:false); $member->write(); ...
Saves users server preferences @param {stdClass} $data Data passed from ActionScript @return {array} Standard response base
entailment
public function changePassword($data) { $response=CodeBank_ClientAPI::responseBase(); try { $member=Member::currentUser(); $e=PasswordEncryptor::create_for_algorithm($member->PasswordEncryption); if(!$e->check($member->Password, $data->currPasswo...
Changes a users password @param {stdClass} $data Data passed from ActionScript @return {array} Returns a standard response array
entailment
public function setLdap(Zend_Ldap $ldap) { $this->_ldap = $ldap; $this->setOptions(array($ldap->getOptions())); return $this; }
Set an Ldap connection @param Zend_Ldap $ldap An existing Ldap object @return Zend_Auth_Adapter_Ldap Provides a fluent interface
entailment
protected function _getAuthorityName() { $options = $this->getLdap()->getOptions(); $name = $options['accountDomainName']; if (!$name) $name = $options['accountDomainNameShort']; return $name ? $name : ''; }
Returns a domain name for the current LDAP options. This is used for skipping redundant operations (e.g. authentications). @return string
entailment
public function authenticate() { /** * @see Zend_Ldap_Exception */ require_once 'Zend/Ldap/Exception.php'; $messages = array(); $messages[0] = ''; // reserved $messages[1] = ''; // reserved $username = $this->_username; $password = $this->_...
Authenticate the user @throws Zend_Auth_Adapter_Exception @return Zend_Auth_Result
entailment
protected function _prepareOptions(Zend_Ldap $ldap, array $options) { $adapterOptions = array( 'group' => null, 'groupDn' => $ldap->getBaseDn(), 'groupScope' => Zend_Ldap::SEARCH_SCOPE_SUB, 'groupAttr' => 'cn', 'groupFilter' => 'object...
Sets the LDAP specific options on the Zend_Ldap instance @param Zend_Ldap $ldap @param array $options @return array of auth-adapter specific options
entailment
protected function _checkGroupMembership(Zend_Ldap $ldap, $canonicalName, $dn, array $adapterOptions) { if ($adapterOptions['group'] === null) { return true; } if ($adapterOptions['memberIsDn'] === false) { $user = $canonicalName; } else { $user =...
Checks the group membership of the bound user @param Zend_Ldap $ldap @param string $canonicalName @param string $dn @param array $adapterOptions @return string|true
entailment
public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array()) { if (!$this->_authenticatedDn) { return false; } $returnObject = new stdClass(); $returnAttribs = array_map('strtolower', $returnAttribs); $omitAttribs = array_map(...
getAccountObject() - Returns the result entry as a stdClass object This resembles the feature {@see Zend_Auth_Adapter_DbTable::getResultRowObject()}. Closes ZF-6813 @param array $returnAttribs @param array $omitAttribs @return stdClass|boolean
entailment
private function _optionsToString(array $options) { $str = ''; foreach ($options as $key => $val) { if ($key === 'password') $val = '*****'; if ($str) $str .= ','; $str .= $key . '=' . $val; } return $str; }
Converts options to string @param array $options @return string
entailment
public static function lowerCase(&$value, &$key) { trigger_error(__CLASS__ . '::' . __METHOD__ . '() is deprecated and will be removed in a future version', E_USER_NOTICE); return $value = strtolower($value); }
Lowercase a string Lowercase's a string by reference @deprecated @param string $string value @param string $key @return string Lower cased string
entailment
protected function _buildCallback(Zend_Server_Reflection_Function_Abstract $reflection) { $callback = new Zend_Server_Method_Callback(); if ($reflection instanceof Zend_Server_Reflection_Method) { $callback->setType($reflection->isStatic() ? 'static' : 'instance') ->...
Build callback for method signature @param Zend_Server_Reflection_Function_Abstract $reflection @return Zend_Server_Method_Callback
entailment
protected function _buildSignature(Zend_Server_Reflection_Function_Abstract $reflection, $class = null) { $ns = $reflection->getNamespace(); $name = $reflection->getName(); $method = empty($ns) ? $name : $ns . '.' . $name; if (!$this->_overwriteExistingMethods && $...
Build a method signature @param Zend_Server_Reflection_Function_Abstract $reflection @param null|string|object $class @return Zend_Server_Method_Definition @throws Zend_Server_Exception on duplicate entry
entailment
protected function _dispatch(Zend_Server_Method_Definition $invocable, array $params) { $callback = $invocable->getCallback(); $type = $callback->getType(); if ('function' == $type) { $function = $callback->getFunction(); return call_user_func_array($function, $p...
Dispatch method @param Zend_Server_Method_Definition $invocable @param array $params @return mixed
entailment
public function it_fails_if_a_collection_doesnt_have_a_matching_event() { $events = DomainEvents::make([]); expect($events)->shouldNotContainEvent( new EventStub(3, 2, 1) ); $events = DomainEvents::make([ new EventStub(3, 2, 1), ]); expect($even...
when you get time
entailment
public function requireDefaultRecords() { parent::requireDefaultRecords(); $defaultLangs=array_keys($this->defaultLanguages); $dbLangCount=SnippetLanguage::get() ->filter('Name', $defaultLangs) ->filter('Use...
Adds the default languages if they are missing
entailment
public function canDelete($member=null) { $parentResult=parent::canDelete($member); if($parentResult==false || $this->UserLanguage==false) { return false; } if($this->Folders()->count()>0 || $this->Snippets()->count()>0) { return false; }...
Checks to see if the given member can delete this object or not @param {Member} $member Member instance or member id to check @return {bool} Returns boolean true or false depending if the user can delete this object
entailment
public function getCMSFields() { $fields=new FieldList( new TextField('Name', _t('SnippetLanguage.NAME', '_Name'), null, 100), new TextField('FileExtension', _t('SnippetLanguage.FILE_EXTENSION', '_File Extension'), null, 45), ne...
Gets fields used in the cms @return {FieldSet} Fields to be used
entailment
public function allowedChildren() { $allowedChildren = array(); $candidates = $this->stat('allowed_children'); if($candidates && $candidates != "none") { foreach($candidates as $candidate) { // If a classname is prefixed by "*", such as "*Page", then only that ...
Returns an array of the class names of classes that are allowed to be children of this class. @return {array} Array of children
entailment
public function transformImage ($asset = null, $transforms = null, $defaultOptions = []) { return Imgix::$plugin->imgixService->transformImage($asset, $transforms, $defaultOptions); }
@param null $asset @param null $transforms @param array $defaultOptions @return string
entailment
public function addMethod($method, $name = null) { if (is_array($method)) { require_once 'Zend/Server/Method/Definition.php'; $method = new Zend_Server_Method_Definition($method); } elseif (!$method instanceof Zend_Server_Method_Definition) { require_once 'Zend/Se...
Add method to definition @param array|Zend_Server_Method_Definition $method @param null|string $name @return Zend_Server_Definition @throws Zend_Server_Exception if duplicate or invalid method provided
entailment
public function addMethods(array $methods) { foreach ($methods as $key => $method) { $this->addMethod($method, $key); } return $this; }
Add multiple methods @param array $methods Array of Zend_Server_Method_Definition objects or arrays @return Zend_Server_Definition
entailment
public function toArray() { $methods = array(); foreach ($this->getMethods() as $key => $method) { $methods[$key] = $method->toArray(); } return $methods; }
Cast definition to an array @return array
entailment
function encrypt(PersonalData $data, CryptographicDetails $crypto): EncryptedPersonalData { if ( ! $crypto->encryption() == 'libsodium') { throw new CryptographicDetailsNotCompatibleWithEncryption("{$crypto->encryption()} received, expected 'libsodium'"); } $dataString = $data->toS...
encrypt personal data and return an encrypted form @param PersonalData $data @param CryptographicDetails $crypto @throws CryptographicDetailsDoNotContainKey @throws CryptographicDetailsNotCompatibleWithEncryption @return EncryptedPersonalData
entailment
function decrypt(EncryptedPersonalData $data, CryptographicDetails $crypto): PersonalData { if ( ! $crypto->encryption() == 'libsodium') { throw new CryptographicDetailsNotCompatibleWithEncryption("{$crypto->encryption()} received, expected 'libsodium'"); } $encrypted = $data->toSt...
decrypted encrypted personal data and return a decrypted form @param EncryptedPersonalData $data @param CryptographicDetails $crypto @throws CryptographicDetailsDoNotContainKey @throws CryptographicDetailsNotCompatibleWithEncryption @return PersonalData
entailment
public function discoverCommand() { $setup = $this->objectManager->get(BackendConfigurationManager::class)->getTypoScriptSetup(); /** @var TypoScriptService $typoscriptService */ $typoscriptService = $this->objectManager->get(TypoScriptService::class); $config = $typoscrip...
Discover and extract all components
entailment
public function createCommand($name, $type, $extension = null, $vendor = null) { // Prepare the component name $name = GeneralUtility::trimExplode('/', $name, true); if (!count($name)) { throw new CommandException('Empty / invalid component name', 1507996606); } ...
Create a new component @param string $name Component path and name @param string $type Component type @param string $extension Host extension @param string $vendor Host extension vendor name @throws CommandException If the component name is empty / invalid @throws CommandException If the component type i...
entailment
public function color($name, $value = null, $options = array()) { return $this->input('color', $name, $value, $options); }
Create a form color field. @param string $name @param string $value @param array $options @return string
entailment
public function date($name, $value = null, $min = null, $max = null, $options = array()) { if( !isset($min) && !isset($max) ) return 'The date field "'.$name.'" must have a min, max or both.'; if( isset($min) ) $options['min'] = $min; if( isset($max) ) $options['max'] = $max; ...
Create a form date field. @param string $name @param date $value @param date $min @param date $max @param array $options @return string
entailment
public function week($name, $value = null, $options = array()) { return $this->input('week', $name, $value, $options); }
Create a form week field. @param string $name @param string $value @param array $options @return string
entailment
public function month($name, $value = null, $options = array()) { return $this->input('month', $name, $value, $options); }
Create a form month field. @param string $name @param string $value @param array $options @return string
entailment
public function number($name, $value = null, $step = null, $options = array()) { if( isset($step) ) $options['step'] = $step; $options = $this->setNumberMinMax($options); return $this->input('number', $name, $value, $options); }
Create a form number field. @param string $name @param string $value @param int $step @param array $options @return string
entailment
public function range($name, $value = null, $options = array()) { $options = $this->setNumberMinMax($options); return $this->input('range', $name, $value, $options); }
Create a form range field. @param string $name @param string $value @param array $options @return string
entailment
public function search($name, $value = null, $options = array()) { return $this->input('search', $name, $value, $options); }
Create a form search field. @param string $name @param string $value @param array $options @return string
entailment
protected function setNumberMinMax($options) { if (isset($options['minmax'])) { // If "minmax" is false, then don't set any min/max and remove it from the options array if ( $options['minmax'] == false){ unset($options['minmax']); return $opt...
Set the number min max on the attributes. @param array $options @return array
entailment
public function img($attributes = null) { if ($image = $this->transformed) { if ($image && isset($image['url'])) { $lazyLoad = false; if (isset($attributes['lazyLoad'])) { $lazyLoad = $attributes['lazyLoad']; unset($attribut...
@param null $attributes @return null|\Twig_Markup
entailment
public function srcset($attributes = []) { if ($images = $this->transformed) { $widths = []; $result = ''; foreach ($images as $image) { $keys = array_keys($image); $width = $image['width'] ?? $image['w'] ?? null; if ($wid...
@param $attributes @return null|\Twig_Markup
entailment
protected function transform($transforms) { if (!$transforms) { return null; } if (isset($transforms[0])) { $images = []; foreach ($transforms as $transform) { $transform = array_merge($this->defaultOptions, $transform); $t...
@param $transforms @return null
entailment
private function buildTransform($filename, $transform) { $parameters = $this->translateAttributes($transform); return $this->builder->createURL($filename, $parameters); }
@param $filename @param $transform @return string
entailment
private function translateAttributes($attributes) { $translatedAttributes = []; foreach ($attributes as $key => $setting) { if (array_key_exists($key, $this->attributesTranslate)) { $key = $this->attributesTranslate[ $key ]; } $translatedAttribut...
@param $attributes @return array
entailment
private function getTagAttributes($attributes) { if (!$attributes) { return ''; } $tagAttributes = ''; foreach ($attributes as $key => $attribute) { $tagAttributes .= ' ' . $key . '="' . $attribute . '"'; } return $tagAttributes; }
@param $attributes @return string
entailment
protected function calculateTargetSizeFromRatio($transform) { if (!isset($transform['ratio'])) { return $transform; } $ratio = (float)$transform['ratio']; $w = isset($transform['w']) ? $transform['w'] : null; $h = isset($transform['h']) ? $transform['h'] ...
@param $transform @return mixed
entailment
public static function regenerateId() { if (!self::$_unitTestEnabled && headers_sent($filename, $linenum)) { /** @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception("You must call " . __CLASS__ . '::' . __FUNCTION__ ....
regenerateId() - Regenerate the session id. Best practice is to call this after session is started. If called prior to session starting, session id will be regenerated at start time. @throws Zend_Session_Exception @return void
entailment
public static function writeClose($readonly = true) { if (self::$_unitTestEnabled) { return; } if (self::$_writeClosed) { return; } if ($readonly) { parent::$_writable = false; } session_write_close(); self::$_wri...
writeClose() - Shutdown the sesssion, close writing and detach $_SESSION from the back-end storage mechanism. This will complete the internal data transformation on this request. @param bool $readonly - OPTIONAL remove write access (i.e. throw error if Zend_Session's attempt writes) @return void
entailment
private static function _processValidators() { foreach ($_SESSION['__ZF']['VALID'] as $validator_name => $valid_data) { if (!class_exists($validator_name)) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass($validator_name); } $valida...
_processValidator() - internal function that is called in the existence of VALID metadata @throws Zend_Session_Exception @return void
entailment
public static function getIterator() { if (parent::$_readable === false) { /** @see Zend_Session_Exception */ require_once 'Zend/Session/Exception.php'; throw new Zend_Session_Exception(parent::_THROW_NOT_READABLE_MSG); } $spaces = array(); if (i...
getIterator() - return an iteratable object for use in foreach and the like, this completes the IteratorAggregate interface @throws Zend_Session_Exception @return ArrayObject
entailment
public function run($request) { //Check for tables $tables=DB::tableList(); if(!array_key_exists('languages', $tables) || !array_key_exists('snippits', $tables) || !array_key_exists('snippit_history', $tables) || !array_key_exists('preferences', $tables) || !array_key_exists('settings', $tables)...
Performs the migration
entailment
public function setTargetUri($targetUri) { if (null === $targetUri) { $targetUri = ''; } $this->_targetUri = (string) $targetUri; return $this; }
Set target Uri @param string $targetUri @return Zend_Amf_Value_MessageBody
entailment
public function setReplyMethod($methodName) { if (!preg_match('#^[/?]#', $methodName)) { $this->_targetUri = rtrim($this->_targetUri, '/') . '/'; } $this->_targetUri = $this->_targetUri . $methodName; return $this; }
Set reply method @param string $methodName @return Zend_Amf_Value_MessageBody
entailment
public static function reflectClass($class, $argv = false, $namespace = '') { if (is_object($class)) { $reflection = new ReflectionObject($class); } elseif (class_exists($class)) { $reflection = new ReflectionClass($class); } else { require_once 'Zend/Serv...
Perform class reflection to create dispatch signatures Creates a {@link Zend_Server_Reflection_Class} object for the class or object provided. If extra arguments should be passed to dispatchable methods, these may be provided as an array to $argv. @param string|object $class Class name or object @param null|array $a...
entailment