id
int32
0
241k
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
43,600
phpforce/soap-client
src/Phpforce/SoapClient/Client.php
Client.fixFieldsToNullXml
protected function fixFieldsToNullXml(\SoapVar $object) { if (isset($object->enc_value->fieldsToNull) && is_array($object->enc_value->fieldsToNull) && count($object->enc_value->fieldsToNull) > 0) { $xml = ''; foreach ($object->enc_value->fieldsToNull as $fieldToNull) { $xml .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; } return new \SoapVar(new \SoapVar($xml, XSD_ANYXML), SOAP_ENC_ARRAY); } }
php
protected function fixFieldsToNullXml(\SoapVar $object) { if (isset($object->enc_value->fieldsToNull) && is_array($object->enc_value->fieldsToNull) && count($object->enc_value->fieldsToNull) > 0) { $xml = ''; foreach ($object->enc_value->fieldsToNull as $fieldToNull) { $xml .= '<fieldsToNull>' . $fieldToNull . '</fieldsToNull>'; } return new \SoapVar(new \SoapVar($xml, XSD_ANYXML), SOAP_ENC_ARRAY); } }
[ "protected", "function", "fixFieldsToNullXml", "(", "\\", "SoapVar", "$", "object", ")", "{", "if", "(", "isset", "(", "$", "object", "->", "enc_value", "->", "fieldsToNull", ")", "&&", "is_array", "(", "$", "object", "->", "enc_value", "->", "fieldsToNull",...
Fix the fieldsToNull property for sObjects @param \SoapVar $object @return \SoapVar
[ "Fix", "the", "fieldsToNull", "property", "for", "sObjects" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L489-L501
43,601
phpforce/soap-client
src/Phpforce/SoapClient/Client.php
Client.checkResult
protected function checkResult(array $results, array $params) { $exceptions = new Exception\SaveException(); for ($i = 0; $i < count($results); $i++) { // If the param was an (s)object, set it’s Id field if (is_object($params[$i]) && (!isset($params[$i]->Id) || null === $params[$i]->Id) && $results[$i] instanceof Result\SaveResult) { $params[$i]->Id = $results[$i]->getId(); } if (!$results[$i]->isSuccess()) { $results[$i]->setParam($params[$i]); $exceptions->add($results[$i]); } } if ($exceptions->count() > 0) { throw $exceptions; } return $results; }
php
protected function checkResult(array $results, array $params) { $exceptions = new Exception\SaveException(); for ($i = 0; $i < count($results); $i++) { // If the param was an (s)object, set it’s Id field if (is_object($params[$i]) && (!isset($params[$i]->Id) || null === $params[$i]->Id) && $results[$i] instanceof Result\SaveResult) { $params[$i]->Id = $results[$i]->getId(); } if (!$results[$i]->isSuccess()) { $results[$i]->setParam($params[$i]); $exceptions->add($results[$i]); } } if ($exceptions->count() > 0) { throw $exceptions; } return $results; }
[ "protected", "function", "checkResult", "(", "array", "$", "results", ",", "array", "$", "params", ")", "{", "$", "exceptions", "=", "new", "Exception", "\\", "SaveException", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count"...
Check response for errors Add each submitted object to its corresponding success or error message @param array $results Results @param array $params Parameters @throws Exception\SaveException When Salesforce returned an error @return array
[ "Check", "response", "for", "errors" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L514-L538
43,602
phpforce/soap-client
src/Phpforce/SoapClient/Client.php
Client.setSoapHeaders
protected function setSoapHeaders(array $headers) { $soapHeaderObjects = array(); foreach ($headers as $key => $value) { $soapHeaderObjects[] = new \SoapHeader(self::SOAP_NAMESPACE, $key, $value); } $this->soapClient->__setSoapHeaders($soapHeaderObjects); }
php
protected function setSoapHeaders(array $headers) { $soapHeaderObjects = array(); foreach ($headers as $key => $value) { $soapHeaderObjects[] = new \SoapHeader(self::SOAP_NAMESPACE, $key, $value); } $this->soapClient->__setSoapHeaders($soapHeaderObjects); }
[ "protected", "function", "setSoapHeaders", "(", "array", "$", "headers", ")", "{", "$", "soapHeaderObjects", "=", "array", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "soapHeaderObjects", "[", "]", ...
Set soap headers @param array $headers
[ "Set", "soap", "headers" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L598-L606
43,603
phpforce/soap-client
src/Phpforce/SoapClient/Client.php
Client.createSObject
protected function createSObject($object, $objectType) { $sObject = new \stdClass(); foreach (get_object_vars($object) as $field => $value) { $type = $this->soapClient->getSoapElementType($objectType, $field); if ($field != 'Id' && !$type) { continue; } if ($value === null) { $sObject->fieldsToNull[] = $field; continue; } // As PHP \DateTime to SOAP dateTime conversion is not done // automatically with the SOAP typemap for sObjects, we do it here. switch ($type) { case 'date': if ($value instanceof \DateTime) { $value = $value->format('Y-m-d'); } break; case 'dateTime': if ($value instanceof \DateTime) { $value = $value->format('Y-m-d\TH:i:sP'); } break; case 'base64Binary': $value = base64_encode($value); break; } $sObject->$field = $value; } return $sObject; }
php
protected function createSObject($object, $objectType) { $sObject = new \stdClass(); foreach (get_object_vars($object) as $field => $value) { $type = $this->soapClient->getSoapElementType($objectType, $field); if ($field != 'Id' && !$type) { continue; } if ($value === null) { $sObject->fieldsToNull[] = $field; continue; } // As PHP \DateTime to SOAP dateTime conversion is not done // automatically with the SOAP typemap for sObjects, we do it here. switch ($type) { case 'date': if ($value instanceof \DateTime) { $value = $value->format('Y-m-d'); } break; case 'dateTime': if ($value instanceof \DateTime) { $value = $value->format('Y-m-d\TH:i:sP'); } break; case 'base64Binary': $value = base64_encode($value); break; } $sObject->$field = $value; } return $sObject; }
[ "protected", "function", "createSObject", "(", "$", "object", ",", "$", "objectType", ")", "{", "$", "sObject", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "object", ")", "as", "$", "field", "=>", "$", "val...
Create a Salesforce object Converts PHP \DateTimes to their SOAP equivalents. @param object $object Any object with public properties @param string $objectType Salesforce object type @return object
[ "Create", "a", "Salesforce", "object" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Client.php#L662-L699
43,604
phpforce/soap-client
src/Phpforce/SoapClient/Result/RecordIterator.php
RecordIterator.getObjectAt
protected function getObjectAt($pointer) { if ($this->queryResult->getRecord($pointer)) { $this->current = $this->queryResult->getRecord($pointer); foreach ($this->current as $key => &$value) { if ($value instanceof QueryResult) { $value = new RecordIterator($this->client, $value); } } return $this->current; } // If no record was found at pointer, see if there are more records // available for querying if (!$this->queryResult->isDone()) { $this->queryMore(); return $this->getObjectAt($this->pointer); } }
php
protected function getObjectAt($pointer) { if ($this->queryResult->getRecord($pointer)) { $this->current = $this->queryResult->getRecord($pointer); foreach ($this->current as $key => &$value) { if ($value instanceof QueryResult) { $value = new RecordIterator($this->client, $value); } } return $this->current; } // If no record was found at pointer, see if there are more records // available for querying if (!$this->queryResult->isDone()) { $this->queryMore(); return $this->getObjectAt($this->pointer); } }
[ "protected", "function", "getObjectAt", "(", "$", "pointer", ")", "{", "if", "(", "$", "this", "->", "queryResult", "->", "getRecord", "(", "$", "pointer", ")", ")", "{", "$", "this", "->", "current", "=", "$", "this", "->", "queryResult", "->", "getRe...
Get record at pointer, or, if there is no record, try to query Salesforce for more records @param int $pointer @return object
[ "Get", "record", "at", "pointer", "or", "if", "there", "is", "no", "record", "try", "to", "query", "Salesforce", "for", "more", "records" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Result/RecordIterator.php#L74-L95
43,605
phpforce/soap-client
src/Phpforce/SoapClient/Result/RecordIterator.php
RecordIterator.queryMore
protected function queryMore() { $result = $this->client->queryMore($this->queryResult->getQueryLocator()); $this->setQueryResult($result); $this->rewind(); }
php
protected function queryMore() { $result = $this->client->queryMore($this->queryResult->getQueryLocator()); $this->setQueryResult($result); $this->rewind(); }
[ "protected", "function", "queryMore", "(", ")", "{", "$", "result", "=", "$", "this", "->", "client", "->", "queryMore", "(", "$", "this", "->", "queryResult", "->", "getQueryLocator", "(", ")", ")", ";", "$", "this", "->", "setQueryResult", "(", "$", ...
Query Salesforce for more records and rewind iterator
[ "Query", "Salesforce", "for", "more", "records", "and", "rewind", "iterator" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Result/RecordIterator.php#L161-L166
43,606
phpforce/soap-client
src/Phpforce/SoapClient/Result/RecordIterator.php
RecordIterator.sort
public function sort($by) { $by = ucfirst($by); $array = $this->queryResult->getRecords(); usort($array, function($a, $b) use ($by) { // These two ifs take care of moving empty values to the end of the // array instead of the beginning if (!isset($a->$by) || !$a->$by) { return 1; } if (!isset($b->$by) || !$b->$by) { return -1; } return strcmp($a->$by, $b->$by); }); return new \ArrayIterator($array); }
php
public function sort($by) { $by = ucfirst($by); $array = $this->queryResult->getRecords(); usort($array, function($a, $b) use ($by) { // These two ifs take care of moving empty values to the end of the // array instead of the beginning if (!isset($a->$by) || !$a->$by) { return 1; } if (!isset($b->$by) || !$b->$by) { return -1; } return strcmp($a->$by, $b->$by); }); return new \ArrayIterator($array); }
[ "public", "function", "sort", "(", "$", "by", ")", "{", "$", "by", "=", "ucfirst", "(", "$", "by", ")", ";", "$", "array", "=", "$", "this", "->", "queryResult", "->", "getRecords", "(", ")", ";", "usort", "(", "$", "array", ",", "function", "(",...
Get sorted result iterator for the records on the current page Note: this method will not query Salesforce for records outside the current page. If you wish to sort larger sets of Salesforce records, do so in the select query you issue to the Salesforce API. @param string $by @return \ArrayIterator
[ "Get", "sorted", "result", "iterator", "for", "the", "records", "on", "the", "current", "page" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Result/RecordIterator.php#L197-L216
43,607
phpforce/soap-client
src/Phpforce/SoapClient/Soap/SoapClient.php
SoapClient.getSoapTypes
public function getSoapTypes() { if (null === $this->types) { $soapTypes = $this->__getTypes(); foreach ($soapTypes as $soapType) { $properties = array(); $lines = explode("\n", $soapType); if (!preg_match('/struct (.*) {/', $lines[0], $matches)) { continue; } $typeName = $matches[1]; foreach (array_slice($lines, 1) as $line) { if ($line == '}') { continue; } preg_match('/\s* (.*) (.*);/', $line, $matches); $properties[$matches[2]] = $matches[1]; } // Since every object extends sObject, need to append sObject elements to all native and custom objects if ($typeName !== 'sObject' && array_key_exists('sObject', $this->types)) { $properties = array_merge($properties, $this->types['sObject']); } $this->types[$typeName] = $properties; } } return $this->types; }
php
public function getSoapTypes() { if (null === $this->types) { $soapTypes = $this->__getTypes(); foreach ($soapTypes as $soapType) { $properties = array(); $lines = explode("\n", $soapType); if (!preg_match('/struct (.*) {/', $lines[0], $matches)) { continue; } $typeName = $matches[1]; foreach (array_slice($lines, 1) as $line) { if ($line == '}') { continue; } preg_match('/\s* (.*) (.*);/', $line, $matches); $properties[$matches[2]] = $matches[1]; } // Since every object extends sObject, need to append sObject elements to all native and custom objects if ($typeName !== 'sObject' && array_key_exists('sObject', $this->types)) { $properties = array_merge($properties, $this->types['sObject']); } $this->types[$typeName] = $properties; } } return $this->types; }
[ "public", "function", "getSoapTypes", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "types", ")", "{", "$", "soapTypes", "=", "$", "this", "->", "__getTypes", "(", ")", ";", "foreach", "(", "$", "soapTypes", "as", "$", "soapType", ")", ...
Retrieve SOAP types from the WSDL and parse them @return array Array of types and their properties
[ "Retrieve", "SOAP", "types", "from", "the", "WSDL", "and", "parse", "them" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Soap/SoapClient.php#L23-L54
43,608
phpforce/soap-client
src/Phpforce/SoapClient/Soap/SoapClient.php
SoapClient.getSoapElements
public function getSoapElements($complexType) { $types = $this->getSoapTypes(); if (isset($types[$complexType])) { return $types[$complexType]; } }
php
public function getSoapElements($complexType) { $types = $this->getSoapTypes(); if (isset($types[$complexType])) { return $types[$complexType]; } }
[ "public", "function", "getSoapElements", "(", "$", "complexType", ")", "{", "$", "types", "=", "$", "this", "->", "getSoapTypes", "(", ")", ";", "if", "(", "isset", "(", "$", "types", "[", "$", "complexType", "]", ")", ")", "{", "return", "$", "types...
Get SOAP elements for a complexType @param string $complexType Name of SOAP complexType @return array Names of elements and their types
[ "Get", "SOAP", "elements", "for", "a", "complexType" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Soap/SoapClient.php#L70-L76
43,609
phpforce/soap-client
src/Phpforce/SoapClient/ClientBuilder.php
ClientBuilder.build
public function build() { $soapClientFactory = new SoapClientFactory(); $soapClient = $soapClientFactory->factory($this->wsdl, $this->soapOptions); $client = new Client($soapClient, $this->username, $this->password, $this->token); if ($this->log) { $logPlugin = new LogPlugin($this->log); $client->getEventDispatcher()->addSubscriber($logPlugin); } return $client; }
php
public function build() { $soapClientFactory = new SoapClientFactory(); $soapClient = $soapClientFactory->factory($this->wsdl, $this->soapOptions); $client = new Client($soapClient, $this->username, $this->password, $this->token); if ($this->log) { $logPlugin = new LogPlugin($this->log); $client->getEventDispatcher()->addSubscriber($logPlugin); } return $client; }
[ "public", "function", "build", "(", ")", "{", "$", "soapClientFactory", "=", "new", "SoapClientFactory", "(", ")", ";", "$", "soapClient", "=", "$", "soapClientFactory", "->", "factory", "(", "$", "this", "->", "wsdl", ",", "$", "this", "->", "soapOptions"...
Build the Salesforce SOAP client @return Client
[ "Build", "the", "Salesforce", "SOAP", "client" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/ClientBuilder.php#L54-L67
43,610
phpforce/soap-client
src/Phpforce/SoapClient/Soap/TypeConverter/TypeConverterCollection.php
TypeConverterCollection.getTypemap
public function getTypemap() { $typemap = array(); foreach ($this->converters as $converter) { $typemap[] = array( 'type_name' => $converter->getTypeName(), 'type_ns' => $converter->getTypeNamespace(), 'from_xml' => function($input) use ($converter) { return $converter->convertXmlToPhp($input); }, 'to_xml' => function($input) use ($converter) { return $converter->convertPhpToXml($input); }, ); } return $typemap; }
php
public function getTypemap() { $typemap = array(); foreach ($this->converters as $converter) { $typemap[] = array( 'type_name' => $converter->getTypeName(), 'type_ns' => $converter->getTypeNamespace(), 'from_xml' => function($input) use ($converter) { return $converter->convertXmlToPhp($input); }, 'to_xml' => function($input) use ($converter) { return $converter->convertPhpToXml($input); }, ); } return $typemap; }
[ "public", "function", "getTypemap", "(", ")", "{", "$", "typemap", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "converters", "as", "$", "converter", ")", "{", "$", "typemap", "[", "]", "=", "array", "(", "'type_name'", "=>", "$", ...
Get this collection as a typemap that can be used in PHP's \SoapClient @return array
[ "Get", "this", "collection", "as", "a", "typemap", "that", "can", "be", "used", "in", "PHP", "s", "\\", "SoapClient" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/Soap/TypeConverter/TypeConverterCollection.php#L83-L101
43,611
phpforce/soap-client
src/Phpforce/SoapClient/BulkSaver.php
BulkSaver.save
public function save($record, $objectType, $matchField = null) { if ($matchField) { $this->addBulkUpsertRecord($record, $objectType, $matchField); } elseif (isset($record->Id) && null !== $record->Id) { $this->addBulkUpdateRecord($record, $objectType); } else { $this->addBulkCreateRecord($record, $objectType); } return $this; }
php
public function save($record, $objectType, $matchField = null) { if ($matchField) { $this->addBulkUpsertRecord($record, $objectType, $matchField); } elseif (isset($record->Id) && null !== $record->Id) { $this->addBulkUpdateRecord($record, $objectType); } else { $this->addBulkCreateRecord($record, $objectType); } return $this; }
[ "public", "function", "save", "(", "$", "record", ",", "$", "objectType", ",", "$", "matchField", "=", "null", ")", "{", "if", "(", "$", "matchField", ")", "{", "$", "this", "->", "addBulkUpsertRecord", "(", "$", "record", ",", "$", "objectType", ",", ...
Save a record in bulk @param mixed $record @param string $objectType The record type, e.g., Account @param string $matchField Optional match field for upserts @return BulkSaver
[ "Save", "a", "record", "in", "bulk" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/BulkSaver.php#L61-L72
43,612
phpforce/soap-client
src/Phpforce/SoapClient/BulkSaver.php
BulkSaver.addBulkCreateRecord
private function addBulkCreateRecord($record, $objectType) { if (isset($this->bulkCreateRecords[$objectType]) && count($this->bulkCreateRecords[$objectType]) == $this->bulkSaveLimit) { $this->flushCreates($objectType); } $this->bulkCreateRecords[$objectType][] = $record; }
php
private function addBulkCreateRecord($record, $objectType) { if (isset($this->bulkCreateRecords[$objectType]) && count($this->bulkCreateRecords[$objectType]) == $this->bulkSaveLimit) { $this->flushCreates($objectType); } $this->bulkCreateRecords[$objectType][] = $record; }
[ "private", "function", "addBulkCreateRecord", "(", "$", "record", ",", "$", "objectType", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "bulkCreateRecords", "[", "$", "objectType", "]", ")", "&&", "count", "(", "$", "this", "->", "bulkCreateRecords...
Add a record to the create queue @param sObject $sObject @param type $objectType
[ "Add", "a", "record", "to", "the", "create", "queue" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/BulkSaver.php#L171-L179
43,613
phpforce/soap-client
src/Phpforce/SoapClient/BulkSaver.php
BulkSaver.addBulkDeleteRecord
private function addBulkDeleteRecord($record) { if ($this->bulkDeleteLimit === count($this->bulkDeleteRecords)) { $this->flushDeletes(); } $this->bulkDeleteRecords[] = $record; }
php
private function addBulkDeleteRecord($record) { if ($this->bulkDeleteLimit === count($this->bulkDeleteRecords)) { $this->flushDeletes(); } $this->bulkDeleteRecords[] = $record; }
[ "private", "function", "addBulkDeleteRecord", "(", "$", "record", ")", "{", "if", "(", "$", "this", "->", "bulkDeleteLimit", "===", "count", "(", "$", "this", "->", "bulkDeleteRecords", ")", ")", "{", "$", "this", "->", "flushDeletes", "(", ")", ";", "}"...
Add a record id to the bulk delete queue (Delete calls @param string $id
[ "Add", "a", "record", "id", "to", "the", "bulk", "delete", "queue" ]
df1d06533d28b34bf7e1a8eb4c6b43316ea25b56
https://github.com/phpforce/soap-client/blob/df1d06533d28b34bf7e1a8eb4c6b43316ea25b56/src/Phpforce/SoapClient/BulkSaver.php#L188-L195
43,614
alt3/cakephp-swagger
src/Shell/SwaggerShell.php
SwaggerShell.getOptionParser
public function getOptionParser() { $parser = parent::getOptionParser(); $parser->addSubcommand('makedocs', [ 'description' => __('Crawl-generate fresh swagger file system documents for all entries found in the library.') ]) ->addArgument('host', [ 'help' => __("Swagger host FQDN (without protocol) as to be inserted into the swagger doc property 'host'"), 'required' => true ]); return $parser; }
php
public function getOptionParser() { $parser = parent::getOptionParser(); $parser->addSubcommand('makedocs', [ 'description' => __('Crawl-generate fresh swagger file system documents for all entries found in the library.') ]) ->addArgument('host', [ 'help' => __("Swagger host FQDN (without protocol) as to be inserted into the swagger doc property 'host'"), 'required' => true ]); return $parser; }
[ "public", "function", "getOptionParser", "(", ")", "{", "$", "parser", "=", "parent", "::", "getOptionParser", "(", ")", ";", "$", "parser", "->", "addSubcommand", "(", "'makedocs'", ",", "[", "'description'", "=>", "__", "(", "'Crawl-generate fresh swagger file...
Define available subcommands, arguments and options. @return \Cake\Console\ConsoleOptionParser @throws \Aura\Intl\Exception
[ "Define", "available", "subcommands", "arguments", "and", "options", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Shell/SwaggerShell.php#L20-L33
43,615
alt3/cakephp-swagger
src/Shell/SwaggerShell.php
SwaggerShell.makedocs
public function makedocs($host) { // make same configuration as used by the API availble inside the lib if (Configure::read('Swagger')) { $this->config = Hash::merge(AppController::$defaultConfig, Configure::read('Swagger')); } $this->out('Crawl-generating swagger documents...'); SwaggerTools::makeDocs($host); $this->out('Command completed successfully.'); }
php
public function makedocs($host) { // make same configuration as used by the API availble inside the lib if (Configure::read('Swagger')) { $this->config = Hash::merge(AppController::$defaultConfig, Configure::read('Swagger')); } $this->out('Crawl-generating swagger documents...'); SwaggerTools::makeDocs($host); $this->out('Command completed successfully.'); }
[ "public", "function", "makedocs", "(", "$", "host", ")", "{", "// make same configuration as used by the API availble inside the lib", "if", "(", "Configure", "::", "read", "(", "'Swagger'", ")", ")", "{", "$", "this", "->", "config", "=", "Hash", "::", "merge", ...
Generate fresh filesystem documents for all entries found in the library. @param string $host Hostname of system serving swagger documents (without protocol) @return void
[ "Generate", "fresh", "filesystem", "documents", "for", "all", "entries", "found", "in", "the", "library", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Shell/SwaggerShell.php#L41-L51
43,616
alt3/cakephp-swagger
src/Controller/UiController.php
UiController.index
public function index() { $this->viewBuilder()->setLayout(false); $this->set('uiConfig', $this->config['ui']); $this->set('url', $this->getDefaultDocumentUrl()); }
php
public function index() { $this->viewBuilder()->setLayout(false); $this->set('uiConfig', $this->config['ui']); $this->set('url', $this->getDefaultDocumentUrl()); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "viewBuilder", "(", ")", "->", "setLayout", "(", "false", ")", ";", "$", "this", "->", "set", "(", "'uiConfig'", ",", "$", "this", "->", "config", "[", "'ui'", "]", ")", ";", "$", "...
Index action used for setting template variables. @return void
[ "Index", "action", "used", "for", "setting", "template", "variables", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Controller/UiController.php#L16-L21
43,617
alt3/cakephp-swagger
src/Controller/DocsController.php
DocsController.addCorsHeaders
protected function addCorsHeaders() { // set CORS headers if specified in config if (!isset($this->config['docs']['cors'])) { return false; } if (!count($this->config['docs']['cors'])) { return false; } foreach ($this->config['docs']['cors'] as $header => $value) { $this->response = $this->response->withHeader($header, $value); } }
php
protected function addCorsHeaders() { // set CORS headers if specified in config if (!isset($this->config['docs']['cors'])) { return false; } if (!count($this->config['docs']['cors'])) { return false; } foreach ($this->config['docs']['cors'] as $header => $value) { $this->response = $this->response->withHeader($header, $value); } }
[ "protected", "function", "addCorsHeaders", "(", ")", "{", "// set CORS headers if specified in config", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'docs'", "]", "[", "'cors'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "("...
Set CORS headers if found in configuration. @return bool|void
[ "Set", "CORS", "headers", "if", "found", "in", "configuration", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Controller/DocsController.php#L83-L97
43,618
alt3/cakephp-swagger
src/Controller/DocsController.php
DocsController.jsonResponse
protected function jsonResponse($json) { $this->set('json', $json); $this->viewBuilder()->setLayout(false); $this->addCorsHeaders(); $this->response = $this->response->withType('json'); }
php
protected function jsonResponse($json) { $this->set('json', $json); $this->viewBuilder()->setLayout(false); $this->addCorsHeaders(); $this->response = $this->response->withType('json'); }
[ "protected", "function", "jsonResponse", "(", "$", "json", ")", "{", "$", "this", "->", "set", "(", "'json'", ",", "$", "json", ")", ";", "$", "this", "->", "viewBuilder", "(", ")", "->", "setLayout", "(", "false", ")", ";", "$", "this", "->", "add...
Configures the json response before calling the index view. @param string $json JSON encoded string @return void
[ "Configures", "the", "json", "response", "before", "calling", "the", "index", "view", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Controller/DocsController.php#L105-L111
43,619
alt3/cakephp-swagger
src/Lib/SwaggerTools.php
SwaggerTools.getSwaggerDocument
public static function getSwaggerDocument($id, $host) { // load document from filesystem $filePath = CACHE . self::$filePrefix . $id . '.json'; if (!Configure::read('Swagger.docs.crawl')) { if (!file_exists($filePath)) { throw new NotFoundException("Swagger json document was not found on filesystem: $filePath"); } $fh = new File($filePath); return $fh->read(); } // otherwise crawl-generate a fresh document $swaggerOptions = []; if (Configure::read("Swagger.library.$id.exclude")) { $swaggerOptions = [ 'exclude' => Configure::read("Swagger.library.$id.exclude") ]; } if (Configure::read('Swagger.analyser')) { $swaggerOptions['analyser'] = Configure::read('Swagger.analyser'); } $swagger = \Swagger\scan(Configure::read("Swagger.library.$id.include"), $swaggerOptions); // set object properties required by UI to generate the BASE URL $swagger->host = $host; if (empty($swagger->basePath)) { $swagger->basePath = '/' . Configure::read('App.base'); } $swagger->schemes = Configure::read('Swagger.ui.schemes'); // write document to filesystem self::writeSwaggerDocumentToFile($filePath, $swagger); return $swagger; }
php
public static function getSwaggerDocument($id, $host) { // load document from filesystem $filePath = CACHE . self::$filePrefix . $id . '.json'; if (!Configure::read('Swagger.docs.crawl')) { if (!file_exists($filePath)) { throw new NotFoundException("Swagger json document was not found on filesystem: $filePath"); } $fh = new File($filePath); return $fh->read(); } // otherwise crawl-generate a fresh document $swaggerOptions = []; if (Configure::read("Swagger.library.$id.exclude")) { $swaggerOptions = [ 'exclude' => Configure::read("Swagger.library.$id.exclude") ]; } if (Configure::read('Swagger.analyser')) { $swaggerOptions['analyser'] = Configure::read('Swagger.analyser'); } $swagger = \Swagger\scan(Configure::read("Swagger.library.$id.include"), $swaggerOptions); // set object properties required by UI to generate the BASE URL $swagger->host = $host; if (empty($swagger->basePath)) { $swagger->basePath = '/' . Configure::read('App.base'); } $swagger->schemes = Configure::read('Swagger.ui.schemes'); // write document to filesystem self::writeSwaggerDocumentToFile($filePath, $swagger); return $swagger; }
[ "public", "static", "function", "getSwaggerDocument", "(", "$", "id", ",", "$", "host", ")", "{", "// load document from filesystem", "$", "filePath", "=", "CACHE", ".", "self", "::", "$", "filePrefix", ".", "$", "id", ".", "'.json'", ";", "if", "(", "!", ...
Returns a single swagger document from filesystem or crawl-generates a fresh one. @param string $id Name of the document @param string $host Hostname of system serving swagger documents (without protocol) @throws \InvalidArgumentException @return string
[ "Returns", "a", "single", "swagger", "document", "from", "filesystem", "or", "crawl", "-", "generates", "a", "fresh", "one", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Lib/SwaggerTools.php#L26-L62
43,620
alt3/cakephp-swagger
src/Lib/SwaggerTools.php
SwaggerTools.writeSwaggerDocumentToFile
protected static function writeSwaggerDocumentToFile($path, $content) { $fh = new File($path, true); if (!$fh->write($content)) { throw new InternalErrorException('Error writing Swagger json document to filesystem'); } return true; }
php
protected static function writeSwaggerDocumentToFile($path, $content) { $fh = new File($path, true); if (!$fh->write($content)) { throw new InternalErrorException('Error writing Swagger json document to filesystem'); } return true; }
[ "protected", "static", "function", "writeSwaggerDocumentToFile", "(", "$", "path", ",", "$", "content", ")", "{", "$", "fh", "=", "new", "File", "(", "$", "path", ",", "true", ")", ";", "if", "(", "!", "$", "fh", "->", "write", "(", "$", "content", ...
Write swagger document to filesystem. @param string $path Full path to the json document including filename @param string $content Swagger content @throws \Cake\Http\Exception\InternalErrorException @return bool
[ "Write", "swagger", "document", "to", "filesystem", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Lib/SwaggerTools.php#L72-L80
43,621
alt3/cakephp-swagger
src/Lib/SwaggerTools.php
SwaggerTools.makeDocs
public static function makeDocs($host) { if (!Configure::read('Swagger.library')) { throw new \InvalidArgumentException('Swagger configuration file does not contain a library section'); } // make sure documents will be crawled and not read from filesystem Configure::write('Swagger.docs.crawl', true); // generate docs foreach (array_keys(Configure::read('Swagger.library')) as $doc) { self::getSwaggerDocument($doc, $host); } return true; }
php
public static function makeDocs($host) { if (!Configure::read('Swagger.library')) { throw new \InvalidArgumentException('Swagger configuration file does not contain a library section'); } // make sure documents will be crawled and not read from filesystem Configure::write('Swagger.docs.crawl', true); // generate docs foreach (array_keys(Configure::read('Swagger.library')) as $doc) { self::getSwaggerDocument($doc, $host); } return true; }
[ "public", "static", "function", "makeDocs", "(", "$", "host", ")", "{", "if", "(", "!", "Configure", "::", "read", "(", "'Swagger.library'", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Swagger configuration file does not contain a library...
Convenience function used by the shell to create filesystem documents for all entries found in the library. @param string $host Hostname of system serving swagger documents (without protocol) @throws \InvalidArgumentException @return bool true if successful, false on all errors
[ "Convenience", "function", "used", "by", "the", "shell", "to", "create", "filesystem", "documents", "for", "all", "entries", "found", "in", "the", "library", "." ]
8cc7b03d0bd560e080d3001e381bcd3d22e85ceb
https://github.com/alt3/cakephp-swagger/blob/8cc7b03d0bd560e080d3001e381bcd3d22e85ceb/src/Lib/SwaggerTools.php#L90-L105
43,622
rainlab/location-plugin
models/Country.php
Country.getFromIp
public static function getFromIp($ipAddress) { try { $body = (string) Http::get('http://ip2c.org/?ip='.$ipAddress); if (substr($body, 0, 1) === '1') { $code = explode(';', $body)[1]; return static::where('code', $code)->first(); } } catch (Exception $e) {} }
php
public static function getFromIp($ipAddress) { try { $body = (string) Http::get('http://ip2c.org/?ip='.$ipAddress); if (substr($body, 0, 1) === '1') { $code = explode(';', $body)[1]; return static::where('code', $code)->first(); } } catch (Exception $e) {} }
[ "public", "static", "function", "getFromIp", "(", "$", "ipAddress", ")", "{", "try", "{", "$", "body", "=", "(", "string", ")", "Http", "::", "get", "(", "'http://ip2c.org/?ip='", ".", "$", "ipAddress", ")", ";", "if", "(", "substr", "(", "$", "body", ...
Attempts to find a country from the IP address. @param string $ipAddress @return self
[ "Attempts", "to", "find", "a", "country", "from", "the", "IP", "address", "." ]
fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3
https://github.com/rainlab/location-plugin/blob/fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3/models/Country.php#L96-L107
43,623
rainlab/location-plugin
behaviors/LocationModel.php
LocationModel.setCountryCodeAttribute
public function setCountryCodeAttribute($code) { if (!$country = Country::whereCode($code)->first()) { return; } $this->model->country = $country; }
php
public function setCountryCodeAttribute($code) { if (!$country = Country::whereCode($code)->first()) { return; } $this->model->country = $country; }
[ "public", "function", "setCountryCodeAttribute", "(", "$", "code", ")", "{", "if", "(", "!", "$", "country", "=", "Country", "::", "whereCode", "(", "$", "code", ")", "->", "first", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "model", ...
Sets the "country" relation with the code specified, model lookup used. @param string $code
[ "Sets", "the", "country", "relation", "with", "the", "code", "specified", "model", "lookup", "used", "." ]
fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3
https://github.com/rainlab/location-plugin/blob/fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3/behaviors/LocationModel.php#L62-L69
43,624
rainlab/location-plugin
behaviors/LocationModel.php
LocationModel.setStateCodeAttribute
public function setStateCodeAttribute($code) { if (!$state = State::whereCode($code)->first()) { return; } $this->model->state = $state; }
php
public function setStateCodeAttribute($code) { if (!$state = State::whereCode($code)->first()) { return; } $this->model->state = $state; }
[ "public", "function", "setStateCodeAttribute", "(", "$", "code", ")", "{", "if", "(", "!", "$", "state", "=", "State", "::", "whereCode", "(", "$", "code", ")", "->", "first", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "model", "->"...
Sets the "state" relation with the code specified, model lookup used. @param string $code
[ "Sets", "the", "state", "relation", "with", "the", "code", "specified", "model", "lookup", "used", "." ]
fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3
https://github.com/rainlab/location-plugin/blob/fe80d08c8f1e4a4415c608e2df2a28fd0d8bd3a3/behaviors/LocationModel.php#L75-L82
43,625
himiklab/yii2-sitemap-module
Sitemap.php
Sitemap.buildSitemap
public function buildSitemap() { $urls = $this->urls; foreach ($this->models as $modelName) { /** @var behaviors\SitemapBehavior|\yii\db\ActiveRecord $model */ if (is_array($modelName)) { $model = new $modelName['class']; if (isset($modelName['behaviors'])) { $model->attachBehaviors($modelName['behaviors']); } } else { $model = new $modelName; } $urls = array_merge($urls, $model->generateSiteMap()); } $sitemapData = $this->createControllerByID('default')->renderPartial('index', ['urls' => $urls]); if ($this->enableGzipedCache) { $sitemapData = gzencode($sitemapData); } $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire); return $sitemapData; }
php
public function buildSitemap() { $urls = $this->urls; foreach ($this->models as $modelName) { /** @var behaviors\SitemapBehavior|\yii\db\ActiveRecord $model */ if (is_array($modelName)) { $model = new $modelName['class']; if (isset($modelName['behaviors'])) { $model->attachBehaviors($modelName['behaviors']); } } else { $model = new $modelName; } $urls = array_merge($urls, $model->generateSiteMap()); } $sitemapData = $this->createControllerByID('default')->renderPartial('index', ['urls' => $urls]); if ($this->enableGzipedCache) { $sitemapData = gzencode($sitemapData); } $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire); return $sitemapData; }
[ "public", "function", "buildSitemap", "(", ")", "{", "$", "urls", "=", "$", "this", "->", "urls", ";", "foreach", "(", "$", "this", "->", "models", "as", "$", "modelName", ")", "{", "/** @var behaviors\\SitemapBehavior|\\yii\\db\\ActiveRecord $model */", "if", "...
Build and cache a site map. @return string @throws \yii\base\InvalidConfigException @throws \yii\base\InvalidParamException
[ "Build", "and", "cache", "a", "site", "map", "." ]
e680cb50049102c47342d27f497f77d8c0e447b3
https://github.com/himiklab/yii2-sitemap-module/blob/e680cb50049102c47342d27f497f77d8c0e447b3/Sitemap.php#L65-L89
43,626
pantheon-systems/terminus-rsync-plugin
src/Commands/RsyncCommand.php
RsyncCommand.rsyncCommand
public function rsyncCommand($src, $dest, array $rsyncOptions) { if (strpos($src, ':') !== false) { $site_env_id = $this->getSiteEnvIdFromPath($src); $src = $this->removeSiteEnvIdFromPath($src); } else { $site_env_id = $this->getSiteEnvIdFromPath($dest); $dest = $this->removeSiteEnvIdFromPath($dest); } return $this->rsync($site_env_id, $src, $dest, $rsyncOptions); }
php
public function rsyncCommand($src, $dest, array $rsyncOptions) { if (strpos($src, ':') !== false) { $site_env_id = $this->getSiteEnvIdFromPath($src); $src = $this->removeSiteEnvIdFromPath($src); } else { $site_env_id = $this->getSiteEnvIdFromPath($dest); $dest = $this->removeSiteEnvIdFromPath($dest); } return $this->rsync($site_env_id, $src, $dest, $rsyncOptions); }
[ "public", "function", "rsyncCommand", "(", "$", "src", ",", "$", "dest", ",", "array", "$", "rsyncOptions", ")", "{", "if", "(", "strpos", "(", "$", "src", ",", "':'", ")", "!==", "false", ")", "{", "$", "site_env_id", "=", "$", "this", "->", "getS...
Call rsync on a Pantheon site @command remote:rsync @aliases rsync @param string $src Source path @param string $dest Destination path @param array $rsyncOptions All of the options after -- (passed to rsync)
[ "Call", "rsync", "on", "a", "Pantheon", "site" ]
2b94a3197409aece9a07303263ec26f521fa7ad7
https://github.com/pantheon-systems/terminus-rsync-plugin/blob/2b94a3197409aece9a07303263ec26f521fa7ad7/src/Commands/RsyncCommand.php#L45-L56
43,627
pantheon-systems/terminus-rsync-plugin
src/Commands/RsyncCommand.php
RsyncCommand.rsync
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions) { list($site, $env) = $this->getSiteEnv($site_env_id); $env_id = $env->getName(); $siteInfo = $site->serialize(); $site_id = $siteInfo['id']; // Stipulate the temporary directory to use iff the destination is remote. $tmpdir = ''; if ($dest[0] == ':') { $tmpdir = '~/tmp'; } $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:"; $src = preg_replace('/^:/', $siteAddress, $src); $dest = preg_replace('/^:/', $siteAddress, $dest); // Get the rsync options string. If the user did not pass // in any mode options (e.g. '-r'), then add in the default. $rsyncOptionString = implode(' ', $rsyncOptions); if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) { $rsyncOptionString = "-rlIpz $rsyncOptionString"; } // Add in a tmp-dir option if one was not already specified if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) { $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates"; } $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]); $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' "); }
php
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions) { list($site, $env) = $this->getSiteEnv($site_env_id); $env_id = $env->getName(); $siteInfo = $site->serialize(); $site_id = $siteInfo['id']; // Stipulate the temporary directory to use iff the destination is remote. $tmpdir = ''; if ($dest[0] == ':') { $tmpdir = '~/tmp'; } $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:"; $src = preg_replace('/^:/', $siteAddress, $src); $dest = preg_replace('/^:/', $siteAddress, $dest); // Get the rsync options string. If the user did not pass // in any mode options (e.g. '-r'), then add in the default. $rsyncOptionString = implode(' ', $rsyncOptions); if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) { $rsyncOptionString = "-rlIpz $rsyncOptionString"; } // Add in a tmp-dir option if one was not already specified if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) { $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates"; } $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]); $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' "); }
[ "protected", "function", "rsync", "(", "$", "site_env_id", ",", "$", "src", ",", "$", "dest", ",", "array", "$", "rsyncOptions", ")", "{", "list", "(", "$", "site", ",", "$", "env", ")", "=", "$", "this", "->", "getSiteEnv", "(", "$", "site_env_id", ...
Call rsync to or from the specified site. @param string $site_env_id Remote site @param string $src Source path to copy from. Start with ":" for remote. @param string $dest Destination path to copy to. Start with ":" for remote.
[ "Call", "rsync", "to", "or", "from", "the", "specified", "site", "." ]
2b94a3197409aece9a07303263ec26f521fa7ad7
https://github.com/pantheon-systems/terminus-rsync-plugin/blob/2b94a3197409aece9a07303263ec26f521fa7ad7/src/Commands/RsyncCommand.php#L65-L97
43,628
wp-cli/wp-cli-tests
features/bootstrap/FeatureContext.php
FeatureContext.get_vendor_dir
private static function get_vendor_dir() { static $vendor_dir = null; if ( null !== $vendor_dir ) { return $vendor_dir; } $paths = [ dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/bin/wp', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/bin/wp', dirname( dirname( __DIR__ ) ) . '/vendor/bin/wp', ]; foreach ( $paths as $path ) { if ( file_exists( $path ) && is_executable( $path ) ) { $vendor_dir = (string) realpath( dirname( $path ) ); break; } } if ( null === $vendor_dir ) { // Did not detect WP-CLI binary, so make a random guess. $vendor_dir = '/usr/local/bin'; } return $vendor_dir; }
php
private static function get_vendor_dir() { static $vendor_dir = null; if ( null !== $vendor_dir ) { return $vendor_dir; } $paths = [ dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/bin/wp', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/bin/wp', dirname( dirname( __DIR__ ) ) . '/vendor/bin/wp', ]; foreach ( $paths as $path ) { if ( file_exists( $path ) && is_executable( $path ) ) { $vendor_dir = (string) realpath( dirname( $path ) ); break; } } if ( null === $vendor_dir ) { // Did not detect WP-CLI binary, so make a random guess. $vendor_dir = '/usr/local/bin'; } return $vendor_dir; }
[ "private", "static", "function", "get_vendor_dir", "(", ")", "{", "static", "$", "vendor_dir", "=", "null", ";", "if", "(", "null", "!==", "$", "vendor_dir", ")", "{", "return", "$", "vendor_dir", ";", "}", "$", "paths", "=", "[", "dirname", "(", "dirn...
Get the path to the Composer vendor folder. @return string Absolute path to the Composer vendor folder.
[ "Get", "the", "path", "to", "the", "Composer", "vendor", "folder", "." ]
83b636fc7cb69ff257e025d1c855c190143a45db
https://github.com/wp-cli/wp-cli-tests/blob/83b636fc7cb69ff257e025d1c855c190143a45db/features/bootstrap/FeatureContext.php#L176-L202
43,629
wp-cli/wp-cli-tests
features/bootstrap/FeatureContext.php
FeatureContext.get_behat_internal_variables
private static function get_behat_internal_variables() { static $variables = null; if ( null !== $variables ) { return $variables; } $paths = [ dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/wp-cli/wp-cli/VERSION', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/VERSION', dirname( dirname( __DIR__ ) ) . '/vendor/wp-cli/wp-cli/VERSION', ]; $framework_root = dirname( dirname( __DIR__ ) ); foreach ( $paths as $path ) { if ( file_exists( $path ) ) { $framework_root = (string) realpath( dirname( $path ) ); break; } } $variables = [ 'FRAMEWORK_ROOT' => realpath( $framework_root ), 'SRC_DIR' => realpath( dirname( dirname( __DIR__ ) ) ), 'PROJECT_DIR' => realpath( dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) ), ]; return $variables; }
php
private static function get_behat_internal_variables() { static $variables = null; if ( null !== $variables ) { return $variables; } $paths = [ dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . '/wp-cli/wp-cli/VERSION', dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/VERSION', dirname( dirname( __DIR__ ) ) . '/vendor/wp-cli/wp-cli/VERSION', ]; $framework_root = dirname( dirname( __DIR__ ) ); foreach ( $paths as $path ) { if ( file_exists( $path ) ) { $framework_root = (string) realpath( dirname( $path ) ); break; } } $variables = [ 'FRAMEWORK_ROOT' => realpath( $framework_root ), 'SRC_DIR' => realpath( dirname( dirname( __DIR__ ) ) ), 'PROJECT_DIR' => realpath( dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) ), ]; return $variables; }
[ "private", "static", "function", "get_behat_internal_variables", "(", ")", "{", "static", "$", "variables", "=", "null", ";", "if", "(", "null", "!==", "$", "variables", ")", "{", "return", "$", "variables", ";", "}", "$", "paths", "=", "[", "dirname", "...
Get the internal variables to use within tests. @return array Associative array of internal variables that will be mapped into tests.
[ "Get", "the", "internal", "variables", "to", "use", "within", "tests", "." ]
83b636fc7cb69ff257e025d1c855c190143a45db
https://github.com/wp-cli/wp-cli-tests/blob/83b636fc7cb69ff257e025d1c855c190143a45db/features/bootstrap/FeatureContext.php#L261-L289
43,630
wp-cli/wp-cli-tests
features/bootstrap/FeatureContext.php
FeatureContext.cache_wp_files
private static function cache_wp_files() { $wp_version = getenv( 'WP_VERSION' ); $wp_version_suffix = ( false !== $wp_version ) ? "-$wp_version" : ''; self::$cache_dir = sys_get_temp_dir() . '/wp-cli-test-core-download-cache' . $wp_version_suffix; if ( is_readable( self::$cache_dir . '/wp-config-sample.php' ) ) { return; } $cmd = Utils\esc_cmd( 'wp core download --force --path=%s', self::$cache_dir ); if ( $wp_version ) { $cmd .= Utils\esc_cmd( ' --version=%s', $wp_version ); } Process::create( $cmd, null, self::get_process_env_variables() )->run_check(); }
php
private static function cache_wp_files() { $wp_version = getenv( 'WP_VERSION' ); $wp_version_suffix = ( false !== $wp_version ) ? "-$wp_version" : ''; self::$cache_dir = sys_get_temp_dir() . '/wp-cli-test-core-download-cache' . $wp_version_suffix; if ( is_readable( self::$cache_dir . '/wp-config-sample.php' ) ) { return; } $cmd = Utils\esc_cmd( 'wp core download --force --path=%s', self::$cache_dir ); if ( $wp_version ) { $cmd .= Utils\esc_cmd( ' --version=%s', $wp_version ); } Process::create( $cmd, null, self::get_process_env_variables() )->run_check(); }
[ "private", "static", "function", "cache_wp_files", "(", ")", "{", "$", "wp_version", "=", "getenv", "(", "'WP_VERSION'", ")", ";", "$", "wp_version_suffix", "=", "(", "false", "!==", "$", "wp_version", ")", "?", "\"-$wp_version\"", ":", "''", ";", "self", ...
We cache the results of `wp core download` to improve test performance. Ideally, we'd cache at the HTTP layer for more reliable tests.
[ "We", "cache", "the", "results", "of", "wp", "core", "download", "to", "improve", "test", "performance", ".", "Ideally", "we", "d", "cache", "at", "the", "HTTP", "layer", "for", "more", "reliable", "tests", "." ]
83b636fc7cb69ff257e025d1c855c190143a45db
https://github.com/wp-cli/wp-cli-tests/blob/83b636fc7cb69ff257e025d1c855c190143a45db/features/bootstrap/FeatureContext.php#L295-L309
43,631
wp-cli/wp-cli-tests
features/bootstrap/FeatureContext.php
FeatureContext.terminate_proc
private static function terminate_proc( $master_pid ) { $output = `ps -o ppid,pid,command | grep $master_pid`; foreach ( explode( PHP_EOL, $output ) as $line ) { if ( preg_match( '/^\s*(\d+)\s+(\d+)/', $line, $matches ) ) { $parent = $matches[1]; $child = $matches[2]; if ( (int) $parent === (int) $master_pid ) { self::terminate_proc( $child ); } } } if ( ! posix_kill( (int) $master_pid, 9 ) ) { $errno = posix_get_last_error(); // Ignore "No such process" error as that's what we want. if ( 3 /*ESRCH*/ !== $errno ) { throw new RuntimeException( posix_strerror( $errno ) ); } } }
php
private static function terminate_proc( $master_pid ) { $output = `ps -o ppid,pid,command | grep $master_pid`; foreach ( explode( PHP_EOL, $output ) as $line ) { if ( preg_match( '/^\s*(\d+)\s+(\d+)/', $line, $matches ) ) { $parent = $matches[1]; $child = $matches[2]; if ( (int) $parent === (int) $master_pid ) { self::terminate_proc( $child ); } } } if ( ! posix_kill( (int) $master_pid, 9 ) ) { $errno = posix_get_last_error(); // Ignore "No such process" error as that's what we want. if ( 3 /*ESRCH*/ !== $errno ) { throw new RuntimeException( posix_strerror( $errno ) ); } } }
[ "private", "static", "function", "terminate_proc", "(", "$", "master_pid", ")", "{", "$", "output", "=", "`ps -o ppid,pid,command | grep $master_pid`", ";", "foreach", "(", "explode", "(", "PHP_EOL", ",", "$", "output", ")", "as", "$", "line", ")", "{", "if", ...
Terminate a process and any of its children.
[ "Terminate", "a", "process", "and", "any", "of", "its", "children", "." ]
83b636fc7cb69ff257e025d1c855c190143a45db
https://github.com/wp-cli/wp-cli-tests/blob/83b636fc7cb69ff257e025d1c855c190143a45db/features/bootstrap/FeatureContext.php#L425-L447
43,632
wp-cli/wp-cli-tests
features/bootstrap/FeatureContext.php
FeatureContext.create_cache_dir
public static function create_cache_dir() { if ( self::$suite_cache_dir ) { self::remove_dir( self::$suite_cache_dir ); } self::$suite_cache_dir = sys_get_temp_dir() . '/' . uniqid( 'wp-cli-test-suite-cache-' . self::$temp_dir_infix . '-', true ); mkdir( self::$suite_cache_dir ); return self::$suite_cache_dir; }
php
public static function create_cache_dir() { if ( self::$suite_cache_dir ) { self::remove_dir( self::$suite_cache_dir ); } self::$suite_cache_dir = sys_get_temp_dir() . '/' . uniqid( 'wp-cli-test-suite-cache-' . self::$temp_dir_infix . '-', true ); mkdir( self::$suite_cache_dir ); return self::$suite_cache_dir; }
[ "public", "static", "function", "create_cache_dir", "(", ")", "{", "if", "(", "self", "::", "$", "suite_cache_dir", ")", "{", "self", "::", "remove_dir", "(", "self", "::", "$", "suite_cache_dir", ")", ";", "}", "self", "::", "$", "suite_cache_dir", "=", ...
Create a temporary WP_CLI_CACHE_DIR. Exposed as SUITE_CACHE_DIR in "Given an empty cache" step.
[ "Create", "a", "temporary", "WP_CLI_CACHE_DIR", ".", "Exposed", "as", "SUITE_CACHE_DIR", "in", "Given", "an", "empty", "cache", "step", "." ]
83b636fc7cb69ff257e025d1c855c190143a45db
https://github.com/wp-cli/wp-cli-tests/blob/83b636fc7cb69ff257e025d1c855c190143a45db/features/bootstrap/FeatureContext.php#L452-L459
43,633
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.getCacheKey
private function getCacheKey(RequestInterface $request, array $vary = []) { $key = $request->getMethod() . ' ' . $request->getUrl(); // If Vary headers have been passed in, fetch each header and add it to // the cache key. foreach ($vary as $header) { $key .= " $header: " . $request->getHeader($header); } return $this->keyPrefix . md5($key); }
php
private function getCacheKey(RequestInterface $request, array $vary = []) { $key = $request->getMethod() . ' ' . $request->getUrl(); // If Vary headers have been passed in, fetch each header and add it to // the cache key. foreach ($vary as $header) { $key .= " $header: " . $request->getHeader($header); } return $this->keyPrefix . md5($key); }
[ "private", "function", "getCacheKey", "(", "RequestInterface", "$", "request", ",", "array", "$", "vary", "=", "[", "]", ")", "{", "$", "key", "=", "$", "request", "->", "getMethod", "(", ")", ".", "' '", ".", "$", "request", "->", "getUrl", "(", ")"...
Hash a request URL into a string that returns cache metadata. @param RequestInterface $request The Request to generate the cache key for. @param array $vary (optional) An array of headers to vary the cache key by. @return string
[ "Hash", "a", "request", "URL", "into", "a", "string", "that", "returns", "cache", "metadata", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L192-L203
43,634
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.getBodyKey
private function getBodyKey($url, StreamInterface $body) { return $this->keyPrefix . md5($url) . Stream\Utils::hash($body, 'md5'); }
php
private function getBodyKey($url, StreamInterface $body) { return $this->keyPrefix . md5($url) . Stream\Utils::hash($body, 'md5'); }
[ "private", "function", "getBodyKey", "(", "$", "url", ",", "StreamInterface", "$", "body", ")", "{", "return", "$", "this", "->", "keyPrefix", ".", "md5", "(", "$", "url", ")", ".", "Stream", "\\", "Utils", "::", "hash", "(", "$", "body", ",", "'md5'...
Create a cache key for a response's body. @param string $url URL of the entry @param StreamInterface $body Response body @return string
[ "Create", "a", "cache", "key", "for", "a", "response", "s", "body", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L213-L216
43,635
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.persistHeaders
private function persistHeaders(MessageInterface $message) { // Clone the response to not destroy any necessary headers when caching $headers = array_diff_key($message->getHeaders(), self::$noCache); // Cast the headers to a string foreach ($headers as &$value) { $value = implode(', ', $value); } return $headers; }
php
private function persistHeaders(MessageInterface $message) { // Clone the response to not destroy any necessary headers when caching $headers = array_diff_key($message->getHeaders(), self::$noCache); // Cast the headers to a string foreach ($headers as &$value) { $value = implode(', ', $value); } return $headers; }
[ "private", "function", "persistHeaders", "(", "MessageInterface", "$", "message", ")", "{", "// Clone the response to not destroy any necessary headers when caching", "$", "headers", "=", "array_diff_key", "(", "$", "message", "->", "getHeaders", "(", ")", ",", "self", ...
Creates an array of cacheable and normalized message headers. @param MessageInterface $message @return array
[ "Creates", "an", "array", "of", "cacheable", "and", "normalized", "message", "headers", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L250-L261
43,636
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.getTtl
private function getTtl(ResponseInterface $response) { $ttl = 0; if ($cacheControl = $response->getHeader('Cache-Control')) { $maxAge = Utils::getDirective($response, 'max-age'); if (is_numeric($maxAge)) { $ttl += $maxAge; } // According to RFC5861 stale headers are *in addition* to any // max-age values. $stale = Utils::getDirective($response, 'stale-if-error'); if (is_numeric($stale)) { $ttl += $stale; } } elseif ($expires = $response->getHeader('Expires')) { $ttl += strtotime($expires) - time(); } return $ttl ?: $this->defaultTtl; }
php
private function getTtl(ResponseInterface $response) { $ttl = 0; if ($cacheControl = $response->getHeader('Cache-Control')) { $maxAge = Utils::getDirective($response, 'max-age'); if (is_numeric($maxAge)) { $ttl += $maxAge; } // According to RFC5861 stale headers are *in addition* to any // max-age values. $stale = Utils::getDirective($response, 'stale-if-error'); if (is_numeric($stale)) { $ttl += $stale; } } elseif ($expires = $response->getHeader('Expires')) { $ttl += strtotime($expires) - time(); } return $ttl ?: $this->defaultTtl; }
[ "private", "function", "getTtl", "(", "ResponseInterface", "$", "response", ")", "{", "$", "ttl", "=", "0", ";", "if", "(", "$", "cacheControl", "=", "$", "response", "->", "getHeader", "(", "'Cache-Control'", ")", ")", "{", "$", "maxAge", "=", "Utils", ...
Return the TTL to use when caching a Response. @param ResponseInterface $response The response being cached. @return int The TTL in seconds.
[ "Return", "the", "TTL", "to", "use", "when", "caching", "a", "Response", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L270-L291
43,637
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.normalizeVary
private function normalizeVary(ResponseInterface $response) { $parts = AbstractMessage::normalizeHeader($response, 'vary'); sort($parts); return $parts; }
php
private function normalizeVary(ResponseInterface $response) { $parts = AbstractMessage::normalizeHeader($response, 'vary'); sort($parts); return $parts; }
[ "private", "function", "normalizeVary", "(", "ResponseInterface", "$", "response", ")", "{", "$", "parts", "=", "AbstractMessage", "::", "normalizeHeader", "(", "$", "response", ",", "'vary'", ")", ";", "sort", "(", "$", "parts", ")", ";", "return", "$", "...
Return a sorted list of Vary headers. While headers are case-insensitive, header values are not. We can only normalize the order of headers to combine cache entries. @param ResponseInterface $response The Response with Vary headers. @return array An array of sorted headers.
[ "Return", "a", "sorted", "list", "of", "Vary", "headers", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L337-L343
43,638
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.cacheVary
private function cacheVary( RequestInterface $request, ResponseInterface $response ) { $key = $this->getVaryKey($request); $this->cache->save($key, $this->normalizeVary($response), $this->getTtl($response)); }
php
private function cacheVary( RequestInterface $request, ResponseInterface $response ) { $key = $this->getVaryKey($request); $this->cache->save($key, $this->normalizeVary($response), $this->getTtl($response)); }
[ "private", "function", "cacheVary", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "key", "=", "$", "this", "->", "getVaryKey", "(", "$", "request", ")", ";", "$", "this", "->", "cache", "->", "save", "...
Cache the Vary headers from a response. @param RequestInterface $request The Request that generated the Vary headers. @param ResponseInterface $response The Response with Vary headers.
[ "Cache", "the", "Vary", "headers", "from", "a", "response", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L352-L358
43,639
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.fetchVary
private function fetchVary(RequestInterface $request) { $key = $this->getVaryKey($request); $varyHeaders = $this->cache->fetch($key); return is_array($varyHeaders) ? $varyHeaders : []; }
php
private function fetchVary(RequestInterface $request) { $key = $this->getVaryKey($request); $varyHeaders = $this->cache->fetch($key); return is_array($varyHeaders) ? $varyHeaders : []; }
[ "private", "function", "fetchVary", "(", "RequestInterface", "$", "request", ")", "{", "$", "key", "=", "$", "this", "->", "getVaryKey", "(", "$", "request", ")", ";", "$", "varyHeaders", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "key",...
Fetch the Vary headers associated with a request, if they exist. Only responses, and not requests, contain Vary headers. However, we need to be able to determine what Vary headers were set for a given URL and request method on a future request. @param RequestInterface $request The Request to fetch headers for. @return array An array of headers.
[ "Fetch", "the", "Vary", "headers", "associated", "with", "a", "request", "if", "they", "exist", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L371-L377
43,640
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.deleteVary
private function deleteVary(RequestInterface $request) { $key = $this->getVaryKey($request); $this->cache->delete($key); }
php
private function deleteVary(RequestInterface $request) { $key = $this->getVaryKey($request); $this->cache->delete($key); }
[ "private", "function", "deleteVary", "(", "RequestInterface", "$", "request", ")", "{", "$", "key", "=", "$", "this", "->", "getVaryKey", "(", "$", "request", ")", ";", "$", "this", "->", "cache", "->", "delete", "(", "$", "key", ")", ";", "}" ]
Delete the headers associated with a Vary request. @param RequestInterface $request The Request to delete headers for.
[ "Delete", "the", "headers", "associated", "with", "a", "Vary", "request", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L384-L388
43,641
guzzle/cache-subscriber
src/CacheStorage.php
CacheStorage.getVaryKey
private function getVaryKey(RequestInterface $request) { $key = $this->keyPrefix . md5('vary ' . $this->getCacheKey($request)); return $key; }
php
private function getVaryKey(RequestInterface $request) { $key = $this->keyPrefix . md5('vary ' . $this->getCacheKey($request)); return $key; }
[ "private", "function", "getVaryKey", "(", "RequestInterface", "$", "request", ")", "{", "$", "key", "=", "$", "this", "->", "keyPrefix", ".", "md5", "(", "'vary '", ".", "$", "this", "->", "getCacheKey", "(", "$", "request", ")", ")", ";", "return", "$...
Get the cache key for Vary headers. @param RequestInterface $request The Request to fetch the key for. @return string The generated key.
[ "Get", "the", "cache", "key", "for", "Vary", "headers", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheStorage.php#L397-L402
43,642
guzzle/cache-subscriber
src/CacheSubscriber.php
CacheSubscriber.attach
public static function attach( HasEmitterInterface $subject, array $options = [] ) { if (!isset($options['storage'])) { $options['storage'] = new CacheStorage(new ArrayCache()); } if (!isset($options['can_cache'])) { $options['can_cache'] = [ 'GuzzleHttp\Subscriber\Cache\Utils', 'canCacheRequest', ]; } $emitter = $subject->getEmitter(); $cache = new self($options['storage'], $options['can_cache']); $emitter->attach($cache); if (!isset($options['validate']) || $options['validate'] === true) { $emitter->attach(new ValidationSubscriber( $options['storage'], $options['can_cache']) ); } if (!isset($options['purge']) || $options['purge'] === true) { $emitter->attach(new PurgeSubscriber($options['storage'])); } return ['subscriber' => $cache, 'storage' => $options['storage']]; }
php
public static function attach( HasEmitterInterface $subject, array $options = [] ) { if (!isset($options['storage'])) { $options['storage'] = new CacheStorage(new ArrayCache()); } if (!isset($options['can_cache'])) { $options['can_cache'] = [ 'GuzzleHttp\Subscriber\Cache\Utils', 'canCacheRequest', ]; } $emitter = $subject->getEmitter(); $cache = new self($options['storage'], $options['can_cache']); $emitter->attach($cache); if (!isset($options['validate']) || $options['validate'] === true) { $emitter->attach(new ValidationSubscriber( $options['storage'], $options['can_cache']) ); } if (!isset($options['purge']) || $options['purge'] === true) { $emitter->attach(new PurgeSubscriber($options['storage'])); } return ['subscriber' => $cache, 'storage' => $options['storage']]; }
[ "public", "static", "function", "attach", "(", "HasEmitterInterface", "$", "subject", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'storage'", "]", ")", ")", "{", "$", "options", "[", "'st...
Helper method used to easily attach a cache to a request or client. This method accepts an array of options that are used to control the caching behavior: - storage: An optional GuzzleHttp\Subscriber\Cache\CacheStorageInterface. If no value is not provided, an in-memory array cache will be used. - validate: Boolean value that determines if cached response are ever validated against the origin server. Defaults to true but can be disabled by passing false. - purge: Boolean value that determines if cached responses are purged when non-idempotent requests are sent to their URI. Defaults to true but can be disabled by passing false. - can_cache: An optional callable used to determine if a request can be cached. The callable accepts a RequestInterface and returns a boolean value. If no value is provided, the default behavior is utilized. @param HasEmitterInterface $subject Client or request to attach to, @param array $options Options used to control the cache. @return array Returns an associative array containing a 'subscriber' key that holds the created CacheSubscriber, and a 'storage' key that contains the cache storage used by the subscriber.
[ "Helper", "method", "used", "to", "easily", "attach", "a", "cache", "to", "a", "request", "or", "client", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheSubscriber.php#L77-L108
43,643
guzzle/cache-subscriber
src/CacheSubscriber.php
CacheSubscriber.onBefore
public function onBefore(BeforeEvent $event) { $request = $event->getRequest(); if (!$this->canCacheRequest($request)) { $this->cacheMiss($request); return; } if (!($response = $this->storage->fetch($request))) { $this->cacheMiss($request); return; } $response->setHeader('Age', Utils::getResponseAge($response)); $valid = $this->validate($request, $response); // Validate that the response satisfies the request if ($valid) { $request->getConfig()->set('cache_lookup', 'HIT'); $request->getConfig()->set('cache_hit', true); $event->intercept($response); } else { $this->cacheMiss($request); } }
php
public function onBefore(BeforeEvent $event) { $request = $event->getRequest(); if (!$this->canCacheRequest($request)) { $this->cacheMiss($request); return; } if (!($response = $this->storage->fetch($request))) { $this->cacheMiss($request); return; } $response->setHeader('Age', Utils::getResponseAge($response)); $valid = $this->validate($request, $response); // Validate that the response satisfies the request if ($valid) { $request->getConfig()->set('cache_lookup', 'HIT'); $request->getConfig()->set('cache_hit', true); $event->intercept($response); } else { $this->cacheMiss($request); } }
[ "public", "function", "onBefore", "(", "BeforeEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "!", "$", "this", "->", "canCacheRequest", "(", "$", "request", ")", ")", "{", "$", "this",...
Checks if a request can be cached, and if so, intercepts with a cached response is available. @param BeforeEvent $event
[ "Checks", "if", "a", "request", "can", "be", "cached", "and", "if", "so", "intercepts", "with", "a", "cached", "response", "is", "available", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheSubscriber.php#L125-L150
43,644
guzzle/cache-subscriber
src/CacheSubscriber.php
CacheSubscriber.onComplete
public function onComplete(CompleteEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); // Cache the response if it can be cached and isn't already if ($request->getConfig()->get('cache_lookup') === 'MISS' && call_user_func($this->canCache, $request) && Utils::canCacheResponse($response) ) { // Store the date when the response was cached $response->setHeader('X-Guzzle-Cache-Date', gmdate('D, d M Y H:i:s T', time())); $this->storage->cache($request, $response); } $this->addResponseHeaders($request, $response); }
php
public function onComplete(CompleteEvent $event) { $request = $event->getRequest(); $response = $event->getResponse(); // Cache the response if it can be cached and isn't already if ($request->getConfig()->get('cache_lookup') === 'MISS' && call_user_func($this->canCache, $request) && Utils::canCacheResponse($response) ) { // Store the date when the response was cached $response->setHeader('X-Guzzle-Cache-Date', gmdate('D, d M Y H:i:s T', time())); $this->storage->cache($request, $response); } $this->addResponseHeaders($request, $response); }
[ "public", "function", "onComplete", "(", "CompleteEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "// Cache the response if it can b...
Checks if the request and response can be cached, and if so, store it. @param CompleteEvent $event
[ "Checks", "if", "the", "request", "and", "response", "can", "be", "cached", "and", "if", "so", "store", "it", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheSubscriber.php#L157-L173
43,645
guzzle/cache-subscriber
src/CacheSubscriber.php
CacheSubscriber.onError
public function onError(ErrorEvent $event) { $request = $event->getRequest(); if (!call_user_func($this->canCache, $request)) { return; } $response = $this->storage->fetch($request); // Intercept the failed response if possible if ($response && $this->validateFailed($request, $response)) { $request->getConfig()->set('cache_hit', 'error'); $response->setHeader('Age', Utils::getResponseAge($response)); $event->intercept($response); } }
php
public function onError(ErrorEvent $event) { $request = $event->getRequest(); if (!call_user_func($this->canCache, $request)) { return; } $response = $this->storage->fetch($request); // Intercept the failed response if possible if ($response && $this->validateFailed($request, $response)) { $request->getConfig()->set('cache_hit', 'error'); $response->setHeader('Age', Utils::getResponseAge($response)); $event->intercept($response); } }
[ "public", "function", "onError", "(", "ErrorEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "!", "call_user_func", "(", "$", "this", "->", "canCache", ",", "$", "request", ")", ")", "{"...
If the request failed, then check if a cached response would suffice. @param ErrorEvent $event
[ "If", "the", "request", "failed", "then", "check", "if", "a", "cached", "response", "would", "suffice", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/CacheSubscriber.php#L180-L196
43,646
guzzle/cache-subscriber
src/Utils.php
Utils.getDirective
public static function getDirective(MessageInterface $message, $part) { $parts = AbstractMessage::parseHeader($message, 'Cache-Control'); foreach ($parts as $line) { if (isset($line[$part])) { return $line[$part]; } elseif (in_array($part, $line)) { return true; } } return null; }
php
public static function getDirective(MessageInterface $message, $part) { $parts = AbstractMessage::parseHeader($message, 'Cache-Control'); foreach ($parts as $line) { if (isset($line[$part])) { return $line[$part]; } elseif (in_array($part, $line)) { return true; } } return null; }
[ "public", "static", "function", "getDirective", "(", "MessageInterface", "$", "message", ",", "$", "part", ")", "{", "$", "parts", "=", "AbstractMessage", "::", "parseHeader", "(", "$", "message", ",", "'Cache-Control'", ")", ";", "foreach", "(", "$", "parts...
Get a cache control directive from a message. @param MessageInterface $message Message to retrieve @param string $part Cache directive to retrieve @return mixed|bool|null
[ "Get", "a", "cache", "control", "directive", "from", "a", "message", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L22-L35
43,647
guzzle/cache-subscriber
src/Utils.php
Utils.getResponseAge
public static function getResponseAge(ResponseInterface $response) { if ($response->hasHeader('Age')) { return (int) $response->getHeader('Age'); } $date = strtotime($response->getHeader('Date') ?: 'now'); return time() - $date; }
php
public static function getResponseAge(ResponseInterface $response) { if ($response->hasHeader('Age')) { return (int) $response->getHeader('Age'); } $date = strtotime($response->getHeader('Date') ?: 'now'); return time() - $date; }
[ "public", "static", "function", "getResponseAge", "(", "ResponseInterface", "$", "response", ")", "{", "if", "(", "$", "response", "->", "hasHeader", "(", "'Age'", ")", ")", "{", "return", "(", "int", ")", "$", "response", "->", "getHeader", "(", "'Age'", ...
Gets the age of a response in seconds. @param ResponseInterface $response @return int
[ "Gets", "the", "age", "of", "a", "response", "in", "seconds", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L44-L53
43,648
guzzle/cache-subscriber
src/Utils.php
Utils.getMaxAge
public static function getMaxAge(ResponseInterface $response) { $smaxage = Utils::getDirective($response, 's-maxage'); if (is_numeric($smaxage)) { return (int) $smaxage; } $maxage = Utils::getDirective($response, 'max-age'); if (is_numeric($maxage)) { return (int) $maxage; } if ($response->hasHeader('Expires')) { return strtotime($response->getHeader('Expires')) - time(); } return null; }
php
public static function getMaxAge(ResponseInterface $response) { $smaxage = Utils::getDirective($response, 's-maxage'); if (is_numeric($smaxage)) { return (int) $smaxage; } $maxage = Utils::getDirective($response, 'max-age'); if (is_numeric($maxage)) { return (int) $maxage; } if ($response->hasHeader('Expires')) { return strtotime($response->getHeader('Expires')) - time(); } return null; }
[ "public", "static", "function", "getMaxAge", "(", "ResponseInterface", "$", "response", ")", "{", "$", "smaxage", "=", "Utils", "::", "getDirective", "(", "$", "response", ",", "'s-maxage'", ")", ";", "if", "(", "is_numeric", "(", "$", "smaxage", ")", ")",...
Gets the number of seconds from the current time in which a response is still considered fresh. @param ResponseInterface $response @return int|null Returns the number of seconds
[ "Gets", "the", "number", "of", "seconds", "from", "the", "current", "time", "in", "which", "a", "response", "is", "still", "considered", "fresh", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L63-L80
43,649
guzzle/cache-subscriber
src/Utils.php
Utils.getFreshness
public static function getFreshness(ResponseInterface $response) { $maxAge = self::getMaxAge($response); $age = self::getResponseAge($response); return is_int($maxAge) && is_int($age) ? ($maxAge - $age) : null; }
php
public static function getFreshness(ResponseInterface $response) { $maxAge = self::getMaxAge($response); $age = self::getResponseAge($response); return is_int($maxAge) && is_int($age) ? ($maxAge - $age) : null; }
[ "public", "static", "function", "getFreshness", "(", "ResponseInterface", "$", "response", ")", "{", "$", "maxAge", "=", "self", "::", "getMaxAge", "(", "$", "response", ")", ";", "$", "age", "=", "self", "::", "getResponseAge", "(", "$", "response", ")", ...
Get the freshness of a response by returning the difference of the maximum lifetime of the response and the age of the response. Freshness values less than 0 mean that the response is no longer fresh and is ABS(freshness) seconds expired. Freshness values of greater than zero is the number of seconds until the response is no longer fresh. A NULL result means that no freshness information is available. @param ResponseInterface $response Response to get freshness of @return int|null
[ "Get", "the", "freshness", "of", "a", "response", "by", "returning", "the", "difference", "of", "the", "maximum", "lifetime", "of", "the", "response", "and", "the", "age", "of", "the", "response", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L95-L101
43,650
guzzle/cache-subscriber
src/Utils.php
Utils.canCacheRequest
public static function canCacheRequest(RequestInterface $request) { $method = $request->getMethod(); // Only GET and HEAD requests can be cached if ($method !== 'GET' && $method !== 'HEAD') { return false; } // Don't fool with Range requests for now if ($request->hasHeader('Range')) { return false; } return self::getDirective($request, 'no-store') === null; }
php
public static function canCacheRequest(RequestInterface $request) { $method = $request->getMethod(); // Only GET and HEAD requests can be cached if ($method !== 'GET' && $method !== 'HEAD') { return false; } // Don't fool with Range requests for now if ($request->hasHeader('Range')) { return false; } return self::getDirective($request, 'no-store') === null; }
[ "public", "static", "function", "canCacheRequest", "(", "RequestInterface", "$", "request", ")", "{", "$", "method", "=", "$", "request", "->", "getMethod", "(", ")", ";", "// Only GET and HEAD requests can be cached", "if", "(", "$", "method", "!==", "'GET'", "...
Default function used to determine if a request can be cached. @param RequestInterface $request Request to check @return bool
[ "Default", "function", "used", "to", "determine", "if", "a", "request", "can", "be", "cached", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L110-L125
43,651
guzzle/cache-subscriber
src/Utils.php
Utils.canCacheResponse
public static function canCacheResponse(ResponseInterface $response) { static $cacheCodes = [200, 203, 300, 301, 410]; // Check if the response is cacheable based on the code if (!in_array((int) $response->getStatusCode(), $cacheCodes)) { return false; } // Make sure a valid body was returned and can be cached $body = $response->getBody(); if ($body && (!$body->isReadable() || !$body->isSeekable())) { return false; } // Never cache no-store resources (this is a private cache, so private // can be cached) if (self::getDirective($response, 'no-store')) { return false; } // Don't fool with Content-Range requests for now if ($response->hasHeader('Content-Range')) { return false; } $freshness = self::getFreshness($response); return $freshness === null // No freshness info. || $freshness >= 0 // It's fresh || $response->hasHeader('ETag') // Can validate || $response->hasHeader('Last-Modified'); // Can validate }
php
public static function canCacheResponse(ResponseInterface $response) { static $cacheCodes = [200, 203, 300, 301, 410]; // Check if the response is cacheable based on the code if (!in_array((int) $response->getStatusCode(), $cacheCodes)) { return false; } // Make sure a valid body was returned and can be cached $body = $response->getBody(); if ($body && (!$body->isReadable() || !$body->isSeekable())) { return false; } // Never cache no-store resources (this is a private cache, so private // can be cached) if (self::getDirective($response, 'no-store')) { return false; } // Don't fool with Content-Range requests for now if ($response->hasHeader('Content-Range')) { return false; } $freshness = self::getFreshness($response); return $freshness === null // No freshness info. || $freshness >= 0 // It's fresh || $response->hasHeader('ETag') // Can validate || $response->hasHeader('Last-Modified'); // Can validate }
[ "public", "static", "function", "canCacheResponse", "(", "ResponseInterface", "$", "response", ")", "{", "static", "$", "cacheCodes", "=", "[", "200", ",", "203", ",", "300", ",", "301", ",", "410", "]", ";", "// Check if the response is cacheable based on the cod...
Determines if a response can be cached. @param ResponseInterface $response Response to check @return bool
[ "Determines", "if", "a", "response", "can", "be", "cached", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/Utils.php#L134-L166
43,652
guzzle/cache-subscriber
src/ValidationSubscriber.php
ValidationSubscriber.handleBadResponse
private function handleBadResponse(BadResponseException $e) { if (isset(self::$gone[$e->getResponse()->getStatusCode()])) { $this->storage->delete($e->getRequest()); } throw $e; }
php
private function handleBadResponse(BadResponseException $e) { if (isset(self::$gone[$e->getResponse()->getStatusCode()])) { $this->storage->delete($e->getRequest()); } throw $e; }
[ "private", "function", "handleBadResponse", "(", "BadResponseException", "$", "e", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "gone", "[", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", "]", ")", ")", "{", "$", "...
Handles a bad response when attempting to validate. If the resource no longer exists, then remove from the cache. @param BadResponseException $e Exception encountered @throws BadResponseException
[ "Handles", "a", "bad", "response", "when", "attempting", "to", "validate", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/ValidationSubscriber.php#L126-L133
43,653
guzzle/cache-subscriber
src/ValidationSubscriber.php
ValidationSubscriber.createRevalidationRequest
private function createRevalidationRequest( RequestInterface $request, ResponseInterface $response ) { $validate = clone $request; $validate->getConfig()->set('cache.disable', true); $validate->removeHeader('Pragma'); $validate->removeHeader('Cache-Control'); $responseDate = $response->getHeader('Last-Modified') ?: $response->getHeader('Date'); $validate->setHeader('If-Modified-Since', $responseDate); if ($etag = $response->getHeader('ETag')) { $validate->setHeader('If-None-Match', $etag); } return $validate; }
php
private function createRevalidationRequest( RequestInterface $request, ResponseInterface $response ) { $validate = clone $request; $validate->getConfig()->set('cache.disable', true); $validate->removeHeader('Pragma'); $validate->removeHeader('Cache-Control'); $responseDate = $response->getHeader('Last-Modified') ?: $response->getHeader('Date'); $validate->setHeader('If-Modified-Since', $responseDate); if ($etag = $response->getHeader('ETag')) { $validate->setHeader('If-None-Match', $etag); } return $validate; }
[ "private", "function", "createRevalidationRequest", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "validate", "=", "clone", "$", "request", ";", "$", "validate", "->", "getConfig", "(", ")", "->", "set", "("...
Creates a request to use for revalidation. @param RequestInterface $request Request @param ResponseInterface $response Response to validate @return RequestInterface returns a revalidation request
[ "Creates", "a", "request", "to", "use", "for", "revalidation", "." ]
1377567481d6d96224c9bd66aac475fbfbeec776
https://github.com/guzzle/cache-subscriber/blob/1377567481d6d96224c9bd66aac475fbfbeec776/src/ValidationSubscriber.php#L143-L160
43,654
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonStore.php
JsonStore.setData
public function setData($data) { $this->data = $data; if (is_string($this->data)) { $this->data = json_decode($this->data, true); } else if (is_object($data)) { $this->data = json_decode(json_encode($this->data), true); } else if (!is_array($data)) { throw new \InvalidArgumentException(sprintf('Invalid data type in JsonStore. Expected object, array or string, got %s', gettype($data))); } }
php
public function setData($data) { $this->data = $data; if (is_string($this->data)) { $this->data = json_decode($this->data, true); } else if (is_object($data)) { $this->data = json_decode(json_encode($this->data), true); } else if (!is_array($data)) { throw new \InvalidArgumentException(sprintf('Invalid data type in JsonStore. Expected object, array or string, got %s', gettype($data))); } }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "$", "this", "->", "data", "=", "$", "data", ";", "if", "(", "is_string", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "json_decode", "(", "$", "this",...
Sets JsonStore's manipulated data @param string|array|\stdClass $data
[ "Sets", "JsonStore", "s", "manipulated", "data" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonStore.php#L40-L51
43,655
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonStore.php
JsonStore.get
public function get($expr, $unique = false) { if ((($exprs = $this->normalizedFirst($expr)) !== false) && (is_array($exprs) || $exprs instanceof \Traversable) ) { $values = array(); foreach ($exprs as $expr) { $o =& $this->data; $keys = preg_split( "/([\"'])?\]\[([\"'])?/", preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr) ); for ($i = 0; $i < count($keys); $i++) { $o =& $o[$keys[$i]]; } $values[] = & $o; } if (true === $unique) { if (!empty($values) && is_array($values[0])) { array_walk($values, function(&$value) { $value = json_encode($value); }); $values = array_unique($values); array_walk($values, function(&$value) { $value = json_decode($value, true); }); return array_values($values); } return array_unique($values); } return $values; } return self::$emptyArray; }
php
public function get($expr, $unique = false) { if ((($exprs = $this->normalizedFirst($expr)) !== false) && (is_array($exprs) || $exprs instanceof \Traversable) ) { $values = array(); foreach ($exprs as $expr) { $o =& $this->data; $keys = preg_split( "/([\"'])?\]\[([\"'])?/", preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr) ); for ($i = 0; $i < count($keys); $i++) { $o =& $o[$keys[$i]]; } $values[] = & $o; } if (true === $unique) { if (!empty($values) && is_array($values[0])) { array_walk($values, function(&$value) { $value = json_encode($value); }); $values = array_unique($values); array_walk($values, function(&$value) { $value = json_decode($value, true); }); return array_values($values); } return array_unique($values); } return $values; } return self::$emptyArray; }
[ "public", "function", "get", "(", "$", "expr", ",", "$", "unique", "=", "false", ")", "{", "if", "(", "(", "(", "$", "exprs", "=", "$", "this", "->", "normalizedFirst", "(", "$", "expr", ")", ")", "!==", "false", ")", "&&", "(", "is_array", "(", ...
Gets elements matching the given JsonPath expression @param string $expr JsonPath expression @param bool $unique Gets unique results or not @return array
[ "Gets", "elements", "matching", "the", "given", "JsonPath", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonStore.php#L86-L128
43,656
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonStore.php
JsonStore.set
function set($expr, $value) { $get = $this->get($expr); if ($res =& $get) { foreach ($res as &$r) { $r = $value; } return true; } return false; }
php
function set($expr, $value) { $get = $this->get($expr); if ($res =& $get) { foreach ($res as &$r) { $r = $value; } return true; } return false; }
[ "function", "set", "(", "$", "expr", ",", "$", "value", ")", "{", "$", "get", "=", "$", "this", "->", "get", "(", "$", "expr", ")", ";", "if", "(", "$", "res", "=", "&", "$", "get", ")", "{", "foreach", "(", "$", "res", "as", "&", "$", "r...
Sets the value for all elements matching the given JsonPath expression @param string $expr JsonPath expression @param mixed $value Value to set @return bool returns true if success
[ "Sets", "the", "value", "for", "all", "elements", "matching", "the", "given", "JsonPath", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonStore.php#L136-L148
43,657
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonStore.php
JsonStore.add
public function add($parentexpr, $value, $name = "") { $get = $this->get($parentexpr); if ($parents =& $get) { foreach ($parents as &$parent) { $parent = is_array($parent) ? $parent : array(); if ($name != "") { $parent[$name] = $value; } else { $parent[] = $value; } } return true; } return false; }
php
public function add($parentexpr, $value, $name = "") { $get = $this->get($parentexpr); if ($parents =& $get) { foreach ($parents as &$parent) { $parent = is_array($parent) ? $parent : array(); if ($name != "") { $parent[$name] = $value; } else { $parent[] = $value; } } return true; } return false; }
[ "public", "function", "add", "(", "$", "parentexpr", ",", "$", "value", ",", "$", "name", "=", "\"\"", ")", "{", "$", "get", "=", "$", "this", "->", "get", "(", "$", "parentexpr", ")", ";", "if", "(", "$", "parents", "=", "&", "$", "get", ")", ...
Adds one or more elements matching the given json path expression @param string $parentexpr JsonPath expression to the parent @param mixed $value Value to add @param string $name Key name @return bool returns true if success
[ "Adds", "one", "or", "more", "elements", "matching", "the", "given", "json", "path", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonStore.php#L157-L176
43,658
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonStore.php
JsonStore.remove
public function remove($expr) { if ((($exprs = $this->normalizedFirst($expr)) !== false) && (is_array($exprs) || $exprs instanceof \Traversable) ) { foreach ($exprs as &$expr) { $o =& $this->data; $keys = preg_split( "/([\"'])?\]\[([\"'])?/", preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr) ); for ($i = 0; $i < count($keys) - 1; $i++) { $o =& $o[$keys[$i]]; } unset($o[$keys[$i]]); } return true; } return false; }
php
public function remove($expr) { if ((($exprs = $this->normalizedFirst($expr)) !== false) && (is_array($exprs) || $exprs instanceof \Traversable) ) { foreach ($exprs as &$expr) { $o =& $this->data; $keys = preg_split( "/([\"'])?\]\[([\"'])?/", preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr) ); for ($i = 0; $i < count($keys) - 1; $i++) { $o =& $o[$keys[$i]]; } unset($o[$keys[$i]]); } return true; } return false; }
[ "public", "function", "remove", "(", "$", "expr", ")", "{", "if", "(", "(", "(", "$", "exprs", "=", "$", "this", "->", "normalizedFirst", "(", "$", "expr", ")", ")", "!==", "false", ")", "&&", "(", "is_array", "(", "$", "exprs", ")", "||", "$", ...
Removes all elements matching the given jsonpath expression @param string $expr JsonPath expression @return bool returns true if success
[ "Removes", "all", "elements", "matching", "the", "given", "jsonpath", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonStore.php#L183-L205
43,659
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonPath.php
JsonPath.normalize
private function normalize($expression) { // Replaces filters by #0 #1... $expression = preg_replace_callback( array("/[\['](\??\(.*?\))[\]']/", "/\['(.*?)'\]/"), array(&$this, "tempFilters"), $expression ); // ; separator between each elements $expression = preg_replace( array("/'?\.'?|\['?/", "/;;;|;;/", "/;$|'?\]|'$/"), array(";", ";..;", ""), $expression ); // Restore filters $expression = preg_replace_callback("/#([0-9]+)/", array(&$this, "restoreFilters"), $expression); $this->result = array(); // result array was temporarily used as a buffer .. return $expression; }
php
private function normalize($expression) { // Replaces filters by #0 #1... $expression = preg_replace_callback( array("/[\['](\??\(.*?\))[\]']/", "/\['(.*?)'\]/"), array(&$this, "tempFilters"), $expression ); // ; separator between each elements $expression = preg_replace( array("/'?\.'?|\['?/", "/;;;|;;/", "/;$|'?\]|'$/"), array(";", ";..;", ""), $expression ); // Restore filters $expression = preg_replace_callback("/#([0-9]+)/", array(&$this, "restoreFilters"), $expression); $this->result = array(); // result array was temporarily used as a buffer .. return $expression; }
[ "private", "function", "normalize", "(", "$", "expression", ")", "{", "// Replaces filters by #0 #1...\r", "$", "expression", "=", "preg_replace_callback", "(", "array", "(", "\"/[\\['](\\??\\(.*?\\))[\\]']/\"", ",", "\"/\\['(.*?)'\\]/\"", ")", ",", "array", "(", "&", ...
normalize path expression
[ "normalize", "path", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonPath.php#L44-L64
43,660
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonPath.php
JsonPath.tempFilters
private function tempFilters($filter) { $f = $filter[1]; $elements = explode('\'', $f); // Hack to make "dot" works on filters for ($i=0, $m=0; $i<count($elements); $i++) { if ($m%2 == 0) { if ($i > 0 && substr($elements[$i-1], 0, 1) == '\\') { continue; } $e = explode('.', $elements[$i]); $str = ''; $first = true; foreach ($e as $substr) { if ($first) { $str = $substr; $first = false; continue; } $end = null; if (false !== $pos = $this->strpos_array($substr, $this->keywords)) { list($substr, $end) = array(substr($substr, 0, $pos), substr($substr, $pos, strlen($substr))); } $str .= '[' . $substr . ']'; if (null !== $end) { $str .= $end; } } $elements[$i] = $str; } $m++; } return "[#" . (array_push($this->result, implode('\'', $elements)) - 1) . "]"; }
php
private function tempFilters($filter) { $f = $filter[1]; $elements = explode('\'', $f); // Hack to make "dot" works on filters for ($i=0, $m=0; $i<count($elements); $i++) { if ($m%2 == 0) { if ($i > 0 && substr($elements[$i-1], 0, 1) == '\\') { continue; } $e = explode('.', $elements[$i]); $str = ''; $first = true; foreach ($e as $substr) { if ($first) { $str = $substr; $first = false; continue; } $end = null; if (false !== $pos = $this->strpos_array($substr, $this->keywords)) { list($substr, $end) = array(substr($substr, 0, $pos), substr($substr, $pos, strlen($substr))); } $str .= '[' . $substr . ']'; if (null !== $end) { $str .= $end; } } $elements[$i] = $str; } $m++; } return "[#" . (array_push($this->result, implode('\'', $elements)) - 1) . "]"; }
[ "private", "function", "tempFilters", "(", "$", "filter", ")", "{", "$", "f", "=", "$", "filter", "[", "1", "]", ";", "$", "elements", "=", "explode", "(", "'\\''", ",", "$", "f", ")", ";", "// Hack to make \"dot\" works on filters\r", "for", "(", "$", ...
Pushs the filter into the list @param string $filter @return string
[ "Pushs", "the", "filter", "into", "the", "list" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonPath.php#L71-L109
43,661
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonPath.php
JsonPath.asPath
private function asPath($path) { $expr = explode(";", $path); $fullPath = "$"; for ($i = 1, $n = count($expr); $i < $n; $i++) { $fullPath .= preg_match("/^[0-9*]+$/", $expr[$i]) ? ("[" . $expr[$i] . "]") : ("['" . $expr[$i] . "']"); } return $fullPath; }
php
private function asPath($path) { $expr = explode(";", $path); $fullPath = "$"; for ($i = 1, $n = count($expr); $i < $n; $i++) { $fullPath .= preg_match("/^[0-9*]+$/", $expr[$i]) ? ("[" . $expr[$i] . "]") : ("['" . $expr[$i] . "']"); } return $fullPath; }
[ "private", "function", "asPath", "(", "$", "path", ")", "{", "$", "expr", "=", "explode", "(", "\";\"", ",", "$", "path", ")", ";", "$", "fullPath", "=", "\"$\"", ";", "for", "(", "$", "i", "=", "1", ",", "$", "n", "=", "count", "(", "$", "ex...
Builds json path expression @param string $path @return string
[ "Builds", "json", "path", "expression" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonPath.php#L126-L135
43,662
Peekmo/JsonPath
src/Peekmo/JsonPath/JsonPath.php
JsonPath.strpos_array
private function strpos_array($haystack, array $needles) { $closer = 10000; foreach($needles as $needle) { if (false !== $pos = strpos($haystack, $needle)) { if ($pos < $closer) { $closer = $pos; } } } return 10000 === $closer ? false : $closer; }
php
private function strpos_array($haystack, array $needles) { $closer = 10000; foreach($needles as $needle) { if (false !== $pos = strpos($haystack, $needle)) { if ($pos < $closer) { $closer = $pos; } } } return 10000 === $closer ? false : $closer; }
[ "private", "function", "strpos_array", "(", "$", "haystack", ",", "array", "$", "needles", ")", "{", "$", "closer", "=", "10000", ";", "foreach", "(", "$", "needles", "as", "$", "needle", ")", "{", "if", "(", "false", "!==", "$", "pos", "=", "strpos"...
Search one of the given needs in the array @param string $haystack @param array $needles @return bool|string
[ "Search", "one", "of", "the", "given", "needs", "in", "the", "array" ]
0b339171b7eab5791bbb71549305a7e0e2a4ca52
https://github.com/Peekmo/JsonPath/blob/0b339171b7eab5791bbb71549305a7e0e2a4ca52/src/Peekmo/JsonPath/JsonPath.php#L266-L278
43,663
silverstripe/silverstripe-tagfield
src/ReadonlyTagField.php
ReadonlyTagField.Field
public function Field($properties = array()) { $options = array(); foreach ($this->getOptions()->filter('Selected', true) as $option) { $options[] = $option->Title; } $field = ReadonlyField::create($this->name . '_Readonly', $this->title); $field->setForm($this->form); $field->setValue(implode(', ', $options)); return $field->Field(); }
php
public function Field($properties = array()) { $options = array(); foreach ($this->getOptions()->filter('Selected', true) as $option) { $options[] = $option->Title; } $field = ReadonlyField::create($this->name . '_Readonly', $this->title); $field->setForm($this->form); $field->setValue(implode(', ', $options)); return $field->Field(); }
[ "public", "function", "Field", "(", "$", "properties", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getOptions", "(", ")", "->", "filter", "(", "'Selected'", ",", "true", ")", "a...
Render the readonly field as HTML. @param array $properties @return HTMLText
[ "Render", "the", "readonly", "field", "as", "HTML", "." ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/ReadonlyTagField.php#L26-L39
43,664
silverstripe/silverstripe-tagfield
src/TagField.php
TagField.getOrCreateTag
protected function getOrCreateTag($term) { // Check if existing record can be found $source = $this->getSourceList(); $titleField = $this->getTitleField(); $record = $source ->filter($titleField, $term) ->first(); if ($record) { return $record; } // Create new instance if not yet saved if ($this->getCanCreate()) { $dataClass = $source->dataClass(); $record = Injector::inst()->create($dataClass); $record->{$titleField} = $term; $record->write(); if ($source instanceof SS_List) { $source->add($record); } return $record; } return false; }
php
protected function getOrCreateTag($term) { // Check if existing record can be found $source = $this->getSourceList(); $titleField = $this->getTitleField(); $record = $source ->filter($titleField, $term) ->first(); if ($record) { return $record; } // Create new instance if not yet saved if ($this->getCanCreate()) { $dataClass = $source->dataClass(); $record = Injector::inst()->create($dataClass); $record->{$titleField} = $term; $record->write(); if ($source instanceof SS_List) { $source->add($record); } return $record; } return false; }
[ "protected", "function", "getOrCreateTag", "(", "$", "term", ")", "{", "// Check if existing record can be found", "$", "source", "=", "$", "this", "->", "getSourceList", "(", ")", ";", "$", "titleField", "=", "$", "this", "->", "getTitleField", "(", ")", ";",...
Get or create tag with the given value @param string $term @return DataObject|bool
[ "Get", "or", "create", "tag", "with", "the", "given", "value" ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/TagField.php#L375-L400
43,665
silverstripe/silverstripe-tagfield
src/TagField.php
TagField.getTags
protected function getTags($term) { $source = $this->getSourceList(); $titleField = $this->getTitleField(); $query = $source ->filter($titleField . ':PartialMatch:nocase', $term) ->sort($titleField) ->limit($this->getLazyLoadItemLimit()); // Map into a distinct list $items = []; $titleField = $this->getTitleField(); foreach ($query->map('ID', $titleField) as $id => $title) { $items[$title] = [ 'id' => $title, 'text' => $title, ]; } return array_values($items); }
php
protected function getTags($term) { $source = $this->getSourceList(); $titleField = $this->getTitleField(); $query = $source ->filter($titleField . ':PartialMatch:nocase', $term) ->sort($titleField) ->limit($this->getLazyLoadItemLimit()); // Map into a distinct list $items = []; $titleField = $this->getTitleField(); foreach ($query->map('ID', $titleField) as $id => $title) { $items[$title] = [ 'id' => $title, 'text' => $title, ]; } return array_values($items); }
[ "protected", "function", "getTags", "(", "$", "term", ")", "{", "$", "source", "=", "$", "this", "->", "getSourceList", "(", ")", ";", "$", "titleField", "=", "$", "this", "->", "getTitleField", "(", ")", ";", "$", "query", "=", "$", "source", "->", ...
Returns array of arrays representing tags. @param string $term @return array
[ "Returns", "array", "of", "arrays", "representing", "tags", "." ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/TagField.php#L425-L447
43,666
silverstripe/silverstripe-tagfield
src/TagField.php
TagField.performReadonlyTransformation
public function performReadonlyTransformation() { /** @var ReadonlyTagField $copy */ $copy = $this->castedCopy(ReadonlyTagField::class); $copy->setSourceList($this->getSourceList()); return $copy; }
php
public function performReadonlyTransformation() { /** @var ReadonlyTagField $copy */ $copy = $this->castedCopy(ReadonlyTagField::class); $copy->setSourceList($this->getSourceList()); return $copy; }
[ "public", "function", "performReadonlyTransformation", "(", ")", "{", "/** @var ReadonlyTagField $copy */", "$", "copy", "=", "$", "this", "->", "castedCopy", "(", "ReadonlyTagField", "::", "class", ")", ";", "$", "copy", "->", "setSourceList", "(", "$", "this", ...
Converts the field to a readonly variant. @return ReadonlyTagField
[ "Converts", "the", "field", "to", "a", "readonly", "variant", "." ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/TagField.php#L466-L472
43,667
silverstripe/silverstripe-tagfield
src/StringTagField.php
StringTagField.getSchemaDataDefaults
public function getSchemaDataDefaults() { $schema = array_merge( parent::getSchemaDataDefaults(), [ 'name' => $this->getName() . '[]', 'lazyLoad' => $this->getShouldLazyLoad(), 'creatable' => $this->getCanCreate(), 'multi' => $this->getIsMultiple(), 'value' => $this->formatOptions($this->Value()), 'disabled' => $this->isDisabled() || $this->isReadonly(), ] ); if (!$this->getShouldLazyLoad()) { $schema['options'] = $this->getOptions()->toNestedArray(); } else { $schema['optionUrl'] = $this->getSuggestURL(); } return $schema; }
php
public function getSchemaDataDefaults() { $schema = array_merge( parent::getSchemaDataDefaults(), [ 'name' => $this->getName() . '[]', 'lazyLoad' => $this->getShouldLazyLoad(), 'creatable' => $this->getCanCreate(), 'multi' => $this->getIsMultiple(), 'value' => $this->formatOptions($this->Value()), 'disabled' => $this->isDisabled() || $this->isReadonly(), ] ); if (!$this->getShouldLazyLoad()) { $schema['options'] = $this->getOptions()->toNestedArray(); } else { $schema['optionUrl'] = $this->getSuggestURL(); } return $schema; }
[ "public", "function", "getSchemaDataDefaults", "(", ")", "{", "$", "schema", "=", "array_merge", "(", "parent", "::", "getSchemaDataDefaults", "(", ")", ",", "[", "'name'", "=>", "$", "this", "->", "getName", "(", ")", ".", "'[]'", ",", "'lazyLoad'", "=>",...
Provide TagField data to the JSON schema for the frontend component @return array
[ "Provide", "TagField", "data", "to", "the", "JSON", "schema", "for", "the", "frontend", "component" ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/StringTagField.php#L159-L180
43,668
silverstripe/silverstripe-tagfield
src/StringTagField.php
StringTagField.suggest
public function suggest(HTTPRequest $request) { $responseBody = json_encode( ['items' => $this->getTags($request->getVar('term'))] ); $response = HTTPResponse::create(); $response->addHeader('Content-Type', 'application/json'); $response->setBody($responseBody); return $response; }
php
public function suggest(HTTPRequest $request) { $responseBody = json_encode( ['items' => $this->getTags($request->getVar('term'))] ); $response = HTTPResponse::create(); $response->addHeader('Content-Type', 'application/json'); $response->setBody($responseBody); return $response; }
[ "public", "function", "suggest", "(", "HTTPRequest", "$", "request", ")", "{", "$", "responseBody", "=", "json_encode", "(", "[", "'items'", "=>", "$", "this", "->", "getTags", "(", "$", "request", "->", "getVar", "(", "'term'", ")", ")", "]", ")", ";"...
Returns a JSON string of tags, for lazy loading. @param HTTPRequest $request @return HTTPResponse
[ "Returns", "a", "JSON", "string", "of", "tags", "for", "lazy", "loading", "." ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/StringTagField.php#L292-L303
43,669
silverstripe/silverstripe-tagfield
src/StringTagField.php
StringTagField.getTags
protected function getTags($term) { $items = []; foreach ($this->getOptions() as $i => $tag) { /** @var ArrayData $tag */ $tagValue = $tag->Value; // Map into a distinct list (prevent duplicates) if (stripos($tagValue, $term) !== false && !array_key_exists($tagValue, $items)) { $items[$tagValue] = [ 'id' => $tag->Title, 'text' => $tag->Value, ]; } } // @todo do we actually need lazy loading limits for StringTagField? return array_slice(array_values($items), 0, $this->getLazyLoadItemLimit()); }
php
protected function getTags($term) { $items = []; foreach ($this->getOptions() as $i => $tag) { /** @var ArrayData $tag */ $tagValue = $tag->Value; // Map into a distinct list (prevent duplicates) if (stripos($tagValue, $term) !== false && !array_key_exists($tagValue, $items)) { $items[$tagValue] = [ 'id' => $tag->Title, 'text' => $tag->Value, ]; } } // @todo do we actually need lazy loading limits for StringTagField? return array_slice(array_values($items), 0, $this->getLazyLoadItemLimit()); }
[ "protected", "function", "getTags", "(", "$", "term", ")", "{", "$", "items", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOptions", "(", ")", "as", "$", "i", "=>", "$", "tag", ")", "{", "/** @var ArrayData $tag */", "$", "tagValue", "=...
Returns array of arrays representing tags that partially match the given search term @param string $term @return array
[ "Returns", "array", "of", "arrays", "representing", "tags", "that", "partially", "match", "the", "given", "search", "term" ]
b5ca874591e4add7c6ba5c4dc6699c39e97299f5
https://github.com/silverstripe/silverstripe-tagfield/blob/b5ca874591e4add7c6ba5c4dc6699c39e97299f5/src/StringTagField.php#L311-L327
43,670
laravel-doctrine/extensions
src/BeberleiExtensionsServiceProvider.php
BeberleiExtensionsServiceProvider.boot
public function boot(DoctrineManager $manager) { $manager->extendAll(function (Configuration $configuration) { $configuration->setCustomDatetimeFunctions($this->datetime); $configuration->setCustomNumericFunctions($this->numeric); $configuration->setCustomStringFunctions($this->string); }); }
php
public function boot(DoctrineManager $manager) { $manager->extendAll(function (Configuration $configuration) { $configuration->setCustomDatetimeFunctions($this->datetime); $configuration->setCustomNumericFunctions($this->numeric); $configuration->setCustomStringFunctions($this->string); }); }
[ "public", "function", "boot", "(", "DoctrineManager", "$", "manager", ")", "{", "$", "manager", "->", "extendAll", "(", "function", "(", "Configuration", "$", "configuration", ")", "{", "$", "configuration", "->", "setCustomDatetimeFunctions", "(", "$", "this", ...
Register the metadata @param DoctrineManager $manager
[ "Register", "the", "metadata" ]
a2e7896100559ecc64504252dbc74ec18ad59813
https://github.com/laravel-doctrine/extensions/blob/a2e7896100559ecc64504252dbc74ec18ad59813/src/BeberleiExtensionsServiceProvider.php#L96-L103
43,671
silverstripe/silverstripe-spamprotection
code/EditableSpamProtectionField.php
EditableSpamProtectionField.getCandidateFields
protected function getCandidateFields() { // Get list of all configured classes available for spam detection $types = $this->config()->get('check_fields'); $typesInherit = array(); foreach ($types as $type) { $subTypes = ClassInfo::subclassesFor($type); $typesInherit = array_merge($typesInherit, $subTypes); } // Get all candidates of the above types return $this ->Parent() ->Fields() ->filter('ClassName', $typesInherit) ->exclude('Title', ''); // Ignore this field and those without titles }
php
protected function getCandidateFields() { // Get list of all configured classes available for spam detection $types = $this->config()->get('check_fields'); $typesInherit = array(); foreach ($types as $type) { $subTypes = ClassInfo::subclassesFor($type); $typesInherit = array_merge($typesInherit, $subTypes); } // Get all candidates of the above types return $this ->Parent() ->Fields() ->filter('ClassName', $typesInherit) ->exclude('Title', ''); // Ignore this field and those without titles }
[ "protected", "function", "getCandidateFields", "(", ")", "{", "// Get list of all configured classes available for spam detection", "$", "types", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'check_fields'", ")", ";", "$", "typesInherit", "=", "arr...
Gets the list of all candidate spam detectable fields on this field's form @return DataList
[ "Gets", "the", "list", "of", "all", "candidate", "spam", "detectable", "fields", "on", "this", "field", "s", "form" ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/EditableSpamProtectionField.php#L99-L116
43,672
silverstripe/silverstripe-spamprotection
code/EditableSpamProtectionField.php
EditableSpamProtectionField.onBeforeWrite
public function onBeforeWrite() { $fieldMap = json_decode($this->SpamFieldSettings, true); if (empty($fieldMap)) { $fieldMap = array(); } foreach ($this->record as $key => $value) { if (substr($key, 0, 8) === 'spammap-') { $fieldMap[substr($key, 8)] = $value; } } $this->setField('SpamFieldSettings', json_encode($fieldMap)); return parent::onBeforeWrite(); }
php
public function onBeforeWrite() { $fieldMap = json_decode($this->SpamFieldSettings, true); if (empty($fieldMap)) { $fieldMap = array(); } foreach ($this->record as $key => $value) { if (substr($key, 0, 8) === 'spammap-') { $fieldMap[substr($key, 8)] = $value; } } $this->setField('SpamFieldSettings', json_encode($fieldMap)); return parent::onBeforeWrite(); }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "$", "fieldMap", "=", "json_decode", "(", "$", "this", "->", "SpamFieldSettings", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "fieldMap", ")", ")", "{", "$", "fieldMap", "=", "array", "(", ...
Write the spam field mapping values to a serialised DB field {@inheritDoc}
[ "Write", "the", "spam", "field", "mapping", "values", "to", "a", "serialised", "DB", "field" ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/EditableSpamProtectionField.php#L123-L138
43,673
silverstripe/silverstripe-spamprotection
code/EditableSpamProtectionField.php
EditableSpamProtectionField.getCMSFields
public function getCMSFields() { /** @var FieldList $fields */ $fields = parent::getCMSFields(); // Get protector $protector = FormSpamProtectionExtension::get_protector(); if (!$protector) { return $fields; } if ($this->Parent()->Fields() instanceof UnsavedRelationList) { return $fields; } // Each other text field in this group can be assigned a field mapping $mapGroup = FieldGroup::create() ->setTitle(_t(__CLASS__.'.SPAMFIELDMAPPING', 'Spam Field Mapping')) ->setName('SpamFieldMapping') ->setDescription(_t( __CLASS__.'.SPAMFIELDMAPPINGDESCRIPTION', 'Select the form fields that correspond to any relevant spam protection identifiers' )); // Generate field specific settings $mappableFields = FormSpamProtectionExtension::config()->get('mappable_fields'); $mappableFieldsMerged = array_combine($mappableFields, $mappableFields); foreach ($this->getCandidateFields() as $otherField) { $mapSetting = "Map-{$otherField->Name}"; $fieldOption = DropdownField::create( 'spammap-' . $mapSetting, $otherField->Title, $mappableFieldsMerged, $this->spamMapValue($mapSetting) )->setEmptyString(''); $mapGroup->push($fieldOption); } $fields->addFieldToTab('Root.Main', $mapGroup); return $fields; }
php
public function getCMSFields() { /** @var FieldList $fields */ $fields = parent::getCMSFields(); // Get protector $protector = FormSpamProtectionExtension::get_protector(); if (!$protector) { return $fields; } if ($this->Parent()->Fields() instanceof UnsavedRelationList) { return $fields; } // Each other text field in this group can be assigned a field mapping $mapGroup = FieldGroup::create() ->setTitle(_t(__CLASS__.'.SPAMFIELDMAPPING', 'Spam Field Mapping')) ->setName('SpamFieldMapping') ->setDescription(_t( __CLASS__.'.SPAMFIELDMAPPINGDESCRIPTION', 'Select the form fields that correspond to any relevant spam protection identifiers' )); // Generate field specific settings $mappableFields = FormSpamProtectionExtension::config()->get('mappable_fields'); $mappableFieldsMerged = array_combine($mappableFields, $mappableFields); foreach ($this->getCandidateFields() as $otherField) { $mapSetting = "Map-{$otherField->Name}"; $fieldOption = DropdownField::create( 'spammap-' . $mapSetting, $otherField->Title, $mappableFieldsMerged, $this->spamMapValue($mapSetting) )->setEmptyString(''); $mapGroup->push($fieldOption); } $fields->addFieldToTab('Root.Main', $mapGroup); return $fields; }
[ "public", "function", "getCMSFields", "(", ")", "{", "/** @var FieldList $fields */", "$", "fields", "=", "parent", "::", "getCMSFields", "(", ")", ";", "// Get protector", "$", "protector", "=", "FormSpamProtectionExtension", "::", "get_protector", "(", ")", ";", ...
Used in userforms 3.x and above {@inheritDoc}
[ "Used", "in", "userforms", "3", ".", "x", "and", "above" ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/EditableSpamProtectionField.php#L145-L185
43,674
silverstripe/silverstripe-spamprotection
code/EditableSpamProtectionField.php
EditableSpamProtectionField.spamMapValue
public function spamMapValue($mapSetting) { $map = json_decode($this->SpamFieldSettings, true); if (empty($map)) { $map = array(); } if (array_key_exists($mapSetting, $map)) { return $map[$mapSetting]; } return ''; }
php
public function spamMapValue($mapSetting) { $map = json_decode($this->SpamFieldSettings, true); if (empty($map)) { $map = array(); } if (array_key_exists($mapSetting, $map)) { return $map[$mapSetting]; } return ''; }
[ "public", "function", "spamMapValue", "(", "$", "mapSetting", ")", "{", "$", "map", "=", "json_decode", "(", "$", "this", "->", "SpamFieldSettings", ",", "true", ")", ";", "if", "(", "empty", "(", "$", "map", ")", ")", "{", "$", "map", "=", "array", ...
Try to retrieve a value for the given spam field map name from the serialised data @param string $mapSetting @return string
[ "Try", "to", "retrieve", "a", "value", "for", "the", "given", "spam", "field", "map", "name", "from", "the", "serialised", "data" ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/EditableSpamProtectionField.php#L193-L204
43,675
silverstripe/silverstripe-spamprotection
code/Extension/FormSpamProtectionExtension.php
FormSpamProtectionExtension.get_protector
public static function get_protector($options = null) { // generate the spam protector if (isset($options['protector'])) { $protector = $options['protector']; } else { $protector = self::config()->get('default_spam_protector'); } if ($protector && class_exists($protector)) { return Injector::inst()->create($protector); } else { return null; } }
php
public static function get_protector($options = null) { // generate the spam protector if (isset($options['protector'])) { $protector = $options['protector']; } else { $protector = self::config()->get('default_spam_protector'); } if ($protector && class_exists($protector)) { return Injector::inst()->create($protector); } else { return null; } }
[ "public", "static", "function", "get_protector", "(", "$", "options", "=", "null", ")", "{", "// generate the spam protector", "if", "(", "isset", "(", "$", "options", "[", "'protector'", "]", ")", ")", "{", "$", "protector", "=", "$", "options", "[", "'pr...
Instantiate a SpamProtector instance @param array $options Configuration options @return SpamProtector|null
[ "Instantiate", "a", "SpamProtector", "instance" ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/Extension/FormSpamProtectionExtension.php#L67-L81
43,676
silverstripe/silverstripe-spamprotection
code/Extension/FormSpamProtectionExtension.php
FormSpamProtectionExtension.enableSpamProtection
public function enableSpamProtection($options = array()) { // captcha form field name (must be unique) if (isset($options['name'])) { $name = $options['name']; } else { $name = $this->config()->get('field_name'); } // captcha field title if (isset($options['title'])) { $title = $options['title']; } else { $title = ''; } // set custom mapping on this form $protector = self::get_protector($options); if (isset($options['mapping'])) { $protector->setFieldMapping($options['mapping']); } if ($protector) { // add the form field if ($field = $protector->getFormField($name, $title)) { $field->setForm($this->owner); // Add before field specified by insertBefore $inserted = false; if (!empty($options['insertBefore'])) { $inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']); } if (!$inserted) { // Add field to end if not added already $this->owner->Fields()->push($field); } } } return $this->owner; }
php
public function enableSpamProtection($options = array()) { // captcha form field name (must be unique) if (isset($options['name'])) { $name = $options['name']; } else { $name = $this->config()->get('field_name'); } // captcha field title if (isset($options['title'])) { $title = $options['title']; } else { $title = ''; } // set custom mapping on this form $protector = self::get_protector($options); if (isset($options['mapping'])) { $protector->setFieldMapping($options['mapping']); } if ($protector) { // add the form field if ($field = $protector->getFormField($name, $title)) { $field->setForm($this->owner); // Add before field specified by insertBefore $inserted = false; if (!empty($options['insertBefore'])) { $inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']); } if (!$inserted) { // Add field to end if not added already $this->owner->Fields()->push($field); } } } return $this->owner; }
[ "public", "function", "enableSpamProtection", "(", "$", "options", "=", "array", "(", ")", ")", "{", "// captcha form field name (must be unique)", "if", "(", "isset", "(", "$", "options", "[", "'name'", "]", ")", ")", "{", "$", "name", "=", "$", "options", ...
Activates the spam protection module. @param array $options @return Object
[ "Activates", "the", "spam", "protection", "module", "." ]
b88a706ae77fa8e1c1113694f986b4dc35a20212
https://github.com/silverstripe/silverstripe-spamprotection/blob/b88a706ae77fa8e1c1113694f986b4dc35a20212/code/Extension/FormSpamProtectionExtension.php#L89-L131
43,677
lovata/oc-toolbox-plugin
classes/helper/PageHelper.php
PageHelper.getPageNameList
public function getPageNameList() { if (!empty($this->arPageNameList)) { return $this->arPageNameList; } $arResult = []; //Get page list $obPageList = $this->getPageList(); if (empty($obPageList)) { return $arResult; } //Process page list foreach ($obPageList as $obPage) { $arResult[$obPage->id] = $obPage->title; } $this->arPageNameList = $arResult; return $arResult; }
php
public function getPageNameList() { if (!empty($this->arPageNameList)) { return $this->arPageNameList; } $arResult = []; //Get page list $obPageList = $this->getPageList(); if (empty($obPageList)) { return $arResult; } //Process page list foreach ($obPageList as $obPage) { $arResult[$obPage->id] = $obPage->title; } $this->arPageNameList = $arResult; return $arResult; }
[ "public", "function", "getPageNameList", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "arPageNameList", ")", ")", "{", "return", "$", "this", "->", "arPageNameList", ";", "}", "$", "arResult", "=", "[", "]", ";", "//Get page list", "...
Get array with names of pages @return array
[ "Get", "array", "with", "names", "of", "pages" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/PageHelper.php#L87-L109
43,678
lovata/oc-toolbox-plugin
classes/helper/PageHelper.php
PageHelper.getPageObject
protected function getPageObject($sPageCode) { if (isset($this->arPageList[$sPageCode])) { return $this->arPageList[$sPageCode]; } if (empty($sPageCode) || empty($this->obTheme)) { return null; } $this->arPageList[$sPageCode] = CmsPage::loadCached($this->obTheme, $sPageCode); return $this->arPageList[$sPageCode]; }
php
protected function getPageObject($sPageCode) { if (isset($this->arPageList[$sPageCode])) { return $this->arPageList[$sPageCode]; } if (empty($sPageCode) || empty($this->obTheme)) { return null; } $this->arPageList[$sPageCode] = CmsPage::loadCached($this->obTheme, $sPageCode); return $this->arPageList[$sPageCode]; }
[ "protected", "function", "getPageObject", "(", "$", "sPageCode", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arPageList", "[", "$", "sPageCode", "]", ")", ")", "{", "return", "$", "this", "->", "arPageList", "[", "$", "sPageCode", "]", ";", ...
Get page object @param string $sPageCode @return CmsPage|null
[ "Get", "page", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/PageHelper.php#L149-L162
43,679
lovata/oc-toolbox-plugin
classes/helper/PageHelper.php
PageHelper.getCachedData
protected function getCachedData($sKey) { if (isset($this->arCachedData[$sKey])) { return $this->arCachedData[$sKey]; } return null; }
php
protected function getCachedData($sKey) { if (isset($this->arCachedData[$sKey])) { return $this->arCachedData[$sKey]; } return null; }
[ "protected", "function", "getCachedData", "(", "$", "sKey", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arCachedData", "[", "$", "sKey", "]", ")", ")", "{", "return", "$", "this", "->", "arCachedData", "[", "$", "sKey", "]", ";", "}", "r...
Get cached data @param string $sKey @return mixed|null
[ "Get", "cached", "data" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/PageHelper.php#L169-L176
43,680
lovata/oc-toolbox-plugin
classes/helper/PageHelper.php
PageHelper.getPageList
protected function getPageList() { //Get CMS page list $obPageList = $this->getCmsPageList(); //Get static page list $obStaticPageList = $this->getStaticPageList(); if (!empty($obStaticPageList)) { if (empty($obPageList)) { return $obStaticPageList; } $obPageList = $obPageList->merge($obStaticPageList->all()); } return $obPageList; }
php
protected function getPageList() { //Get CMS page list $obPageList = $this->getCmsPageList(); //Get static page list $obStaticPageList = $this->getStaticPageList(); if (!empty($obStaticPageList)) { if (empty($obPageList)) { return $obStaticPageList; } $obPageList = $obPageList->merge($obStaticPageList->all()); } return $obPageList; }
[ "protected", "function", "getPageList", "(", ")", "{", "//Get CMS page list", "$", "obPageList", "=", "$", "this", "->", "getCmsPageList", "(", ")", ";", "//Get static page list", "$", "obStaticPageList", "=", "$", "this", "->", "getStaticPageList", "(", ")", ";...
Get page list @return array|\Cms\Classes\CmsObjectCollection|CmsPage[]|null
[ "Get", "page", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/PageHelper.php#L201-L217
43,681
lovata/oc-toolbox-plugin
classes/helper/PageHelper.php
PageHelper.getStaticPageList
protected function getStaticPageList() { if (!PluginManager::instance()->hasPlugin('RainLab.Pages') || empty($this->obTheme)) { return null; } //Get Static page list /** @var \Cms\Classes\CmsObjectCollection|\Cms\Classes\Page[] $obStaticPageList */ $obStaticPage = new \RainLab\Pages\Classes\PageList($this->obTheme); $obStaticPageList = $obStaticPage->listPages(true); return $obStaticPageList; }
php
protected function getStaticPageList() { if (!PluginManager::instance()->hasPlugin('RainLab.Pages') || empty($this->obTheme)) { return null; } //Get Static page list /** @var \Cms\Classes\CmsObjectCollection|\Cms\Classes\Page[] $obStaticPageList */ $obStaticPage = new \RainLab\Pages\Classes\PageList($this->obTheme); $obStaticPageList = $obStaticPage->listPages(true); return $obStaticPageList; }
[ "protected", "function", "getStaticPageList", "(", ")", "{", "if", "(", "!", "PluginManager", "::", "instance", "(", ")", "->", "hasPlugin", "(", "'RainLab.Pages'", ")", "||", "empty", "(", "$", "this", "->", "obTheme", ")", ")", "{", "return", "null", "...
Get Static page list @return array|\Cms\Classes\CmsObjectCollection|CmsPage[]|null
[ "Get", "Static", "page", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/PageHelper.php#L239-L251
43,682
lovata/oc-toolbox-plugin
traits/helpers/TraitCached.php
TraitCached.addCachedField
public function addCachedField($arFieldList) { if (empty($arFieldList)) { return; } if (empty($this->cached) || !is_array($this->cached)) { $this->cached = []; } if (is_string($arFieldList)) { $arFieldList = [$arFieldList]; } $this->cached = array_merge($this->cached, $arFieldList); $this->cached = array_unique($this->cached); }
php
public function addCachedField($arFieldList) { if (empty($arFieldList)) { return; } if (empty($this->cached) || !is_array($this->cached)) { $this->cached = []; } if (is_string($arFieldList)) { $arFieldList = [$arFieldList]; } $this->cached = array_merge($this->cached, $arFieldList); $this->cached = array_unique($this->cached); }
[ "public", "function", "addCachedField", "(", "$", "arFieldList", ")", "{", "if", "(", "empty", "(", "$", "arFieldList", ")", ")", "{", "return", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "cached", ")", "||", "!", "is_array", "(", "$", "...
Add fields to cached field list @param array|string $arFieldList
[ "Add", "fields", "to", "cached", "field", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/traits/helpers/TraitCached.php#L16-L32
43,683
lovata/oc-toolbox-plugin
traits/helpers/TraitCached.php
TraitCached.getCachedField
public function getCachedField(): array { if (empty($this->cached) || !is_array($this->cached)) { $this->cached = []; } return $this->cached; }
php
public function getCachedField(): array { if (empty($this->cached) || !is_array($this->cached)) { $this->cached = []; } return $this->cached; }
[ "public", "function", "getCachedField", "(", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "this", "->", "cached", ")", "||", "!", "is_array", "(", "$", "this", "->", "cached", ")", ")", "{", "$", "this", "->", "cached", "=", "[", "]", ";...
Get cached field list @return array
[ "Get", "cached", "field", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/traits/helpers/TraitCached.php#L38-L45
43,684
lovata/oc-toolbox-plugin
models/CommonSettings.php
CommonSettings.getValue
public static function getValue($sCode, $sDefaultValue = null) { if (empty($sCode)) { return $sDefaultValue; } //Get settings object $obSettings = static::where('item', static::SETTINGS_CODE)->first(); if (empty($obSettings)) { return static::get($sCode, $sDefaultValue); } $sValue = $obSettings->$sCode; if (empty($sValue)) { return $sDefaultValue; } return $sValue; }
php
public static function getValue($sCode, $sDefaultValue = null) { if (empty($sCode)) { return $sDefaultValue; } //Get settings object $obSettings = static::where('item', static::SETTINGS_CODE)->first(); if (empty($obSettings)) { return static::get($sCode, $sDefaultValue); } $sValue = $obSettings->$sCode; if (empty($sValue)) { return $sDefaultValue; } return $sValue; }
[ "public", "static", "function", "getValue", "(", "$", "sCode", ",", "$", "sDefaultValue", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "sCode", ")", ")", "{", "return", "$", "sDefaultValue", ";", "}", "//Get settings object", "$", "obSettings", "...
Get setting value @param string $sCode @param string $sDefaultValue @return null|string
[ "Get", "setting", "value" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/models/CommonSettings.php#L32-L50
43,685
lovata/oc-toolbox-plugin
classes/event/AbstractModelRelationHandler.php
AbstractModelRelationHandler.checkRelationName
protected function checkRelationName($sRelationName) : bool { $sCheckedRelationName = $this->getRelationName(); if (empty($sCheckedRelationName)) { return true; } if (is_array($sCheckedRelationName) && in_array($sRelationName, $sCheckedRelationName)) { return true; } $bResult = $sRelationName == $sCheckedRelationName; return $bResult; }
php
protected function checkRelationName($sRelationName) : bool { $sCheckedRelationName = $this->getRelationName(); if (empty($sCheckedRelationName)) { return true; } if (is_array($sCheckedRelationName) && in_array($sRelationName, $sCheckedRelationName)) { return true; } $bResult = $sRelationName == $sCheckedRelationName; return $bResult; }
[ "protected", "function", "checkRelationName", "(", "$", "sRelationName", ")", ":", "bool", "{", "$", "sCheckedRelationName", "=", "$", "this", "->", "getRelationName", "(", ")", ";", "if", "(", "empty", "(", "$", "sCheckedRelationName", ")", ")", "{", "retur...
Check relation name @param string $sRelationName @return bool
[ "Check", "relation", "name" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/event/AbstractModelRelationHandler.php#L68-L82
43,686
lovata/oc-toolbox-plugin
traits/helpers/TraitComponentNotFoundResponse.php
TraitComponentNotFoundResponse.getErrorResponse
protected function getErrorResponse() { if (Request::ajax()) { throw new AjaxException('Element not found'); } return Response::make($this->controller->run('404')->getContent(), 404); }
php
protected function getErrorResponse() { if (Request::ajax()) { throw new AjaxException('Element not found'); } return Response::make($this->controller->run('404')->getContent(), 404); }
[ "protected", "function", "getErrorResponse", "(", ")", "{", "if", "(", "Request", "::", "ajax", "(", ")", ")", "{", "throw", "new", "AjaxException", "(", "'Element not found'", ")", ";", "}", "return", "Response", "::", "make", "(", "$", "this", "->", "c...
Get error response for 404 page @throws AjaxException @return \Illuminate\Http\Response
[ "Get", "error", "response", "for", "404", "page" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/traits/helpers/TraitComponentNotFoundResponse.php#L51-L58
43,687
lovata/oc-toolbox-plugin
traits/helpers/PriceHelperTrait.php
PriceHelperTrait.addPriceFiledMethods
protected static function addPriceFiledMethods($obElement) { if (empty($obElement->arPriceField) || !is_array($obElement->arPriceField)) { return; } foreach ($obElement->arPriceField as $sFieldName) { if (empty($sFieldName) || !is_string($sFieldName)) { continue; } $sFieldConvert = Str::studly($sFieldName); self::addGetPriceFieldMethod($obElement, $sFieldName, $sFieldConvert); if ($obElement instanceof Model) { self::addSetPriceFieldMethod($obElement, $sFieldName, $sFieldConvert); self::addGetPriceValueFieldMethod($obElement, $sFieldName, $sFieldConvert); self::addScopePriceFieldMethod($obElement, $sFieldName, $sFieldConvert); } } }
php
protected static function addPriceFiledMethods($obElement) { if (empty($obElement->arPriceField) || !is_array($obElement->arPriceField)) { return; } foreach ($obElement->arPriceField as $sFieldName) { if (empty($sFieldName) || !is_string($sFieldName)) { continue; } $sFieldConvert = Str::studly($sFieldName); self::addGetPriceFieldMethod($obElement, $sFieldName, $sFieldConvert); if ($obElement instanceof Model) { self::addSetPriceFieldMethod($obElement, $sFieldName, $sFieldConvert); self::addGetPriceValueFieldMethod($obElement, $sFieldName, $sFieldConvert); self::addScopePriceFieldMethod($obElement, $sFieldName, $sFieldConvert); } } }
[ "protected", "static", "function", "addPriceFiledMethods", "(", "$", "obElement", ")", "{", "if", "(", "empty", "(", "$", "obElement", "->", "arPriceField", ")", "||", "!", "is_array", "(", "$", "obElement", "->", "arPriceField", ")", ")", "{", "return", "...
Check arPriceField array and add price methods to model object @param \Model|\Eloquent|\Lovata\Toolbox\Classes\Item\ElementItem $obElement $obElement
[ "Check", "arPriceField", "array", "and", "add", "price", "methods", "to", "model", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/traits/helpers/PriceHelperTrait.php#L29-L51
43,688
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.clearCache
public static function clearCache($iElementID) { if (empty($iElementID)) { return; } ItemStorage::clear(static::class, $iElementID); CCache::clear(static::getCacheTag(), $iElementID); }
php
public static function clearCache($iElementID) { if (empty($iElementID)) { return; } ItemStorage::clear(static::class, $iElementID); CCache::clear(static::getCacheTag(), $iElementID); }
[ "public", "static", "function", "clearCache", "(", "$", "iElementID", ")", "{", "if", "(", "empty", "(", "$", "iElementID", ")", ")", "{", "return", ";", "}", "ItemStorage", "::", "clear", "(", "static", "::", "class", ",", "$", "iElementID", ")", ";",...
Remove model data from cache @link https://github.com/lovata/oc-toolbox-plugin/wiki/ElementItem#clearcacheielementid @param int $iElementID
[ "Remove", "model", "data", "from", "cache" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L193-L201
43,689
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.setData
protected function setData() { $this->initElementObject(); if (empty($this->obElement)) { return; } //Set default lang (if update cache with non default lang) if (self::$bLangInit && !empty(self::$sDefaultLang) && $this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { $this->obElement->lang(self::$sDefaultLang); } //Get cached field list from model and add fields to cache array $this->setCachedFieldList(); //Get element data $arResult = $this->getElementData(); if (empty($arResult) || !is_array($arResult)) { $arResult = []; } //Add fields values to cached array foreach ($arResult as $sField => $sValue) { $this->setAttribute($sField, $sValue); } //Save lang properties (integration with Translate plugin) $this->setLangProperties(); //Run methods from $arExtendResult array $this->setExtendData(); }
php
protected function setData() { $this->initElementObject(); if (empty($this->obElement)) { return; } //Set default lang (if update cache with non default lang) if (self::$bLangInit && !empty(self::$sDefaultLang) && $this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { $this->obElement->lang(self::$sDefaultLang); } //Get cached field list from model and add fields to cache array $this->setCachedFieldList(); //Get element data $arResult = $this->getElementData(); if (empty($arResult) || !is_array($arResult)) { $arResult = []; } //Add fields values to cached array foreach ($arResult as $sField => $sValue) { $this->setAttribute($sField, $sValue); } //Save lang properties (integration with Translate plugin) $this->setLangProperties(); //Run methods from $arExtendResult array $this->setExtendData(); }
[ "protected", "function", "setData", "(", ")", "{", "$", "this", "->", "initElementObject", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "obElement", ")", ")", "{", "return", ";", "}", "//Set default lang (if update cache with non default lang)", ...
Set data from model object
[ "Set", "data", "from", "model", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L259-L290
43,690
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.setCachedFieldList
protected function setCachedFieldList() { if (!method_exists($this->obElement, 'getCachedField')) { return; } //Get cached field list $arFieldList = $this->obElement->getCachedField(); if (empty($arFieldList)) { return; } foreach ($arFieldList as $sField) { if (array_key_exists($sField, (array) $this->obElement->attachOne)) { $arFileData = $this->getUploadFileData($this->obElement->$sField); $sFieldName = 'attachOne|'.$sField; $this->setAttribute($sFieldName, $arFileData); } elseif (array_key_exists($sField, (array) $this->obElement->attachMany)) { $arFileList = []; $obFileList = $this->obElement->$sField; foreach ($obFileList as $obFile) { $arFileData = $this->getUploadFileData($obFile); $arFileList[] = $arFileData; } $sFieldName = 'attachMany|'.$sField; $this->setAttribute($sFieldName, $arFileList); } else { $this->setAttribute($sField, $this->obElement->$sField); } } }
php
protected function setCachedFieldList() { if (!method_exists($this->obElement, 'getCachedField')) { return; } //Get cached field list $arFieldList = $this->obElement->getCachedField(); if (empty($arFieldList)) { return; } foreach ($arFieldList as $sField) { if (array_key_exists($sField, (array) $this->obElement->attachOne)) { $arFileData = $this->getUploadFileData($this->obElement->$sField); $sFieldName = 'attachOne|'.$sField; $this->setAttribute($sFieldName, $arFileData); } elseif (array_key_exists($sField, (array) $this->obElement->attachMany)) { $arFileList = []; $obFileList = $this->obElement->$sField; foreach ($obFileList as $obFile) { $arFileData = $this->getUploadFileData($obFile); $arFileList[] = $arFileData; } $sFieldName = 'attachMany|'.$sField; $this->setAttribute($sFieldName, $arFileList); } else { $this->setAttribute($sField, $this->obElement->$sField); } } }
[ "protected", "function", "setCachedFieldList", "(", ")", "{", "if", "(", "!", "method_exists", "(", "$", "this", "->", "obElement", ",", "'getCachedField'", ")", ")", "{", "return", ";", "}", "//Get cached field list", "$", "arFieldList", "=", "$", "this", "...
Get cached field list from model and add fields to cache array
[ "Get", "cached", "field", "list", "from", "model", "and", "add", "fields", "to", "cache", "array" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L295-L326
43,691
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.setCachedData
protected function setCachedData() { if (empty($this->iElementID)) { return; } $arCacheTags = static::getCacheTag(); $sCacheKey = $this->iElementID; $this->arModelData = CCache::get($arCacheTags, $sCacheKey); if (!$this->isEmpty()) { return; } $this->setData(); //Set cache data CCache::forever($arCacheTags, $sCacheKey, $this->arModelData); }
php
protected function setCachedData() { if (empty($this->iElementID)) { return; } $arCacheTags = static::getCacheTag(); $sCacheKey = $this->iElementID; $this->arModelData = CCache::get($arCacheTags, $sCacheKey); if (!$this->isEmpty()) { return; } $this->setData(); //Set cache data CCache::forever($arCacheTags, $sCacheKey, $this->arModelData); }
[ "protected", "function", "setCachedData", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "iElementID", ")", ")", "{", "return", ";", "}", "$", "arCacheTags", "=", "static", "::", "getCacheTag", "(", ")", ";", "$", "sCacheKey", "=", "$", "...
Set cached brand data
[ "Set", "cached", "brand", "data" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L351-L369
43,692
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.initElementObject
protected function initElementObject() { $sModelClass = static::MODEL_CLASS; if (!empty($this->obElement) && !$this->obElement instanceof $sModelClass) { $this->obElement = null; } if (!empty($this->obElement) || empty($this->iElementID)) { return; } $this->setElementObject(); }
php
protected function initElementObject() { $sModelClass = static::MODEL_CLASS; if (!empty($this->obElement) && !$this->obElement instanceof $sModelClass) { $this->obElement = null; } if (!empty($this->obElement) || empty($this->iElementID)) { return; } $this->setElementObject(); }
[ "protected", "function", "initElementObject", "(", ")", "{", "$", "sModelClass", "=", "static", "::", "MODEL_CLASS", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "obElement", ")", "&&", "!", "$", "this", "->", "obElement", "instanceof", "$", "sM...
Init element object
[ "Init", "element", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L422-L434
43,693
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.setLangProperties
private function setLangProperties() { if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { return; } //Check translate model property if (empty($this->obElement->translatable) || !is_array($this->obElement->translatable)) { return; } //Get active lang list from Translate plugin $arLangList = self::getActiveLangList(); if (empty($arLangList)) { return; } //Process translatable fields foreach ($this->obElement->translatable as $sField) { //Check field name if (empty($sField) || (!is_string($sField) && !is_array($sField))) { continue; } if (is_array($sField)) { $sField = array_shift($sField); } if (!isset($this->arModelData[$sField]) || array_key_exists($sField, (array) $this->obElement->attachOne) || array_key_exists($sField, (array) $this->obElement->attachMany)) { continue; } //Save field value with different lang code foreach ($arLangList as $sLangCode) { $sLangField = $sField.'|'.$sLangCode; $sValue = $this->obElement->lang($sLangCode)->$sField; $this->setAttribute($sLangField, $sValue); } } }
php
private function setLangProperties() { if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { return; } //Check translate model property if (empty($this->obElement->translatable) || !is_array($this->obElement->translatable)) { return; } //Get active lang list from Translate plugin $arLangList = self::getActiveLangList(); if (empty($arLangList)) { return; } //Process translatable fields foreach ($this->obElement->translatable as $sField) { //Check field name if (empty($sField) || (!is_string($sField) && !is_array($sField))) { continue; } if (is_array($sField)) { $sField = array_shift($sField); } if (!isset($this->arModelData[$sField]) || array_key_exists($sField, (array) $this->obElement->attachOne) || array_key_exists($sField, (array) $this->obElement->attachMany)) { continue; } //Save field value with different lang code foreach ($arLangList as $sLangCode) { $sLangField = $sField.'|'.$sLangCode; $sValue = $this->obElement->lang($sLangCode)->$sField; $this->setAttribute($sLangField, $sValue); } } }
[ "private", "function", "setLangProperties", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "obElement", ")", "||", "!", "$", "this", "->", "obElement", "->", "isClassExtendedWith", "(", "'RainLab.Translate.Behaviors.TranslatableModel'", ")", ")", "{"...
Process translatable fields and save values, how 'field_name|lang_code'
[ "Process", "translatable", "fields", "and", "save", "values", "how", "field_name|lang_code" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L457-L496
43,694
lovata/oc-toolbox-plugin
classes/item/ElementItem.php
ElementItem.getUploadFileData
private function getUploadFileData($obFile) : array { if (empty($obFile)) { return []; } //Set default lang in image object if (!empty(self::$sDefaultLang) && $obFile->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { $obFile->lang(self::$sDefaultLang); } //Convert image data to array $arFileData = $obFile->toArray(); $arLangList = $this->getActiveLangList(); if (empty($arLangList) || !$obFile->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { return $arFileData; } //Add lang fields to array foreach ($arLangList as $sLangCode) { $arFileData[$sLangCode] = []; foreach ($obFile->translatable as $sLangField) { $arFileData[$sLangCode][$sLangField] = $obFile->lang($sLangCode)->$sLangField; } } return $arFileData; }
php
private function getUploadFileData($obFile) : array { if (empty($obFile)) { return []; } //Set default lang in image object if (!empty(self::$sDefaultLang) && $obFile->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { $obFile->lang(self::$sDefaultLang); } //Convert image data to array $arFileData = $obFile->toArray(); $arLangList = $this->getActiveLangList(); if (empty($arLangList) || !$obFile->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) { return $arFileData; } //Add lang fields to array foreach ($arLangList as $sLangCode) { $arFileData[$sLangCode] = []; foreach ($obFile->translatable as $sLangField) { $arFileData[$sLangCode][$sLangField] = $obFile->lang($sLangCode)->$sLangField; } } return $arFileData; }
[ "private", "function", "getUploadFileData", "(", "$", "obFile", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "obFile", ")", ")", "{", "return", "[", "]", ";", "}", "//Set default lang in image object", "if", "(", "!", "empty", "(", "self", "::",...
Get image data from image object @param \System\Models\File $obFile @return []
[ "Get", "image", "data", "from", "image", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ElementItem.php#L503-L530
43,695
lovata/oc-toolbox-plugin
Plugin.php
Plugin.boot
public function boot() { if (env('APP_ENV') == 'testing') { $this->app->bind(\Lovata\Toolbox\Classes\Item\TestItem::class, \Lovata\Toolbox\Classes\Item\TestItem::class); $this->app->bind(\Lovata\Toolbox\Classes\Collection\TestCollection::class, \Lovata\Toolbox\Classes\Collection\TestCollection::class); } }
php
public function boot() { if (env('APP_ENV') == 'testing') { $this->app->bind(\Lovata\Toolbox\Classes\Item\TestItem::class, \Lovata\Toolbox\Classes\Item\TestItem::class); $this->app->bind(\Lovata\Toolbox\Classes\Collection\TestCollection::class, \Lovata\Toolbox\Classes\Collection\TestCollection::class); } }
[ "public", "function", "boot", "(", ")", "{", "if", "(", "env", "(", "'APP_ENV'", ")", "==", "'testing'", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "\\", "Lovata", "\\", "Toolbox", "\\", "Classes", "\\", "Item", "\\", "TestItem", "::", ...
Plugin boot method
[ "Plugin", "boot", "method" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/Plugin.php#L61-L67
43,696
lovata/oc-toolbox-plugin
models/CommonProperty.php
CommonProperty.getWidgetData
public function getWidgetData() { $arResult = []; switch ($this->type) { case self::TYPE_INPUT: $arResult = $this->getInputFieldSettings(); break; case self::TYPE_NUMBER: $arResult = $this->getNumberFieldSettings(); break; case self::TYPE_TEXT_AREA: $arResult = $this->getTextareaFieldSettings(); break; case self::TYPE_RICH_EDITOR: $arResult = $this->getRichEditorFieldSettings(); break; case self::TYPE_SINGLE_CHECKBOX: $arResult = $this->getSingleCheckboxFieldSettings(); break; case self::TYPE_SWITCH: $arResult = $this->getSwitchFieldSettings(); break; case self::TYPE_CHECKBOX: $arResult = $this->getCheckboxListSettings(); break; case self::TYPE_BALLOON: $arResult = $this->getBalloonSettings(); break; case self::TYPE_TAG_LIST: $arResult = $this->getTagListSettings(); break; case self::TYPE_SELECT: $arResult = $this->getSelectSettings(); break; case self::TYPE_RADIO: $arResult = $this->getRadioSettings(); break; case self::TYPE_DATE: $arResult = $this->getDateSettings(); break; case self::TYPE_COLOR_PICKER: $arResult = $this->getColorPickerSettings(); break; /** FILE FINDER TYPE */ case self::TYPE_MEDIA_FINDER: $arResult = $this->getMediaFinderSettings(); break; default: return $arResult; } //Get common widget settings if (empty($arResult)) { return $arResult; } $arResult = array_merge($arResult, $this->getDefaultConfigSettings()); return $arResult; }
php
public function getWidgetData() { $arResult = []; switch ($this->type) { case self::TYPE_INPUT: $arResult = $this->getInputFieldSettings(); break; case self::TYPE_NUMBER: $arResult = $this->getNumberFieldSettings(); break; case self::TYPE_TEXT_AREA: $arResult = $this->getTextareaFieldSettings(); break; case self::TYPE_RICH_EDITOR: $arResult = $this->getRichEditorFieldSettings(); break; case self::TYPE_SINGLE_CHECKBOX: $arResult = $this->getSingleCheckboxFieldSettings(); break; case self::TYPE_SWITCH: $arResult = $this->getSwitchFieldSettings(); break; case self::TYPE_CHECKBOX: $arResult = $this->getCheckboxListSettings(); break; case self::TYPE_BALLOON: $arResult = $this->getBalloonSettings(); break; case self::TYPE_TAG_LIST: $arResult = $this->getTagListSettings(); break; case self::TYPE_SELECT: $arResult = $this->getSelectSettings(); break; case self::TYPE_RADIO: $arResult = $this->getRadioSettings(); break; case self::TYPE_DATE: $arResult = $this->getDateSettings(); break; case self::TYPE_COLOR_PICKER: $arResult = $this->getColorPickerSettings(); break; /** FILE FINDER TYPE */ case self::TYPE_MEDIA_FINDER: $arResult = $this->getMediaFinderSettings(); break; default: return $arResult; } //Get common widget settings if (empty($arResult)) { return $arResult; } $arResult = array_merge($arResult, $this->getDefaultConfigSettings()); return $arResult; }
[ "public", "function", "getWidgetData", "(", ")", "{", "$", "arResult", "=", "[", "]", ";", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "self", "::", "TYPE_INPUT", ":", "$", "arResult", "=", "$", "this", "->", "getInputFieldSettings", "(...
Get widget data @return array
[ "Get", "widget", "data" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/models/CommonProperty.php#L83-L143
43,697
lovata/oc-toolbox-plugin
models/CommonProperty.php
CommonProperty.getPropertyVariants
public function getPropertyVariants() { $arValueList = []; //Get and check settings array $arSettings = $this->settings; if (empty($arSettings) || !isset($arSettings['list']) || empty($arSettings['list'])) { return $arValueList; } //Get property value variants foreach ($arSettings['list'] as $arValue) { if (!isset($arValue['value']) || empty($arValue['value'])) { continue; } $arValueList[$arValue['value']] = $arValue['value']; } natsort($arValueList); return $arValueList; }
php
public function getPropertyVariants() { $arValueList = []; //Get and check settings array $arSettings = $this->settings; if (empty($arSettings) || !isset($arSettings['list']) || empty($arSettings['list'])) { return $arValueList; } //Get property value variants foreach ($arSettings['list'] as $arValue) { if (!isset($arValue['value']) || empty($arValue['value'])) { continue; } $arValueList[$arValue['value']] = $arValue['value']; } natsort($arValueList); return $arValueList; }
[ "public", "function", "getPropertyVariants", "(", ")", "{", "$", "arValueList", "=", "[", "]", ";", "//Get and check settings array", "$", "arSettings", "=", "$", "this", "->", "settings", ";", "if", "(", "empty", "(", "$", "arSettings", ")", "||", "!", "i...
Get property variants from settings @return array
[ "Get", "property", "variants", "from", "settings" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/models/CommonProperty.php#L149-L171
43,698
lovata/oc-toolbox-plugin
models/CommonProperty.php
CommonProperty.getTypeOptions
public function getTypeOptions() { $sLangPath = 'lovata.toolbox::lang.type.'; return [ self::TYPE_INPUT => Lang::get($sLangPath.self::TYPE_INPUT), self::TYPE_NUMBER => Lang::get($sLangPath.self::TYPE_NUMBER), self::TYPE_TEXT_AREA => Lang::get($sLangPath.self::TYPE_TEXT_AREA), self::TYPE_RICH_EDITOR => Lang::get($sLangPath.self::TYPE_RICH_EDITOR), self::TYPE_SINGLE_CHECKBOX => Lang::get($sLangPath.self::TYPE_SINGLE_CHECKBOX), self::TYPE_SWITCH => Lang::get($sLangPath.self::TYPE_SWITCH), self::TYPE_CHECKBOX => Lang::get($sLangPath.self::TYPE_CHECKBOX), self::TYPE_TAG_LIST => Lang::get($sLangPath.self::TYPE_TAG_LIST), self::TYPE_SELECT => Lang::get($sLangPath.self::TYPE_SELECT), self::TYPE_RADIO => Lang::get($sLangPath.self::TYPE_RADIO), self::TYPE_BALLOON => Lang::get($sLangPath.self::TYPE_BALLOON), self::TYPE_DATE => Lang::get($sLangPath.self::TYPE_DATE), self::TYPE_COLOR_PICKER => Lang::get($sLangPath.self::TYPE_COLOR_PICKER), self::TYPE_MEDIA_FINDER => Lang::get($sLangPath.self::TYPE_MEDIA_FINDER), ]; }
php
public function getTypeOptions() { $sLangPath = 'lovata.toolbox::lang.type.'; return [ self::TYPE_INPUT => Lang::get($sLangPath.self::TYPE_INPUT), self::TYPE_NUMBER => Lang::get($sLangPath.self::TYPE_NUMBER), self::TYPE_TEXT_AREA => Lang::get($sLangPath.self::TYPE_TEXT_AREA), self::TYPE_RICH_EDITOR => Lang::get($sLangPath.self::TYPE_RICH_EDITOR), self::TYPE_SINGLE_CHECKBOX => Lang::get($sLangPath.self::TYPE_SINGLE_CHECKBOX), self::TYPE_SWITCH => Lang::get($sLangPath.self::TYPE_SWITCH), self::TYPE_CHECKBOX => Lang::get($sLangPath.self::TYPE_CHECKBOX), self::TYPE_TAG_LIST => Lang::get($sLangPath.self::TYPE_TAG_LIST), self::TYPE_SELECT => Lang::get($sLangPath.self::TYPE_SELECT), self::TYPE_RADIO => Lang::get($sLangPath.self::TYPE_RADIO), self::TYPE_BALLOON => Lang::get($sLangPath.self::TYPE_BALLOON), self::TYPE_DATE => Lang::get($sLangPath.self::TYPE_DATE), self::TYPE_COLOR_PICKER => Lang::get($sLangPath.self::TYPE_COLOR_PICKER), self::TYPE_MEDIA_FINDER => Lang::get($sLangPath.self::TYPE_MEDIA_FINDER), ]; }
[ "public", "function", "getTypeOptions", "(", ")", "{", "$", "sLangPath", "=", "'lovata.toolbox::lang.type.'", ";", "return", "[", "self", "::", "TYPE_INPUT", "=>", "Lang", "::", "get", "(", "$", "sLangPath", ".", "self", "::", "TYPE_INPUT", ")", ",", "self",...
Get type list @return array
[ "Get", "type", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/models/CommonProperty.php#L186-L206
43,699
lovata/oc-toolbox-plugin
models/CommonProperty.php
CommonProperty.getMediaFinderSettings
protected function getMediaFinderSettings() : array { $sMode = $this->getSettingValue(self::TYPE_MEDIA_FINDER); if (!in_array($sMode, ['file', 'image'])) { return []; } $arResult = [ 'type' => self::TYPE_MEDIA_FINDER, 'mode' => $sMode, ]; return $arResult; }
php
protected function getMediaFinderSettings() : array { $sMode = $this->getSettingValue(self::TYPE_MEDIA_FINDER); if (!in_array($sMode, ['file', 'image'])) { return []; } $arResult = [ 'type' => self::TYPE_MEDIA_FINDER, 'mode' => $sMode, ]; return $arResult; }
[ "protected", "function", "getMediaFinderSettings", "(", ")", ":", "array", "{", "$", "sMode", "=", "$", "this", "->", "getSettingValue", "(", "self", "::", "TYPE_MEDIA_FINDER", ")", ";", "if", "(", "!", "in_array", "(", "$", "sMode", ",", "[", "'file'", ...
Get field setting with type "media finder" @return array
[ "Get", "field", "setting", "with", "type", "media", "finder" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/models/CommonProperty.php#L447-L460