repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
php-lug/lug
src/Bundle/GridBundle/Form/Type/Filter/TextFilterType.php
TextFilterType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add($builder->create('type', ChoiceType::class, [ 'choices' => array_combine( array_map(function ($choice) use ($options) { return $options['label_prefix'].'.type.'.$choice; }, $choices = TextType::getTypes()), $choices ), 'choices_as_values' => true, 'xml_http_request_trigger' => true, ]) ->addEventSubscriber($this->textFilterSubscriber)); }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add($builder->create('type', ChoiceType::class, [ 'choices' => array_combine( array_map(function ($choice) use ($options) { return $options['label_prefix'].'.type.'.$choice; }, $choices = TextType::getTypes()), $choices ), 'choices_as_values' => true, 'xml_http_request_trigger' => true, ]) ->addEventSubscriber($this->textFilterSubscriber)); }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "builder", "->", "add", "(", "$", "builder", "->", "create", "(", "'type'", ",", "ChoiceType", "::", "class", ",", "[", "'choices'", "=>", "array_combine", "(", "array_map", "(", "function", "(", "$", "choice", ")", "use", "(", "$", "options", ")", "{", "return", "$", "options", "[", "'label_prefix'", "]", ".", "'.type.'", ".", "$", "choice", ";", "}", ",", "$", "choices", "=", "TextType", "::", "getTypes", "(", ")", ")", ",", "$", "choices", ")", ",", "'choices_as_values'", "=>", "true", ",", "'xml_http_request_trigger'", "=>", "true", ",", "]", ")", "->", "addEventSubscriber", "(", "$", "this", "->", "textFilterSubscriber", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/Type/Filter/TextFilterType.php#L40-L54
php-lug/lug
src/Bundle/GridBundle/Form/EventSubscriber/Batch/AbstractGridBatchSubscriber.php
AbstractGridBatchSubscriber.handleAll
private function handleAll(FormInterface $form) { $config = $form->get('value')->getConfig(); $choiceValue = $config->getOption('choice_value'); $choices = iterator_to_array($config->getOption('grid')->getDataSource(['all' => true])); $this->buildForm($form, $choices); return array_map(function ($choice) use ($choiceValue) { return call_user_func($choiceValue, $choice); }, $choices); }
php
private function handleAll(FormInterface $form) { $config = $form->get('value')->getConfig(); $choiceValue = $config->getOption('choice_value'); $choices = iterator_to_array($config->getOption('grid')->getDataSource(['all' => true])); $this->buildForm($form, $choices); return array_map(function ($choice) use ($choiceValue) { return call_user_func($choiceValue, $choice); }, $choices); }
[ "private", "function", "handleAll", "(", "FormInterface", "$", "form", ")", "{", "$", "config", "=", "$", "form", "->", "get", "(", "'value'", ")", "->", "getConfig", "(", ")", ";", "$", "choiceValue", "=", "$", "config", "->", "getOption", "(", "'choice_value'", ")", ";", "$", "choices", "=", "iterator_to_array", "(", "$", "config", "->", "getOption", "(", "'grid'", ")", "->", "getDataSource", "(", "[", "'all'", "=>", "true", "]", ")", ")", ";", "$", "this", "->", "buildForm", "(", "$", "form", ",", "$", "choices", ")", ";", "return", "array_map", "(", "function", "(", "$", "choice", ")", "use", "(", "$", "choiceValue", ")", "{", "return", "call_user_func", "(", "$", "choiceValue", ",", "$", "choice", ")", ";", "}", ",", "$", "choices", ")", ";", "}" ]
@param FormInterface $form @return mixed[]
[ "@param", "FormInterface", "$form" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/EventSubscriber/Batch/AbstractGridBatchSubscriber.php#L120-L131
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php
ClassAssembler.create
public function create($data) { $classDescriptor = new ClassDescriptor(); $classDescriptor->setFullyQualifiedStructuralElementName($data->getName()); $classDescriptor->setName($data->getShortName()); $classDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); $classDescriptor->setLine($data->getLinenumber()); $classDescriptor->setParent($data->getParentClass()); $classDescriptor->setAbstract($data->isAbstract()); $classDescriptor->setFinal($data->isFinal()); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $classDescriptor->setNamespace( '\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace()) ); foreach ($data->getInterfaces() as $interfaceClassName) { $classDescriptor->getInterfaces()->set($interfaceClassName, $interfaceClassName); } $fqcn = $classDescriptor->getFullyQualifiedStructuralElementName(); $namespace = substr($fqcn, 0, strrpos($fqcn, '\\')); $classDescriptor->setNamespace($namespace); $this->assembleDocBlock($data->getDocBlock(), $classDescriptor); $this->addConstants($data->getConstants(), $classDescriptor); $this->addProperties($data->getProperties(), $classDescriptor); $this->addMethods($data->getMethods(), $classDescriptor); $this->addUses($data->getTraits(), $classDescriptor); return $classDescriptor; }
php
public function create($data) { $classDescriptor = new ClassDescriptor(); $classDescriptor->setFullyQualifiedStructuralElementName($data->getName()); $classDescriptor->setName($data->getShortName()); $classDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: ''); $classDescriptor->setLine($data->getLinenumber()); $classDescriptor->setParent($data->getParentClass()); $classDescriptor->setAbstract($data->isAbstract()); $classDescriptor->setFinal($data->isFinal()); // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself $classDescriptor->setNamespace( '\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace()) ); foreach ($data->getInterfaces() as $interfaceClassName) { $classDescriptor->getInterfaces()->set($interfaceClassName, $interfaceClassName); } $fqcn = $classDescriptor->getFullyQualifiedStructuralElementName(); $namespace = substr($fqcn, 0, strrpos($fqcn, '\\')); $classDescriptor->setNamespace($namespace); $this->assembleDocBlock($data->getDocBlock(), $classDescriptor); $this->addConstants($data->getConstants(), $classDescriptor); $this->addProperties($data->getProperties(), $classDescriptor); $this->addMethods($data->getMethods(), $classDescriptor); $this->addUses($data->getTraits(), $classDescriptor); return $classDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "classDescriptor", "=", "new", "ClassDescriptor", "(", ")", ";", "$", "classDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "classDescriptor", "->", "setName", "(", "$", "data", "->", "getShortName", "(", ")", ")", ";", "$", "classDescriptor", "->", "setPackage", "(", "$", "this", "->", "extractPackageFromDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ")", "?", ":", "''", ")", ";", "$", "classDescriptor", "->", "setLine", "(", "$", "data", "->", "getLinenumber", "(", ")", ")", ";", "$", "classDescriptor", "->", "setParent", "(", "$", "data", "->", "getParentClass", "(", ")", ")", ";", "$", "classDescriptor", "->", "setAbstract", "(", "$", "data", "->", "isAbstract", "(", ")", ")", ";", "$", "classDescriptor", "->", "setFinal", "(", "$", "data", "->", "isFinal", "(", ")", ")", ";", "// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself", "$", "classDescriptor", "->", "setNamespace", "(", "'\\\\'", ".", "(", "strtolower", "(", "$", "data", "->", "getNamespace", "(", ")", ")", "==", "'global'", "?", "''", ":", "$", "data", "->", "getNamespace", "(", ")", ")", ")", ";", "foreach", "(", "$", "data", "->", "getInterfaces", "(", ")", "as", "$", "interfaceClassName", ")", "{", "$", "classDescriptor", "->", "getInterfaces", "(", ")", "->", "set", "(", "$", "interfaceClassName", ",", "$", "interfaceClassName", ")", ";", "}", "$", "fqcn", "=", "$", "classDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ";", "$", "namespace", "=", "substr", "(", "$", "fqcn", ",", "0", ",", "strrpos", "(", "$", "fqcn", ",", "'\\\\'", ")", ")", ";", "$", "classDescriptor", "->", "setNamespace", "(", "$", "namespace", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addConstants", "(", "$", "data", "->", "getConstants", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addProperties", "(", "$", "data", "->", "getProperties", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addMethods", "(", "$", "data", "->", "getMethods", "(", ")", ",", "$", "classDescriptor", ")", ";", "$", "this", "->", "addUses", "(", "$", "data", "->", "getTraits", "(", ")", ",", "$", "classDescriptor", ")", ";", "return", "$", "classDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param ClassReflector $data @return ClassDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/ClassAssembler.php#L31-L64
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.store
public function store($key, $data, $lifetime = 0) { if ($lifetime != 0) { $lifetime = \time() + $lifetime; } $data = array($lifetime, $data); $this->hash[$key] = $data; if ($key != $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return true; }
php
public function store($key, $data, $lifetime = 0) { if ($lifetime != 0) { $lifetime = \time() + $lifetime; } $data = array($lifetime, $data); $this->hash[$key] = $data; if ($key != $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return true; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", "=", "0", ")", "{", "if", "(", "$", "lifetime", "!=", "0", ")", "{", "$", "lifetime", "=", "\\", "time", "(", ")", "+", "$", "lifetime", ";", "}", "$", "data", "=", "array", "(", "$", "lifetime", ",", "$", "data", ")", ";", "$", "this", "->", "hash", "[", "$", "key", "]", "=", "$", "data", ";", "if", "(", "$", "key", "!=", "$", "this", "->", "catalog_key", ")", "{", "$", "this", "->", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", ";", "}", "return", "true", ";", "}" ]
Store the cache data in memcache
[ "Store", "the", "cache", "data", "in", "memcache" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L48-L64
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.fetch
public function fetch($key) { if (!\array_key_exists($key, $this->hash)) { return false; } $data = $this->hash[$key]; //check to see if it expired if ($data && ($data[0] == 0 || \time() <= $data[0])) { return $data[1]; } else { $this->delete($key); return false; } }
php
public function fetch($key) { if (!\array_key_exists($key, $this->hash)) { return false; } $data = $this->hash[$key]; //check to see if it expired if ($data && ($data[0] == 0 || \time() <= $data[0])) { return $data[1]; } else { $this->delete($key); return false; } }
[ "public", "function", "fetch", "(", "$", "key", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "hash", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "$", "this", "->", "hash", "[", "$", "key", "]", ";", "//check to see if it expired", "if", "(", "$", "data", "&&", "(", "$", "data", "[", "0", "]", "==", "0", "||", "\\", "time", "(", ")", "<=", "$", "data", "[", "0", "]", ")", ")", "{", "return", "$", "data", "[", "1", "]", ";", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "key", ")", ";", "return", "false", ";", "}", "}" ]
Fetches the cache from memcache
[ "Fetches", "the", "cache", "from", "memcache" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L69-L85
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.delete
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if ($k == $key) { unset($this->hash[$key]); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
php
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if ($k == $key) { unset($this->hash[$key]); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "deleted", "=", "false", ";", "$", "catalog", "=", "\\", "array_keys", "(", "$", "this", "->", "getKeys", "(", ")", ")", ";", "foreach", "(", "$", "catalog", "as", "$", "k", ")", "{", "if", "(", "$", "k", "==", "$", "key", ")", "{", "unset", "(", "$", "this", "->", "hash", "[", "$", "key", "]", ")", ";", "if", "(", "$", "delete", ")", "{", "$", "this", "->", "catalogKeyDelete", "(", "$", "k", ")", ";", "$", "deleted", "=", "true", ";", "}", "}", "}", "return", "$", "deleted", ";", "}" ]
Deletes cache data
[ "Deletes", "cache", "data" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L90-L108
VincentChalnot/SidusDataGridBundle
Model/Column.php
Column.renderValue
public function renderValue($object, array $options = []): string { $options = array_merge( ['column' => $this, 'object' => $object], $this->getFormattingOptions(), $options ); $accessor = PropertyAccess::createPropertyAccessor(); try { $value = $accessor->getValue($object, $this->getPropertyPath()); } catch (UnexpectedTypeException $e) { return ''; } return $this->getValueRenderer()->renderValue($value, $options); }
php
public function renderValue($object, array $options = []): string { $options = array_merge( ['column' => $this, 'object' => $object], $this->getFormattingOptions(), $options ); $accessor = PropertyAccess::createPropertyAccessor(); try { $value = $accessor->getValue($object, $this->getPropertyPath()); } catch (UnexpectedTypeException $e) { return ''; } return $this->getValueRenderer()->renderValue($value, $options); }
[ "public", "function", "renderValue", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "$", "options", "=", "array_merge", "(", "[", "'column'", "=>", "$", "this", ",", "'object'", "=>", "$", "object", "]", ",", "$", "this", "->", "getFormattingOptions", "(", ")", ",", "$", "options", ")", ";", "$", "accessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "try", "{", "$", "value", "=", "$", "accessor", "->", "getValue", "(", "$", "object", ",", "$", "this", "->", "getPropertyPath", "(", ")", ")", ";", "}", "catch", "(", "UnexpectedTypeException", "$", "e", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "getValueRenderer", "(", ")", "->", "renderValue", "(", "$", "value", ",", "$", "options", ")", ";", "}" ]
Render column for a given result @param mixed $object @param array $options @return string
[ "Render", "column", "for", "a", "given", "result" ]
train
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/Column.php#L249-L264
surebert/surebert-framework
src/sb/Logger/FileSystem.php
FileSystem.getLogPath
protected function getLogPath($log) { $dir = $this->log_root.'/'.$log.'/'; if(!is_dir($dir)){ mkdir($dir, 0777, true); } return $dir; }
php
protected function getLogPath($log) { $dir = $this->log_root.'/'.$log.'/'; if(!is_dir($dir)){ mkdir($dir, 0777, true); } return $dir; }
[ "protected", "function", "getLogPath", "(", "$", "log", ")", "{", "$", "dir", "=", "$", "this", "->", "log_root", ".", "'/'", ".", "$", "log", ".", "'/'", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Grabs the log path based on the type of log @param $log Sting the log type. Should be in the $enabled_logs array @return string The path to the log directory to be used
[ "Grabs", "the", "log", "path", "based", "on", "the", "type", "of", "log" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/FileSystem.php#L40-L50
surebert/surebert-framework
src/sb/Logger/FileSystem.php
FileSystem.write
protected function write($data, $log_type) { return file_put_contents($this->getLogPath($log_type) .date('Y_m_d').'.log', "\n\n".\date('Y/m/d H:i:s') ."\t".$this->agent_str ."\n".$data, \FILE_APPEND); }
php
protected function write($data, $log_type) { return file_put_contents($this->getLogPath($log_type) .date('Y_m_d').'.log', "\n\n".\date('Y/m/d H:i:s') ."\t".$this->agent_str ."\n".$data, \FILE_APPEND); }
[ "protected", "function", "write", "(", "$", "data", ",", "$", "log_type", ")", "{", "return", "file_put_contents", "(", "$", "this", "->", "getLogPath", "(", "$", "log_type", ")", ".", "date", "(", "'Y_m_d'", ")", ".", "'.log'", ",", "\"\\n\\n\"", ".", "\\", "date", "(", "'Y/m/d H:i:s'", ")", ".", "\"\\t\"", ".", "$", "this", "->", "agent_str", ".", "\"\\n\"", ".", "$", "data", ",", "\\", "FILE_APPEND", ")", ";", "}" ]
Writes the data to file @param string $data The data to be written @param string $log_type The log_type being written to @return boolean If the data was written or not
[ "Writes", "the", "data", "to", "file" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/FileSystem.php#L58-L64
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.add
function add($header) { // convert to object form if (is_string($header)) $header = HeaderField::fromString($header); $this->_headers[] = $header; return $this; }
php
function add($header) { // convert to object form if (is_string($header)) $header = HeaderField::fromString($header); $this->_headers[] = $header; return $this; }
[ "function", "add", "(", "$", "header", ")", "{", "// convert to object form", "if", "(", "is_string", "(", "$", "header", ")", ")", "$", "header", "=", "HeaderField", "::", "fromString", "(", "$", "header", ")", ";", "$", "this", "->", "_headers", "[", "]", "=", "$", "header", ";", "return", "$", "this", ";", "}" ]
Adds a header to the collection, either in "Header: Value" format or an {@link HeaderField} object. @chainable
[ "Adds", "a", "header", "to", "the", "collection", "either", "in", "Header", ":", "Value", "format", "or", "an", "{" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L26-L34
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.remove
function remove($header) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($header); foreach ($this->_headers as $idx => $header) { if ($header->getName() == $name) unset($this->_headers[$idx]); } return $this; }
php
function remove($header) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($header); foreach ($this->_headers as $idx => $header) { if ($header->getName() == $name) unset($this->_headers[$idx]); } return $this; }
[ "function", "remove", "(", "$", "header", ")", "{", "$", "normalizer", "=", "new", "HeaderCaseNormalizer", "(", ")", ";", "$", "name", "=", "$", "normalizer", "->", "normalize", "(", "$", "header", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "idx", "=>", "$", "header", ")", "{", "if", "(", "$", "header", "->", "getName", "(", ")", "==", "$", "name", ")", "unset", "(", "$", "this", "->", "_headers", "[", "$", "idx", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a header by name @chainable
[ "Remove", "a", "header", "by", "name" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L40-L51
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.replace
function replace($header) { if (is_string($header)) $header = HeaderField::fromString($header); return $this ->remove($header->getName()) ->add($header); }
php
function replace($header) { if (is_string($header)) $header = HeaderField::fromString($header); return $this ->remove($header->getName()) ->add($header); }
[ "function", "replace", "(", "$", "header", ")", "{", "if", "(", "is_string", "(", "$", "header", ")", ")", "$", "header", "=", "HeaderField", "::", "fromString", "(", "$", "header", ")", ";", "return", "$", "this", "->", "remove", "(", "$", "header", "->", "getName", "(", ")", ")", "->", "add", "(", "$", "header", ")", ";", "}" ]
Replaces a header in the collection, either in "Header: Value" format or an {@link HeaderField} object. @chainable
[ "Replaces", "a", "header", "in", "the", "collection", "either", "in", "Header", ":", "Value", "format", "or", "an", "{" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L58-L66
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.value
function value($name, $default = false) { $values = $this->values($name); return count($values) ? $values[0] : $default; }
php
function value($name, $default = false) { $values = $this->values($name); return count($values) ? $values[0] : $default; }
[ "function", "value", "(", "$", "name", ",", "$", "default", "=", "false", ")", "{", "$", "values", "=", "$", "this", "->", "values", "(", "$", "name", ")", ";", "return", "count", "(", "$", "values", ")", "?", "$", "values", "[", "0", "]", ":", "$", "default", ";", "}" ]
Gets a single header value @return string
[ "Gets", "a", "single", "header", "value" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L72-L76
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.values
function values($name) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($name); $values = array(); foreach ($this->_headers as $header) { if ($header->getName() == $name) { $values[] = $header->getValue(); } } return $values; }
php
function values($name) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($name); $values = array(); foreach ($this->_headers as $header) { if ($header->getName() == $name) { $values[] = $header->getValue(); } } return $values; }
[ "function", "values", "(", "$", "name", ")", "{", "$", "normalizer", "=", "new", "HeaderCaseNormalizer", "(", ")", ";", "$", "name", "=", "$", "normalizer", "->", "normalize", "(", "$", "name", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "if", "(", "$", "header", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "$", "values", "[", "]", "=", "$", "header", "->", "getValue", "(", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
Gets an array of the values for a header @return array
[ "Gets", "an", "array", "of", "the", "values", "for", "a", "header" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L82-L95
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.toArray
function toArray($crlf = true) { $headers = array(); foreach ($this->_headers as $header) { $string = $header->__toString(); $headers[] = $crlf ? $string : rtrim($string); } return $headers; }
php
function toArray($crlf = true) { $headers = array(); foreach ($this->_headers as $header) { $string = $header->__toString(); $headers[] = $crlf ? $string : rtrim($string); } return $headers; }
[ "function", "toArray", "(", "$", "crlf", "=", "true", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "$", "string", "=", "$", "header", "->", "__toString", "(", ")", ";", "$", "headers", "[", "]", "=", "$", "crlf", "?", "$", "string", ":", "rtrim", "(", "$", "string", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Returns an array of the string versions of headers @return array
[ "Returns", "an", "array", "of", "the", "string", "versions", "of", "headers" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L101-L111
brick/di
src/Container.php
Container.has
public function has(string $key) : bool { if (isset($this->items[$key])) { return true; } try { $class = new \ReflectionClass($key); } catch (\ReflectionException $e) { return false; } $classes = $this->reflectionTools->getClassHierarchy($class); foreach ($classes as $class) { if ($this->injectionPolicy->isClassInjected($class)) { $this->bind($key); // @todo allow to configure scope (singleton) with annotations return true; } } return false; }
php
public function has(string $key) : bool { if (isset($this->items[$key])) { return true; } try { $class = new \ReflectionClass($key); } catch (\ReflectionException $e) { return false; } $classes = $this->reflectionTools->getClassHierarchy($class); foreach ($classes as $class) { if ($this->injectionPolicy->isClassInjected($class)) { $this->bind($key); // @todo allow to configure scope (singleton) with annotations return true; } } return false; }
[ "public", "function", "has", "(", "string", "$", "key", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "key", "]", ")", ")", "{", "return", "true", ";", "}", "try", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "key", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "return", "false", ";", "}", "$", "classes", "=", "$", "this", "->", "reflectionTools", "->", "getClassHierarchy", "(", "$", "class", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "$", "this", "->", "injectionPolicy", "->", "isClassInjected", "(", "$", "class", ")", ")", "{", "$", "this", "->", "bind", "(", "$", "key", ")", ";", "// @todo allow to configure scope (singleton) with annotations", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether the container has the given key. @param string $key The key, class or interface name. @return bool
[ "Returns", "whether", "the", "container", "has", "the", "given", "key", "." ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L94-L117
brick/di
src/Container.php
Container.get
public function get(string $key) { if (! $this->has($key)) { throw DependencyInjectionException::keyNotRegistered($key); } $value = $this->items[$key]; if ($value instanceof Definition) { return $value->get($this); } return $value; }
php
public function get(string $key) { if (! $this->has($key)) { throw DependencyInjectionException::keyNotRegistered($key); } $value = $this->items[$key]; if ($value instanceof Definition) { return $value->get($this); } return $value; }
[ "public", "function", "get", "(", "string", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "throw", "DependencyInjectionException", "::", "keyNotRegistered", "(", "$", "key", ")", ";", "}", "$", "value", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "if", "(", "$", "value", "instanceof", "Definition", ")", "{", "return", "$", "value", "->", "get", "(", "$", "this", ")", ";", "}", "return", "$", "value", ";", "}" ]
Returns the value for the given key. @param string $key The key, class or interface name. @return mixed @throws DependencyInjectionException If the key is not registered.
[ "Returns", "the", "value", "for", "the", "given", "key", "." ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L128-L141
brick/di
src/Container.php
Container.set
public function set(string $key, $value) : Container { $this->items[$key] = $value; return $this; }
php
public function set(string $key, $value) : Container { $this->items[$key] = $value; return $this; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "value", ")", ":", "Container", "{", "$", "this", "->", "items", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets a single value. The value will be returned as is when requested with get(). @param string $key The key, class or interface name. @param mixed $value The value to set. @return Container
[ "Sets", "a", "single", "value", "." ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L153-L158
brick/di
src/Container.php
Container.bind
public function bind(string $key, $target = null) : BindingDefinition { return $this->items[$key] = new BindingDefinition($target ?? $key); }
php
public function bind(string $key, $target = null) : BindingDefinition { return $this->items[$key] = new BindingDefinition($target ?? $key); }
[ "public", "function", "bind", "(", "string", "$", "key", ",", "$", "target", "=", "null", ")", ":", "BindingDefinition", "{", "return", "$", "this", "->", "items", "[", "$", "key", "]", "=", "new", "BindingDefinition", "(", "$", "target", "??", "$", "key", ")", ";", "}" ]
Binds a key to a class name to be instantiated, or to a closure to be invoked. By default, the key is bound to itself, so these two lines of code are equivalent; $container->bind('Class\Name'); $container->bind('Class\Name', 'Class\Name'); It can be used to bind an interface to a class to be instantiated: $container->bind('Interface\Name', 'Class\Name'); The key can also be bound to a closure to return any value: $container->bind('Class\Or\Interface\Name', function() { return new Class\Name(); }); If the key is an interface name, the target must be the name of a class implementing this interface, or a closure returning an instance of such class. If the key is a class name, the target must be the name of the class or one of its subclasses, or a closure returning an instance of this class. Any parameters required by the class constructor or the closure will be automatically resolved when possible using type-hinted classes or interfaces. Additional parameters can be passed as an associative array using the with() method: $container->bind('Interface\Name', 'Class\Name')->with([ 'username' => 'admin', 'password' => new Ref('config.password') ]); Fixed parameters can be provided as is, and references to container keys can be provided by wrapping the key in a `Ref` object. See `BindingDefinition::with()` for more information. Note: not use bind() to attach an existing object instance. Use set() instead. @param string $key The key, class or interface name. @param \Closure|string|null $target The class name or closure to bind. Optional if the key is the class name. @return BindingDefinition
[ "Binds", "a", "key", "to", "a", "class", "name", "to", "be", "instantiated", "or", "to", "a", "closure", "to", "be", "invoked", "." ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L219-L222
brick/di
src/Container.php
Container.alias
public function alias(string $key, string $targetKey) : AliasDefinition { return $this->items[$key] = new AliasDefinition($targetKey); }
php
public function alias(string $key, string $targetKey) : AliasDefinition { return $this->items[$key] = new AliasDefinition($targetKey); }
[ "public", "function", "alias", "(", "string", "$", "key", ",", "string", "$", "targetKey", ")", ":", "AliasDefinition", "{", "return", "$", "this", "->", "items", "[", "$", "key", "]", "=", "new", "AliasDefinition", "(", "$", "targetKey", ")", ";", "}" ]
Creates an alias from one key to another. This method can be used for use cases as simple as: $container->alias('my.alias', 'my.service'); This is particularly useful when you have already registered a class by its name, but now want to make it resolvable through an interface name it implements as well: $container->bind('Class\Name'); $container->alias('Interface\Name', 'Class\Name'); An alias always queries the current value by default, unless you change its scope, which may be used for advanced use cases, such as creating singletons out of a prototype: $container->bind('Class\Name')->in(new Scope\Prototype()); $container->alias('my.shared.instance', 'Class\Name')->in(new Scope\Singleton()); @param string $key The key, class or interface name. @param string $targetKey The target key. @return \Brick\Di\Definition\AliasDefinition
[ "Creates", "an", "alias", "from", "one", "key", "to", "another", "." ]
train
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L248-L251
php-lug/lug
src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php
DataSourceBuilder.setParameter
public function setParameter($parameter, $value, $type = null) { $this->queryBuilder->setParameter($parameter, $value, $type); return $this; }
php
public function setParameter($parameter, $value, $type = null) { $this->queryBuilder->setParameter($parameter, $value, $type); return $this; }
[ "public", "function", "setParameter", "(", "$", "parameter", ",", "$", "value", ",", "$", "type", "=", "null", ")", "{", "$", "this", "->", "queryBuilder", "->", "setParameter", "(", "$", "parameter", ",", "$", "value", ",", "$", "type", ")", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php#L148-L153
php-lug/lug
src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php
DataSourceBuilder.createPlaceholder
public function createPlaceholder($parameter, $value, $type = null) { $placeholder = str_replace('.', '_', $parameter).'_'.str_replace('.', '', uniqid(null, true)); $this->setParameter($placeholder, $value, $type); return ':'.$placeholder; }
php
public function createPlaceholder($parameter, $value, $type = null) { $placeholder = str_replace('.', '_', $parameter).'_'.str_replace('.', '', uniqid(null, true)); $this->setParameter($placeholder, $value, $type); return ':'.$placeholder; }
[ "public", "function", "createPlaceholder", "(", "$", "parameter", ",", "$", "value", ",", "$", "type", "=", "null", ")", "{", "$", "placeholder", "=", "str_replace", "(", "'.'", ",", "'_'", ",", "$", "parameter", ")", ".", "'_'", ".", "str_replace", "(", "'.'", ",", "''", ",", "uniqid", "(", "null", ",", "true", ")", ")", ";", "$", "this", "->", "setParameter", "(", "$", "placeholder", ",", "$", "value", ",", "$", "type", ")", ";", "return", "':'", ".", "$", "placeholder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php#L158-L164
php-lug/lug
src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php
DataSourceBuilder.getProperty
public function getProperty($field, $root = null) { return $this->repository->getProperty($field, $root ?: $this->queryBuilder); }
php
public function getProperty($field, $root = null) { return $this->repository->getProperty($field, $root ?: $this->queryBuilder); }
[ "public", "function", "getProperty", "(", "$", "field", ",", "$", "root", "=", "null", ")", "{", "return", "$", "this", "->", "repository", "->", "getProperty", "(", "$", "field", ",", "$", "root", "?", ":", "$", "this", "->", "queryBuilder", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php#L169-L172
php-lug/lug
src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php
DataSourceBuilder.getExpressionBuilder
public function getExpressionBuilder() { if ($this->expressionBuilder === null) { $this->expressionBuilder = new ExpressionBuilder($this->queryBuilder->expr()); } return $this->expressionBuilder; }
php
public function getExpressionBuilder() { if ($this->expressionBuilder === null) { $this->expressionBuilder = new ExpressionBuilder($this->queryBuilder->expr()); } return $this->expressionBuilder; }
[ "public", "function", "getExpressionBuilder", "(", ")", "{", "if", "(", "$", "this", "->", "expressionBuilder", "===", "null", ")", "{", "$", "this", "->", "expressionBuilder", "=", "new", "ExpressionBuilder", "(", "$", "this", "->", "queryBuilder", "->", "expr", "(", ")", ")", ";", "}", "return", "$", "this", "->", "expressionBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php#L185-L192
php-lug/lug
src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php
DataSourceBuilder.createDataSource
public function createDataSource(array $options = []) { $queryBuilder = clone $this->queryBuilder; if (isset($options['all']) && $options['all']) { return new ArrayDataSource($queryBuilder->getQuery()->getResult()); } $dataSource = new PagerfantaDataSource(new DoctrineORMAdapter( $queryBuilder, isset($options['fetch_join_collection']) ? $options['fetch_join_collection'] : true, isset($options['use_output_walkers']) ? $options['use_output_walkers'] : true )); $dataSource->setMaxPerPage($this->limit); $dataSource->setCurrentPage($this->page); return $dataSource; }
php
public function createDataSource(array $options = []) { $queryBuilder = clone $this->queryBuilder; if (isset($options['all']) && $options['all']) { return new ArrayDataSource($queryBuilder->getQuery()->getResult()); } $dataSource = new PagerfantaDataSource(new DoctrineORMAdapter( $queryBuilder, isset($options['fetch_join_collection']) ? $options['fetch_join_collection'] : true, isset($options['use_output_walkers']) ? $options['use_output_walkers'] : true )); $dataSource->setMaxPerPage($this->limit); $dataSource->setCurrentPage($this->page); return $dataSource; }
[ "public", "function", "createDataSource", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "queryBuilder", "=", "clone", "$", "this", "->", "queryBuilder", ";", "if", "(", "isset", "(", "$", "options", "[", "'all'", "]", ")", "&&", "$", "options", "[", "'all'", "]", ")", "{", "return", "new", "ArrayDataSource", "(", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ")", ";", "}", "$", "dataSource", "=", "new", "PagerfantaDataSource", "(", "new", "DoctrineORMAdapter", "(", "$", "queryBuilder", ",", "isset", "(", "$", "options", "[", "'fetch_join_collection'", "]", ")", "?", "$", "options", "[", "'fetch_join_collection'", "]", ":", "true", ",", "isset", "(", "$", "options", "[", "'use_output_walkers'", "]", ")", "?", "$", "options", "[", "'use_output_walkers'", "]", ":", "true", ")", ")", ";", "$", "dataSource", "->", "setMaxPerPage", "(", "$", "this", "->", "limit", ")", ";", "$", "dataSource", "->", "setCurrentPage", "(", "$", "this", "->", "page", ")", ";", "return", "$", "dataSource", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/DataSource/Doctrine/ORM/DataSourceBuilder.php#L197-L215
giftcards/Encryption
CipherText/Rotator/Store/StoreRegistryBuilder.php
StoreRegistryBuilder.addStoreToBuildQueue
private function addStoreToBuildQueue($storeName, $builderName, array $options) { if (!$this->factory->getRegistry()->has($builderName)) { throw new \DomainException(sprintf("Unknown builder: %s", $builderName)); } $this->buildQueue[$storeName] = array($builderName, $options); return $this; }
php
private function addStoreToBuildQueue($storeName, $builderName, array $options) { if (!$this->factory->getRegistry()->has($builderName)) { throw new \DomainException(sprintf("Unknown builder: %s", $builderName)); } $this->buildQueue[$storeName] = array($builderName, $options); return $this; }
[ "private", "function", "addStoreToBuildQueue", "(", "$", "storeName", ",", "$", "builderName", ",", "array", "$", "options", ")", "{", "if", "(", "!", "$", "this", "->", "factory", "->", "getRegistry", "(", ")", "->", "has", "(", "$", "builderName", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "sprintf", "(", "\"Unknown builder: %s\"", ",", "$", "builderName", ")", ")", ";", "}", "$", "this", "->", "buildQueue", "[", "$", "storeName", "]", "=", "array", "(", "$", "builderName", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Queues a store to be built @param string $storeName @param $builderName @param array $options @return StoreRegistryBuilder
[ "Queues", "a", "store", "to", "be", "built" ]
train
https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/CipherText/Rotator/Store/StoreRegistryBuilder.php#L90-L97
inhere/php-librarys
src/Traits/LiteConfigTrait.php
LiteConfigTrait.getValue
public function getValue($name, $default = null) { $value = array_key_exists($name, $this->config) ? $this->config[$name] : $default; if ($value && ($value instanceof \Closure)) { $value = $value(); } return $value; }
php
public function getValue($name, $default = null) { $value = array_key_exists($name, $this->config) ? $this->config[$name] : $default; if ($value && ($value instanceof \Closure)) { $value = $value(); } return $value; }
[ "public", "function", "getValue", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", ")", "?", "$", "this", "->", "config", "[", "$", "name", "]", ":", "$", "default", ";", "if", "(", "$", "value", "&&", "(", "$", "value", "instanceof", "\\", "Closure", ")", ")", "{", "$", "value", "=", "$", "value", "(", ")", ";", "}", "return", "$", "value", ";", "}" ]
Method to get property Options @param string $name @param mixed $default @return mixed
[ "Method", "to", "get", "property", "Options" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/LiteConfigTrait.php#L35-L44
atomwares/atom-view
src/Renderer.php
Renderer.removeAttribute
public function removeAttribute($name) { if (isset($this->attributes[$name])) { unset($this->attributes[$name]); } return $this; }
php
public function removeAttribute($name) { if (isset($this->attributes[$name])) { unset($this->attributes[$name]); } return $this; }
[ "public", "function", "removeAttribute", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "attributes", "[", "$", "name", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
@param string $name @return $this
[ "@param", "string", "$name" ]
train
https://github.com/atomwares/atom-view/blob/8f2c3f8ed736c5a2e7a442659e2db99a7f333fce/src/Renderer.php#L149-L156
atomwares/atom-view
src/Renderer.php
Renderer.block
public function block($name, $default = null) { return isset($this->blocks[$name]) ? $this->blocks[$name] : $default; }
php
public function block($name, $default = null) { return isset($this->blocks[$name]) ? $this->blocks[$name] : $default; }
[ "public", "function", "block", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "blocks", "[", "$", "name", "]", ")", "?", "$", "this", "->", "blocks", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
@param string $name @param string $default @return mixed|null
[ "@param", "string", "$name", "@param", "string", "$default" ]
train
https://github.com/atomwares/atom-view/blob/8f2c3f8ed736c5a2e7a442659e2db99a7f333fce/src/Renderer.php#L194-L197
atomwares/atom-view
src/Renderer.php
Renderer.render
public function render($template, array $data = []) { ob_start(); $this->requireTemplate($template, $data); while ($extend = array_pop($this->inherits)) { ob_clean(); $this->requireTemplate($extend, $data); } return ob_get_clean(); }
php
public function render($template, array $data = []) { ob_start(); $this->requireTemplate($template, $data); while ($extend = array_pop($this->inherits)) { ob_clean(); $this->requireTemplate($extend, $data); } return ob_get_clean(); }
[ "public", "function", "render", "(", "$", "template", ",", "array", "$", "data", "=", "[", "]", ")", "{", "ob_start", "(", ")", ";", "$", "this", "->", "requireTemplate", "(", "$", "template", ",", "$", "data", ")", ";", "while", "(", "$", "extend", "=", "array_pop", "(", "$", "this", "->", "inherits", ")", ")", "{", "ob_clean", "(", ")", ";", "$", "this", "->", "requireTemplate", "(", "$", "extend", ",", "$", "data", ")", ";", "}", "return", "ob_get_clean", "(", ")", ";", "}" ]
@param string $template @param array $data @return string
[ "@param", "string", "$template", "@param", "array", "$data" ]
train
https://github.com/atomwares/atom-view/blob/8f2c3f8ed736c5a2e7a442659e2db99a7f333fce/src/Renderer.php#L205-L216
alevilar/ristorantino-vendor
Comanda/Controller/DetalleComandasController.php
DetalleComandasController.index
public function index() { $this->layout = 'Stats.default'; $this->elementMenu = 'Stats.menu'; // por default ordenar por sumatoria de dinero vendido $conditions['order'] = array('ventas DESC',"cant DESC"); if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) { // ordenado por cantidad de unidades vendidas $conditions['order'] = array("cant DESC", 'ventas DESC'); } $this->Prg->commonProcess(); $conds = $this->DetalleComanda->parseCriteria( $this->Prg->parsedParams() ); $conditions['conditions'] = $conds; $conditions['conditions']['Mesa.deleted'] = 0; $this->DetalleComanda->Producto->recursive = -1; $conditions['group'] = array('Producto.id', 'Producto.name'); $conditions['joins'] = array( array( 'table' => 'detalle_comandas', 'alias' => 'DetalleComanda', 'type' => 'left', 'conditions' => 'Producto.id = DetalleComanda.producto_id', ), array( 'table' => 'comandas', 'alias' => 'Comanda', 'type' => 'left', 'conditions' => 'Comanda.id = DetalleComanda.comanda_id', ), array( 'table' => 'mesas', 'alias' => 'Mesa', 'type' => 'left', 'conditions' => 'Mesa.id = Comanda.mesa_id', ), ); $conditions['fields'] = array( 'Producto.name', 'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada)*Producto.precio as "ventas"', 'Producto.precio', 'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada) as "cant"', ); if ( empty($this->request->query['desde']) ) { $desde = $this->DetalleComanda->find('first', array( 'order' => array('DetalleComanda.created' => 'ASC') )); $desde = $desde['DetalleComanda']['created']; } else { $desde = $this->request->query['desde']; } if ( empty($this->request->query['hasta']) ) { $hasta = $this->DetalleComanda->find('first', array( 'order' => array('DetalleComanda.created' => 'DESC') )); $hasta = $hasta['DetalleComanda']['created']; } else { $hasta = $this->request->query['hasta']; } $comandas = $this->DetalleComanda->Producto->find('all', $conditions); $cantTotal = 0; $ventasTotal = 0; foreach ($comandas as $c) { $cantTotal += $c[0]['cant']; $ventasTotal += $c[0]['ventas']; } if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) { $this->request->data['DetalleComanda']['cant_o_tot'] = 1; } $this->set('categorias', $this->DetalleComanda->Producto->Categoria->generateTreeList()); $this->set('productos', $this->DetalleComanda->Producto->find('list', array('order' => 'name'))); $this->set('tags', $this->DetalleComanda->Producto->Tag->find('list', array('order' => 'name'))); $this->set(compact('comandas', 'cantTotal', 'ventasTotal','tags', 'desde', 'hasta')); }
php
public function index() { $this->layout = 'Stats.default'; $this->elementMenu = 'Stats.menu'; // por default ordenar por sumatoria de dinero vendido $conditions['order'] = array('ventas DESC',"cant DESC"); if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) { // ordenado por cantidad de unidades vendidas $conditions['order'] = array("cant DESC", 'ventas DESC'); } $this->Prg->commonProcess(); $conds = $this->DetalleComanda->parseCriteria( $this->Prg->parsedParams() ); $conditions['conditions'] = $conds; $conditions['conditions']['Mesa.deleted'] = 0; $this->DetalleComanda->Producto->recursive = -1; $conditions['group'] = array('Producto.id', 'Producto.name'); $conditions['joins'] = array( array( 'table' => 'detalle_comandas', 'alias' => 'DetalleComanda', 'type' => 'left', 'conditions' => 'Producto.id = DetalleComanda.producto_id', ), array( 'table' => 'comandas', 'alias' => 'Comanda', 'type' => 'left', 'conditions' => 'Comanda.id = DetalleComanda.comanda_id', ), array( 'table' => 'mesas', 'alias' => 'Mesa', 'type' => 'left', 'conditions' => 'Mesa.id = Comanda.mesa_id', ), ); $conditions['fields'] = array( 'Producto.name', 'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada)*Producto.precio as "ventas"', 'Producto.precio', 'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada) as "cant"', ); if ( empty($this->request->query['desde']) ) { $desde = $this->DetalleComanda->find('first', array( 'order' => array('DetalleComanda.created' => 'ASC') )); $desde = $desde['DetalleComanda']['created']; } else { $desde = $this->request->query['desde']; } if ( empty($this->request->query['hasta']) ) { $hasta = $this->DetalleComanda->find('first', array( 'order' => array('DetalleComanda.created' => 'DESC') )); $hasta = $hasta['DetalleComanda']['created']; } else { $hasta = $this->request->query['hasta']; } $comandas = $this->DetalleComanda->Producto->find('all', $conditions); $cantTotal = 0; $ventasTotal = 0; foreach ($comandas as $c) { $cantTotal += $c[0]['cant']; $ventasTotal += $c[0]['ventas']; } if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) { $this->request->data['DetalleComanda']['cant_o_tot'] = 1; } $this->set('categorias', $this->DetalleComanda->Producto->Categoria->generateTreeList()); $this->set('productos', $this->DetalleComanda->Producto->find('list', array('order' => 'name'))); $this->set('tags', $this->DetalleComanda->Producto->Tag->find('list', array('order' => 'name'))); $this->set(compact('comandas', 'cantTotal', 'ventasTotal','tags', 'desde', 'hasta')); }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "layout", "=", "'Stats.default'", ";", "$", "this", "->", "elementMenu", "=", "'Stats.menu'", ";", "// por default ordenar por sumatoria de dinero vendido", "$", "conditions", "[", "'order'", "]", "=", "array", "(", "'ventas DESC'", ",", "\"cant DESC\"", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "query", ")", "&&", "$", "this", "->", "request", "->", "query", "[", "'cant_o_tot'", "]", "==", "1", ")", "{", "// ordenado por cantidad de unidades vendidas ", "$", "conditions", "[", "'order'", "]", "=", "array", "(", "\"cant DESC\"", ",", "'ventas DESC'", ")", ";", "}", "$", "this", "->", "Prg", "->", "commonProcess", "(", ")", ";", "$", "conds", "=", "$", "this", "->", "DetalleComanda", "->", "parseCriteria", "(", "$", "this", "->", "Prg", "->", "parsedParams", "(", ")", ")", ";", "$", "conditions", "[", "'conditions'", "]", "=", "$", "conds", ";", "$", "conditions", "[", "'conditions'", "]", "[", "'Mesa.deleted'", "]", "=", "0", ";", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "recursive", "=", "-", "1", ";", "$", "conditions", "[", "'group'", "]", "=", "array", "(", "'Producto.id'", ",", "'Producto.name'", ")", ";", "$", "conditions", "[", "'joins'", "]", "=", "array", "(", "array", "(", "'table'", "=>", "'detalle_comandas'", ",", "'alias'", "=>", "'DetalleComanda'", ",", "'type'", "=>", "'left'", ",", "'conditions'", "=>", "'Producto.id = DetalleComanda.producto_id'", ",", ")", ",", "array", "(", "'table'", "=>", "'comandas'", ",", "'alias'", "=>", "'Comanda'", ",", "'type'", "=>", "'left'", ",", "'conditions'", "=>", "'Comanda.id = DetalleComanda.comanda_id'", ",", ")", ",", "array", "(", "'table'", "=>", "'mesas'", ",", "'alias'", "=>", "'Mesa'", ",", "'type'", "=>", "'left'", ",", "'conditions'", "=>", "'Mesa.id = Comanda.mesa_id'", ",", ")", ",", ")", ";", "$", "conditions", "[", "'fields'", "]", "=", "array", "(", "'Producto.name'", ",", "'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada)*Producto.precio as \"ventas\"'", ",", "'Producto.precio'", ",", "'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada) as \"cant\"'", ",", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "request", "->", "query", "[", "'desde'", "]", ")", ")", "{", "$", "desde", "=", "$", "this", "->", "DetalleComanda", "->", "find", "(", "'first'", ",", "array", "(", "'order'", "=>", "array", "(", "'DetalleComanda.created'", "=>", "'ASC'", ")", ")", ")", ";", "$", "desde", "=", "$", "desde", "[", "'DetalleComanda'", "]", "[", "'created'", "]", ";", "}", "else", "{", "$", "desde", "=", "$", "this", "->", "request", "->", "query", "[", "'desde'", "]", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "request", "->", "query", "[", "'hasta'", "]", ")", ")", "{", "$", "hasta", "=", "$", "this", "->", "DetalleComanda", "->", "find", "(", "'first'", ",", "array", "(", "'order'", "=>", "array", "(", "'DetalleComanda.created'", "=>", "'DESC'", ")", ")", ")", ";", "$", "hasta", "=", "$", "hasta", "[", "'DetalleComanda'", "]", "[", "'created'", "]", ";", "}", "else", "{", "$", "hasta", "=", "$", "this", "->", "request", "->", "query", "[", "'hasta'", "]", ";", "}", "$", "comandas", "=", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "find", "(", "'all'", ",", "$", "conditions", ")", ";", "$", "cantTotal", "=", "0", ";", "$", "ventasTotal", "=", "0", ";", "foreach", "(", "$", "comandas", "as", "$", "c", ")", "{", "$", "cantTotal", "+=", "$", "c", "[", "0", "]", "[", "'cant'", "]", ";", "$", "ventasTotal", "+=", "$", "c", "[", "0", "]", "[", "'ventas'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "request", "->", "query", ")", "&&", "$", "this", "->", "request", "->", "query", "[", "'cant_o_tot'", "]", "==", "1", ")", "{", "$", "this", "->", "request", "->", "data", "[", "'DetalleComanda'", "]", "[", "'cant_o_tot'", "]", "=", "1", ";", "}", "$", "this", "->", "set", "(", "'categorias'", ",", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "Categoria", "->", "generateTreeList", "(", ")", ")", ";", "$", "this", "->", "set", "(", "'productos'", ",", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "find", "(", "'list'", ",", "array", "(", "'order'", "=>", "'name'", ")", ")", ")", ";", "$", "this", "->", "set", "(", "'tags'", ",", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "Tag", "->", "find", "(", "'list'", ",", "array", "(", "'order'", "=>", "'name'", ")", ")", ")", ";", "$", "this", "->", "set", "(", "compact", "(", "'comandas'", ",", "'cantTotal'", ",", "'ventasTotal'", ",", "'tags'", ",", "'desde'", ",", "'hasta'", ")", ")", ";", "}" ]
Listado de los productos mas Vendidos csegun regla de Paretto
[ "Listado", "de", "los", "productos", "mas", "Vendidos", "csegun", "regla", "de", "Paretto" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Comanda/Controller/DetalleComandasController.php#L18-L102
alevilar/ristorantino-vendor
Comanda/Controller/DetalleComandasController.php
DetalleComandasController.add
public function add ( $mesa_id = null ) { if ( $this->request->is(array('post', 'put') ) ) { if ( $this->DetalleComanda->Comanda->saveComanda( $this->request->data ) ) { $this->Session->setFlash('Se guardó correctamente', 'Risto.flash_success'); } else { $this->Session->setFlash('No se guardó correctamente', 'Risto.flash_error'); } if ( $this->request->is('ajax') ) { } else { $this->redirect($this->request->data['Comanda']['redirect']); } } $productos = $this->DetalleComanda->Producto->find('list'); $mesas = $this->DetalleComanda->Comanda->Mesa->find('list', array( 'fields' => array('id','numero'), 'conditions' => array("Mesa.estado_id" => MESA_ABIERTA), )); $this->set(compact('productos', 'mesas', 'mesa_id')); $this->DetalleComanda->Comanda->contain(array('DetalleComanda' => array('DetalleSabor.Sabor','Producto'))); $this->set('comanda', $this->DetalleComanda->Comanda->read()); }
php
public function add ( $mesa_id = null ) { if ( $this->request->is(array('post', 'put') ) ) { if ( $this->DetalleComanda->Comanda->saveComanda( $this->request->data ) ) { $this->Session->setFlash('Se guardó correctamente', 'Risto.flash_success'); } else { $this->Session->setFlash('No se guardó correctamente', 'Risto.flash_error'); } if ( $this->request->is('ajax') ) { } else { $this->redirect($this->request->data['Comanda']['redirect']); } } $productos = $this->DetalleComanda->Producto->find('list'); $mesas = $this->DetalleComanda->Comanda->Mesa->find('list', array( 'fields' => array('id','numero'), 'conditions' => array("Mesa.estado_id" => MESA_ABIERTA), )); $this->set(compact('productos', 'mesas', 'mesa_id')); $this->DetalleComanda->Comanda->contain(array('DetalleComanda' => array('DetalleSabor.Sabor','Producto'))); $this->set('comanda', $this->DetalleComanda->Comanda->read()); }
[ "public", "function", "add", "(", "$", "mesa_id", "=", "null", ")", "{", "if", "(", "$", "this", "->", "request", "->", "is", "(", "array", "(", "'post'", ",", "'put'", ")", ")", ")", "{", "if", "(", "$", "this", "->", "DetalleComanda", "->", "Comanda", "->", "saveComanda", "(", "$", "this", "->", "request", "->", "data", ")", ")", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "'Se guardó correctamente',", " ", "Risto.flash_success')", ";", "", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "'No se guardó correctamente',", " ", "Risto.flash_error')", ";", "", "}", "if", "(", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", ")", "{", "}", "else", "{", "$", "this", "->", "redirect", "(", "$", "this", "->", "request", "->", "data", "[", "'Comanda'", "]", "[", "'redirect'", "]", ")", ";", "}", "}", "$", "productos", "=", "$", "this", "->", "DetalleComanda", "->", "Producto", "->", "find", "(", "'list'", ")", ";", "$", "mesas", "=", "$", "this", "->", "DetalleComanda", "->", "Comanda", "->", "Mesa", "->", "find", "(", "'list'", ",", "array", "(", "'fields'", "=>", "array", "(", "'id'", ",", "'numero'", ")", ",", "'conditions'", "=>", "array", "(", "\"Mesa.estado_id\"", "=>", "MESA_ABIERTA", ")", ",", ")", ")", ";", "$", "this", "->", "set", "(", "compact", "(", "'productos'", ",", "'mesas'", ",", "'mesa_id'", ")", ")", ";", "$", "this", "->", "DetalleComanda", "->", "Comanda", "->", "contain", "(", "array", "(", "'DetalleComanda'", "=>", "array", "(", "'DetalleSabor.Sabor'", ",", "'Producto'", ")", ")", ")", ";", "$", "this", "->", "set", "(", "'comanda'", ",", "$", "this", "->", "DetalleComanda", "->", "Comanda", "->", "read", "(", ")", ")", ";", "}" ]
}
[ "}" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Comanda/Controller/DetalleComandasController.php#L125-L152
jakubkratina/larachartie
src/DataTable/Factory/ColumnsFactory.php
ColumnsFactory.create
public static function create($type, $label = '') { if (Type::exists($type) === false) { throw new InvalidColumnTypeException($type); } return new Column($type, $label); }
php
public static function create($type, $label = '') { if (Type::exists($type) === false) { throw new InvalidColumnTypeException($type); } return new Column($type, $label); }
[ "public", "static", "function", "create", "(", "$", "type", ",", "$", "label", "=", "''", ")", "{", "if", "(", "Type", "::", "exists", "(", "$", "type", ")", "===", "false", ")", "{", "throw", "new", "InvalidColumnTypeException", "(", "$", "type", ")", ";", "}", "return", "new", "Column", "(", "$", "type", ",", "$", "label", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/jakubkratina/larachartie/blob/96c535650d61a2a6c1c1b12d374e5e59d33239f6/src/DataTable/Factory/ColumnsFactory.php#L18-L25
j-d/draggy
src/Draggy/Loader.php
Loader.checkMandatoryAttributes
private function checkMandatoryAttributes($where, array $xmlSection, array $requirements) { foreach ($requirements as $requirement) { if (!isset( $xmlSection[$requirement] )) { throw new InvalidFileException( 'Could not find the attribute \'' . $requirement . '\' on the ' . $where . ' section of the saved file.' ); } } }
php
private function checkMandatoryAttributes($where, array $xmlSection, array $requirements) { foreach ($requirements as $requirement) { if (!isset( $xmlSection[$requirement] )) { throw new InvalidFileException( 'Could not find the attribute \'' . $requirement . '\' on the ' . $where . ' section of the saved file.' ); } } }
[ "private", "function", "checkMandatoryAttributes", "(", "$", "where", ",", "array", "$", "xmlSection", ",", "array", "$", "requirements", ")", "{", "foreach", "(", "$", "requirements", "as", "$", "requirement", ")", "{", "if", "(", "!", "isset", "(", "$", "xmlSection", "[", "$", "requirement", "]", ")", ")", "{", "throw", "new", "InvalidFileException", "(", "'Could not find the attribute \\''", ".", "$", "requirement", ".", "'\\' on the '", ".", "$", "where", ".", "' section of the saved file.'", ")", ";", "}", "}", "}" ]
@param string $where @param array $xmlSection @param array $requirements @throws Exceptions\InvalidFileException
[ "@param", "string", "$where", "@param", "array", "$xmlSection", "@param", "array", "$requirements" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L77-L84
j-d/draggy
src/Draggy/Loader.php
Loader.getProjectProperties
private function getProjectProperties() { $r = ''; $projectOptions = (array)$this->xml->xpath('/draggy/project'); $projectOptions = (array)$projectOptions[0]; $this->checkMandatoryAttributes('Project', $projectOptions, ['language', 'description', 'orm', 'framework']); $r .= 'Draggy.prototype.setLanguage(\'' . $projectOptions['language'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setDescription(\'' . str_replace('\'', '\\\'', $projectOptions['description']) . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setORM(\'' . $projectOptions['orm'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setFramework(\'' . $projectOptions['framework'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.updateConfiguration();' . PHP_EOL; return $r; }
php
private function getProjectProperties() { $r = ''; $projectOptions = (array)$this->xml->xpath('/draggy/project'); $projectOptions = (array)$projectOptions[0]; $this->checkMandatoryAttributes('Project', $projectOptions, ['language', 'description', 'orm', 'framework']); $r .= 'Draggy.prototype.setLanguage(\'' . $projectOptions['language'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setDescription(\'' . str_replace('\'', '\\\'', $projectOptions['description']) . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setORM(\'' . $projectOptions['orm'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.setFramework(\'' . $projectOptions['framework'] . '\');' . PHP_EOL; $r .= 'Draggy.prototype.updateConfiguration();' . PHP_EOL; return $r; }
[ "private", "function", "getProjectProperties", "(", ")", "{", "$", "r", "=", "''", ";", "$", "projectOptions", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/project'", ")", ";", "$", "projectOptions", "=", "(", "array", ")", "$", "projectOptions", "[", "0", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Project'", ",", "$", "projectOptions", ",", "[", "'language'", ",", "'description'", ",", "'orm'", ",", "'framework'", "]", ")", ";", "$", "r", ".=", "'Draggy.prototype.setLanguage(\\''", ".", "$", "projectOptions", "[", "'language'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'Draggy.prototype.setDescription(\\''", ".", "str_replace", "(", "'\\''", ",", "'\\\\\\''", ",", "$", "projectOptions", "[", "'description'", "]", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'Draggy.prototype.setORM(\\''", ".", "$", "projectOptions", "[", "'orm'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'Draggy.prototype.setFramework(\\''", ".", "$", "projectOptions", "[", "'framework'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'Draggy.prototype.updateConfiguration();'", ".", "PHP_EOL", ";", "return", "$", "r", ";", "}" ]
Get the project properties from the saved file @return string
[ "Get", "the", "project", "properties", "from", "the", "saved", "file" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L91-L107
j-d/draggy
src/Draggy/Loader.php
Loader.getAutocodeProperties
private function getAutocodeProperties() { $r = ''; $autocode = (array)$this->xml->xpath('/draggy/autocode'); $autocode = (array)$autocode[0]; $autocodeProperties = (array)$autocode['properties']; $autocodeConfigurations = (array)$autocode['configurations']; $autocodeTemplates = (array)$autocode['templates']; foreach ($autocodeProperties as $propertyName => $propertyValue) { $r .= 'Autocode.prototype.setProperty(\'' . $propertyName . '\', true === ' . $propertyValue . ');' . PHP_EOL; } foreach ($autocodeConfigurations as $configurationName => $configurationValue) { $r .= 'Autocode.prototype.setConfiguration(\'' . $configurationName . '\', \'' . str_replace('\\', '\\\\', $configurationValue) . '\');' . PHP_EOL; } foreach ($autocodeTemplates as $templateName => $templateValue) { $r .= 'Autocode.prototype.setTemplate(\'' . $templateName . '\', "' . str_replace('\\', '\\\\', $templateValue) . '");' . PHP_EOL; } return $r; }
php
private function getAutocodeProperties() { $r = ''; $autocode = (array)$this->xml->xpath('/draggy/autocode'); $autocode = (array)$autocode[0]; $autocodeProperties = (array)$autocode['properties']; $autocodeConfigurations = (array)$autocode['configurations']; $autocodeTemplates = (array)$autocode['templates']; foreach ($autocodeProperties as $propertyName => $propertyValue) { $r .= 'Autocode.prototype.setProperty(\'' . $propertyName . '\', true === ' . $propertyValue . ');' . PHP_EOL; } foreach ($autocodeConfigurations as $configurationName => $configurationValue) { $r .= 'Autocode.prototype.setConfiguration(\'' . $configurationName . '\', \'' . str_replace('\\', '\\\\', $configurationValue) . '\');' . PHP_EOL; } foreach ($autocodeTemplates as $templateName => $templateValue) { $r .= 'Autocode.prototype.setTemplate(\'' . $templateName . '\', "' . str_replace('\\', '\\\\', $templateValue) . '");' . PHP_EOL; } return $r; }
[ "private", "function", "getAutocodeProperties", "(", ")", "{", "$", "r", "=", "''", ";", "$", "autocode", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/autocode'", ")", ";", "$", "autocode", "=", "(", "array", ")", "$", "autocode", "[", "0", "]", ";", "$", "autocodeProperties", "=", "(", "array", ")", "$", "autocode", "[", "'properties'", "]", ";", "$", "autocodeConfigurations", "=", "(", "array", ")", "$", "autocode", "[", "'configurations'", "]", ";", "$", "autocodeTemplates", "=", "(", "array", ")", "$", "autocode", "[", "'templates'", "]", ";", "foreach", "(", "$", "autocodeProperties", "as", "$", "propertyName", "=>", "$", "propertyValue", ")", "{", "$", "r", ".=", "'Autocode.prototype.setProperty(\\''", ".", "$", "propertyName", ".", "'\\', true === '", ".", "$", "propertyValue", ".", "');'", ".", "PHP_EOL", ";", "}", "foreach", "(", "$", "autocodeConfigurations", "as", "$", "configurationName", "=>", "$", "configurationValue", ")", "{", "$", "r", ".=", "'Autocode.prototype.setConfiguration(\\''", ".", "$", "configurationName", ".", "'\\', \\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "configurationValue", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "foreach", "(", "$", "autocodeTemplates", "as", "$", "templateName", "=>", "$", "templateValue", ")", "{", "$", "r", ".=", "'Autocode.prototype.setTemplate(\\''", ".", "$", "templateName", ".", "'\\', \"'", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "templateValue", ")", ".", "'\");'", ".", "PHP_EOL", ";", "}", "return", "$", "r", ";", "}" ]
Get the project autocode properties from the saved file @return string
[ "Get", "the", "project", "autocode", "properties", "from", "the", "saved", "file" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L114-L138
j-d/draggy
src/Draggy/Loader.php
Loader.getModules
private function getModules() { $modules = (array)$this->xml->xpath('/draggy/module'); $r = ''; foreach ($modules as $module) { $moduleAttributes = (array)$module; $moduleAttributes = (array)$moduleAttributes['@attributes']; $this->checkMandatoryAttributes('Modules', $moduleAttributes, ['name', 'left', 'top', 'width', 'height']); $moduleName = $moduleAttributes['name']; $r .= 'var o = new Container(\'' . str_replace('\\', '\\\\', $moduleName) . '\');' . PHP_EOL; $r .= 'o.moveTo(\'' . ( $moduleAttributes['left'] - 1 ) . 'px\',\'' . ( $moduleAttributes['top'] - 1 ) . 'px\',\'' . $moduleAttributes['width'] . 'px\',\'' . $moduleAttributes['height'] . 'px\')' . PHP_EOL; $this->modules[] = $moduleName; $this->insideClasses[$moduleName] = []; $this->insideAbstracts[$moduleName] = []; } return $r; }
php
private function getModules() { $modules = (array)$this->xml->xpath('/draggy/module'); $r = ''; foreach ($modules as $module) { $moduleAttributes = (array)$module; $moduleAttributes = (array)$moduleAttributes['@attributes']; $this->checkMandatoryAttributes('Modules', $moduleAttributes, ['name', 'left', 'top', 'width', 'height']); $moduleName = $moduleAttributes['name']; $r .= 'var o = new Container(\'' . str_replace('\\', '\\\\', $moduleName) . '\');' . PHP_EOL; $r .= 'o.moveTo(\'' . ( $moduleAttributes['left'] - 1 ) . 'px\',\'' . ( $moduleAttributes['top'] - 1 ) . 'px\',\'' . $moduleAttributes['width'] . 'px\',\'' . $moduleAttributes['height'] . 'px\')' . PHP_EOL; $this->modules[] = $moduleName; $this->insideClasses[$moduleName] = []; $this->insideAbstracts[$moduleName] = []; } return $r; }
[ "private", "function", "getModules", "(", ")", "{", "$", "modules", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module'", ")", ";", "$", "r", "=", "''", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "$", "moduleAttributes", "=", "(", "array", ")", "$", "module", ";", "$", "moduleAttributes", "=", "(", "array", ")", "$", "moduleAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Modules'", ",", "$", "moduleAttributes", ",", "[", "'name'", ",", "'left'", ",", "'top'", ",", "'width'", ",", "'height'", "]", ")", ";", "$", "moduleName", "=", "$", "moduleAttributes", "[", "'name'", "]", ";", "$", "r", ".=", "'var o = new Container(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "moduleName", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'o.moveTo(\\''", ".", "(", "$", "moduleAttributes", "[", "'left'", "]", "-", "1", ")", ".", "'px\\',\\''", ".", "(", "$", "moduleAttributes", "[", "'top'", "]", "-", "1", ")", ".", "'px\\',\\''", ".", "$", "moduleAttributes", "[", "'width'", "]", ".", "'px\\',\\''", ".", "$", "moduleAttributes", "[", "'height'", "]", ".", "'px\\')'", ".", "PHP_EOL", ";", "$", "this", "->", "modules", "[", "]", "=", "$", "moduleName", ";", "$", "this", "->", "insideClasses", "[", "$", "moduleName", "]", "=", "[", "]", ";", "$", "this", "->", "insideAbstracts", "[", "$", "moduleName", "]", "=", "[", "]", ";", "}", "return", "$", "r", ";", "}" ]
Get the project modules @return string
[ "Get", "the", "project", "modules" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L145-L168
j-d/draggy
src/Draggy/Loader.php
Loader.getClassLikeProperties
private function getClassLikeProperties($classLikeAttributes, $varName) { $r = ''; if (isset( $classLikeAttributes['description'] )) { $r .= $varName . '.setDescription("' . str_replace('\'', '\\\'', $classLikeAttributes['description']) . '");' . PHP_EOL; } if (isset( $classLikeAttributes['constructor'] )) { $r .= $varName . '.setConstructor(' . $classLikeAttributes['constructor'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['repository'] )) { $r .= $varName . '.setRepository(' . $classLikeAttributes['repository'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['form'] )) { $r .= $varName . '.setForm(' . $classLikeAttributes['form'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['controller'] )) { $r .= $varName . '.setController(' . $classLikeAttributes['controller'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['fixtures'] )) { $r .= $varName . '.setFixtures(' . $classLikeAttributes['fixtures'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['crud'] )) { $r .= $varName . '.setCrud(\'' . $classLikeAttributes['crud'] . '\');' . PHP_EOL; } if (isset( $classLikeAttributes['routes'] )) { $r .= $varName . '.setRoutes(' . $classLikeAttributes['routes'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['arrayAccess'] )) { $r .= $varName . '.setArrayAccess(' . $classLikeAttributes['arrayAccess'] . ');' . PHP_EOL; } return $r; }
php
private function getClassLikeProperties($classLikeAttributes, $varName) { $r = ''; if (isset( $classLikeAttributes['description'] )) { $r .= $varName . '.setDescription("' . str_replace('\'', '\\\'', $classLikeAttributes['description']) . '");' . PHP_EOL; } if (isset( $classLikeAttributes['constructor'] )) { $r .= $varName . '.setConstructor(' . $classLikeAttributes['constructor'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['repository'] )) { $r .= $varName . '.setRepository(' . $classLikeAttributes['repository'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['form'] )) { $r .= $varName . '.setForm(' . $classLikeAttributes['form'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['controller'] )) { $r .= $varName . '.setController(' . $classLikeAttributes['controller'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['fixtures'] )) { $r .= $varName . '.setFixtures(' . $classLikeAttributes['fixtures'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['crud'] )) { $r .= $varName . '.setCrud(\'' . $classLikeAttributes['crud'] . '\');' . PHP_EOL; } if (isset( $classLikeAttributes['routes'] )) { $r .= $varName . '.setRoutes(' . $classLikeAttributes['routes'] . ');' . PHP_EOL; } if (isset( $classLikeAttributes['arrayAccess'] )) { $r .= $varName . '.setArrayAccess(' . $classLikeAttributes['arrayAccess'] . ');' . PHP_EOL; } return $r; }
[ "private", "function", "getClassLikeProperties", "(", "$", "classLikeAttributes", ",", "$", "varName", ")", "{", "$", "r", "=", "''", ";", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'description'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setDescription(\"'", ".", "str_replace", "(", "'\\''", ",", "'\\\\\\''", ",", "$", "classLikeAttributes", "[", "'description'", "]", ")", ".", "'\");'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'constructor'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setConstructor('", ".", "$", "classLikeAttributes", "[", "'constructor'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'repository'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setRepository('", ".", "$", "classLikeAttributes", "[", "'repository'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'form'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setForm('", ".", "$", "classLikeAttributes", "[", "'form'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'controller'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setController('", ".", "$", "classLikeAttributes", "[", "'controller'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'fixtures'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setFixtures('", ".", "$", "classLikeAttributes", "[", "'fixtures'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'crud'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setCrud(\\''", ".", "$", "classLikeAttributes", "[", "'crud'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'routes'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setRoutes('", ".", "$", "classLikeAttributes", "[", "'routes'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "classLikeAttributes", "[", "'arrayAccess'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setArrayAccess('", ".", "$", "classLikeAttributes", "[", "'arrayAccess'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "return", "$", "r", ";", "}" ]
@param array $classLikeAttributes @param string $varName @return string
[ "@param", "array", "$classLikeAttributes", "@param", "string", "$varName" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L176-L217
j-d/draggy
src/Draggy/Loader.php
Loader.getClasses
private function getClasses() { $r = ''; // Inside classes foreach ($this->modules as $module) { $classes = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/class'); foreach ($classes as $class) { $classAttributes = (array)$class; $classAttributes = (array)$classAttributes['@attributes']; $this->checkMandatoryAttributes('Class in module ' . $module, $classAttributes, ['name']); $className = $classAttributes['name']; $this->insideClasses[$module][] = $className; $this->checkMandatoryAttributes( 'Class ' . $className . ' in module ' . $module, $classAttributes, ['left', 'top'] ); $r .= 'var c = new Class(\'' . $classAttributes['name'] . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 'c.moveTo(\'' . ( $classAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $classAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($classAttributes, 'c'); $r .= 'c.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside classes $classes = (array)$this->xml->xpath('/draggy/loose/class'); foreach ($classes as $class) { $classAttributes = (array)$class; $classAttributes = $classAttributes['@attributes']; $this->checkMandatoryAttributes('Loose class', $classAttributes, ['name']); $className = $classAttributes['name']; $this->outsideClasses[] = $className; $this->checkMandatoryAttributes('Loose class ' . $className, $classAttributes, ['left', 'top']); $r .= 'var c = new Class(\'' . $className . '\');' . PHP_EOL; $r .= 'c.moveTo(\'' . ( $classAttributes['left'] ) . 'px\',\'' . ( $classAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($classAttributes, 'c'); } return $r; }
php
private function getClasses() { $r = ''; // Inside classes foreach ($this->modules as $module) { $classes = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/class'); foreach ($classes as $class) { $classAttributes = (array)$class; $classAttributes = (array)$classAttributes['@attributes']; $this->checkMandatoryAttributes('Class in module ' . $module, $classAttributes, ['name']); $className = $classAttributes['name']; $this->insideClasses[$module][] = $className; $this->checkMandatoryAttributes( 'Class ' . $className . ' in module ' . $module, $classAttributes, ['left', 'top'] ); $r .= 'var c = new Class(\'' . $classAttributes['name'] . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 'c.moveTo(\'' . ( $classAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $classAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($classAttributes, 'c'); $r .= 'c.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside classes $classes = (array)$this->xml->xpath('/draggy/loose/class'); foreach ($classes as $class) { $classAttributes = (array)$class; $classAttributes = $classAttributes['@attributes']; $this->checkMandatoryAttributes('Loose class', $classAttributes, ['name']); $className = $classAttributes['name']; $this->outsideClasses[] = $className; $this->checkMandatoryAttributes('Loose class ' . $className, $classAttributes, ['left', 'top']); $r .= 'var c = new Class(\'' . $className . '\');' . PHP_EOL; $r .= 'c.moveTo(\'' . ( $classAttributes['left'] ) . 'px\',\'' . ( $classAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($classAttributes, 'c'); } return $r; }
[ "private", "function", "getClasses", "(", ")", "{", "$", "r", "=", "''", ";", "// Inside classes", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "classes", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module[@name=\\''", ".", "$", "module", ".", "'\\']/class'", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "classAttributes", "=", "(", "array", ")", "$", "class", ";", "$", "classAttributes", "=", "(", "array", ")", "$", "classAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Class in module '", ".", "$", "module", ",", "$", "classAttributes", ",", "[", "'name'", "]", ")", ";", "$", "className", "=", "$", "classAttributes", "[", "'name'", "]", ";", "$", "this", "->", "insideClasses", "[", "$", "module", "]", "[", "]", "=", "$", "className", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Class '", ".", "$", "className", ".", "' in module '", ".", "$", "module", ",", "$", "classAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var c = new Class(\\''", ".", "$", "classAttributes", "[", "'name'", "]", ".", "'\\',\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'c.moveTo(\\''", ".", "(", "$", "classAttributes", "[", "'left'", "]", "/*- 1*/", ")", ".", "'px\\',\\''", ".", "(", "$", "classAttributes", "[", "'top'", "]", "/*- 1*/", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeProperties", "(", "$", "classAttributes", ",", "'c'", ")", ";", "$", "r", ".=", "'c.setModule(Container.prototype.getContainerByName(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\').getId());'", ".", "PHP_EOL", ";", "}", "}", "// Outside classes", "$", "classes", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/loose/class'", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "classAttributes", "=", "(", "array", ")", "$", "class", ";", "$", "classAttributes", "=", "$", "classAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose class'", ",", "$", "classAttributes", ",", "[", "'name'", "]", ")", ";", "$", "className", "=", "$", "classAttributes", "[", "'name'", "]", ";", "$", "this", "->", "outsideClasses", "[", "]", "=", "$", "className", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose class '", ".", "$", "className", ",", "$", "classAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var c = new Class(\\''", ".", "$", "className", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'c.moveTo(\\''", ".", "(", "$", "classAttributes", "[", "'left'", "]", ")", ".", "'px\\',\\''", ".", "(", "$", "classAttributes", "[", "'top'", "]", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeProperties", "(", "$", "classAttributes", ",", "'c'", ")", ";", "}", "return", "$", "r", ";", "}" ]
Get the project classes @return string
[ "Get", "the", "project", "classes" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L224-L287
j-d/draggy
src/Draggy/Loader.php
Loader.getAbstracts
private function getAbstracts() { $r = ''; // Inside abstracts foreach ($this->modules as $module) { $abstracts = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/abstract'); foreach ($abstracts as $abstract) { $abstractAttributes = (array)$abstract; $abstractAttributes = $abstractAttributes['@attributes']; $this->checkMandatoryAttributes('Abstract in module ' . $module, $abstractAttributes, ['name']); $abstractName = $abstractAttributes['name']; $this->insideAbstracts[$module][] = $abstractName; $this->checkMandatoryAttributes( 'Abstract ' . $abstractName . ' in module ' . $module, $abstractAttributes, ['left', 'top'] ); $r .= 'var s = new Abstract(\'' . $abstractName . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $abstractAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($abstractAttributes, 's'); $r .= 's.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside abstracts $abstracts = (array)$this->xml->xpath('/draggy/loose/abstract'); foreach ($abstracts as $abstract) { $abstractAttributes = (array)$abstract; $abstractAttributes = $abstractAttributes['@attributes']; $this->checkMandatoryAttributes('Loose abstract', $abstractAttributes, ['name']); $abstractName = $abstractAttributes['name']; $this->outsideAbstracts[] = $abstractName; $this->checkMandatoryAttributes('Loose abstract ' . $abstractName, $abstractAttributes, ['left', 'top']); $r .= 'var s = new Abstract(\'' . $abstractName . '\');' . PHP_EOL; $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] ) . 'px\',\'' . ( $abstractAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($abstractAttributes, 's'); } return $r; }
php
private function getAbstracts() { $r = ''; // Inside abstracts foreach ($this->modules as $module) { $abstracts = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/abstract'); foreach ($abstracts as $abstract) { $abstractAttributes = (array)$abstract; $abstractAttributes = $abstractAttributes['@attributes']; $this->checkMandatoryAttributes('Abstract in module ' . $module, $abstractAttributes, ['name']); $abstractName = $abstractAttributes['name']; $this->insideAbstracts[$module][] = $abstractName; $this->checkMandatoryAttributes( 'Abstract ' . $abstractName . ' in module ' . $module, $abstractAttributes, ['left', 'top'] ); $r .= 'var s = new Abstract(\'' . $abstractName . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $abstractAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($abstractAttributes, 's'); $r .= 's.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside abstracts $abstracts = (array)$this->xml->xpath('/draggy/loose/abstract'); foreach ($abstracts as $abstract) { $abstractAttributes = (array)$abstract; $abstractAttributes = $abstractAttributes['@attributes']; $this->checkMandatoryAttributes('Loose abstract', $abstractAttributes, ['name']); $abstractName = $abstractAttributes['name']; $this->outsideAbstracts[] = $abstractName; $this->checkMandatoryAttributes('Loose abstract ' . $abstractName, $abstractAttributes, ['left', 'top']); $r .= 'var s = new Abstract(\'' . $abstractName . '\');' . PHP_EOL; $r .= 's.moveTo(\'' . ( $abstractAttributes['left'] ) . 'px\',\'' . ( $abstractAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getClassLikeProperties($abstractAttributes, 's'); } return $r; }
[ "private", "function", "getAbstracts", "(", ")", "{", "$", "r", "=", "''", ";", "// Inside abstracts", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "abstracts", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module[@name=\\''", ".", "$", "module", ".", "'\\']/abstract'", ")", ";", "foreach", "(", "$", "abstracts", "as", "$", "abstract", ")", "{", "$", "abstractAttributes", "=", "(", "array", ")", "$", "abstract", ";", "$", "abstractAttributes", "=", "$", "abstractAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Abstract in module '", ".", "$", "module", ",", "$", "abstractAttributes", ",", "[", "'name'", "]", ")", ";", "$", "abstractName", "=", "$", "abstractAttributes", "[", "'name'", "]", ";", "$", "this", "->", "insideAbstracts", "[", "$", "module", "]", "[", "]", "=", "$", "abstractName", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Abstract '", ".", "$", "abstractName", ".", "' in module '", ".", "$", "module", ",", "$", "abstractAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var s = new Abstract(\\''", ".", "$", "abstractName", ".", "'\\',\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'s.moveTo(\\''", ".", "(", "$", "abstractAttributes", "[", "'left'", "]", "/*- 1*/", ")", ".", "'px\\',\\''", ".", "(", "$", "abstractAttributes", "[", "'top'", "]", "/*- 1*/", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeProperties", "(", "$", "abstractAttributes", ",", "'s'", ")", ";", "$", "r", ".=", "'s.setModule(Container.prototype.getContainerByName(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\').getId());'", ".", "PHP_EOL", ";", "}", "}", "// Outside abstracts", "$", "abstracts", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/loose/abstract'", ")", ";", "foreach", "(", "$", "abstracts", "as", "$", "abstract", ")", "{", "$", "abstractAttributes", "=", "(", "array", ")", "$", "abstract", ";", "$", "abstractAttributes", "=", "$", "abstractAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose abstract'", ",", "$", "abstractAttributes", ",", "[", "'name'", "]", ")", ";", "$", "abstractName", "=", "$", "abstractAttributes", "[", "'name'", "]", ";", "$", "this", "->", "outsideAbstracts", "[", "]", "=", "$", "abstractName", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose abstract '", ".", "$", "abstractName", ",", "$", "abstractAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var s = new Abstract(\\''", ".", "$", "abstractName", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'s.moveTo(\\''", ".", "(", "$", "abstractAttributes", "[", "'left'", "]", ")", ".", "'px\\',\\''", ".", "(", "$", "abstractAttributes", "[", "'top'", "]", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeProperties", "(", "$", "abstractAttributes", ",", "'s'", ")", ";", "}", "return", "$", "r", ";", "}" ]
Get the project classes @return string
[ "Get", "the", "project", "classes" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L294-L357
j-d/draggy
src/Draggy/Loader.php
Loader.getInterfaceProperties
private function getInterfaceProperties($interfaceAttributes, $varName) { $r = ''; if (isset( $interfaceAttributes['description'] )) { $r .= $varName . '.setDescription("' . str_replace('\'', '\\\'', $interfaceAttributes['description']) . '");' . PHP_EOL; } return $r; }
php
private function getInterfaceProperties($interfaceAttributes, $varName) { $r = ''; if (isset( $interfaceAttributes['description'] )) { $r .= $varName . '.setDescription("' . str_replace('\'', '\\\'', $interfaceAttributes['description']) . '");' . PHP_EOL; } return $r; }
[ "private", "function", "getInterfaceProperties", "(", "$", "interfaceAttributes", ",", "$", "varName", ")", "{", "$", "r", "=", "''", ";", "if", "(", "isset", "(", "$", "interfaceAttributes", "[", "'description'", "]", ")", ")", "{", "$", "r", ".=", "$", "varName", ".", "'.setDescription(\"'", ".", "str_replace", "(", "'\\''", ",", "'\\\\\\''", ",", "$", "interfaceAttributes", "[", "'description'", "]", ")", ".", "'\");'", ".", "PHP_EOL", ";", "}", "return", "$", "r", ";", "}" ]
@param array $interfaceAttributes @param string $varName @return string
[ "@param", "array", "$interfaceAttributes", "@param", "string", "$varName" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L365-L374
j-d/draggy
src/Draggy/Loader.php
Loader.getInterfaces
private function getInterfaces() { $r = ''; // Inside interfaces foreach ($this->modules as $module) { $interfaces = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/interface'); foreach ($interfaces as $interface) { $interfaceAttributes = (array)$interface; $interfaceAttributes = $interfaceAttributes['@attributes']; $this->checkMandatoryAttributes('Interface in module ' . $module, $interfaceAttributes, ['name']); $className = $interfaceAttributes['name']; $this->checkMandatoryAttributes( 'Interface ' . $className . ' in module ' . $module, $interfaceAttributes, ['left', 'top'] ); $r .= 'var i = new Interface(\'' . $interfaceAttributes['name'] . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $interfaceAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getInterfaceProperties($interfaceAttributes, 'i'); $r .= 'i.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside interfaces $interfaces = (array)$this->xml->xpath('/draggy/loose/interface'); foreach ($interfaces as $interface) { $interfaceAttributes = (array)$interface; $interfaceAttributes = $interfaceAttributes['@attributes']; $this->checkMandatoryAttributes('Loose interface', $interfaceAttributes, ['name']); $className = $interfaceAttributes['name']; $this->checkMandatoryAttributes('Loose interface ' . $className, $interfaceAttributes, ['left', 'top']); $r .= 'var i = new Interface(\'' . $className . '\');' . PHP_EOL; $r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] ) . 'px\',\'' . ( $interfaceAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getInterfaceProperties($interfaceAttributes, 'i'); } return $r; }
php
private function getInterfaces() { $r = ''; // Inside interfaces foreach ($this->modules as $module) { $interfaces = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/interface'); foreach ($interfaces as $interface) { $interfaceAttributes = (array)$interface; $interfaceAttributes = $interfaceAttributes['@attributes']; $this->checkMandatoryAttributes('Interface in module ' . $module, $interfaceAttributes, ['name']); $className = $interfaceAttributes['name']; $this->checkMandatoryAttributes( 'Interface ' . $className . ' in module ' . $module, $interfaceAttributes, ['left', 'top'] ); $r .= 'var i = new Interface(\'' . $interfaceAttributes['name'] . '\',\'' . str_replace( '\\', '\\\\', $module ) . '\');' . PHP_EOL; $r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $interfaceAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL; $r .= $this->getInterfaceProperties($interfaceAttributes, 'i'); $r .= 'i.setModule(Container.prototype.getContainerByName(\'' . str_replace( '\\', '\\\\', $module ) . '\').getId());' . PHP_EOL; } } // Outside interfaces $interfaces = (array)$this->xml->xpath('/draggy/loose/interface'); foreach ($interfaces as $interface) { $interfaceAttributes = (array)$interface; $interfaceAttributes = $interfaceAttributes['@attributes']; $this->checkMandatoryAttributes('Loose interface', $interfaceAttributes, ['name']); $className = $interfaceAttributes['name']; $this->checkMandatoryAttributes('Loose interface ' . $className, $interfaceAttributes, ['left', 'top']); $r .= 'var i = new Interface(\'' . $className . '\');' . PHP_EOL; $r .= 'i.moveTo(\'' . ( $interfaceAttributes['left'] ) . 'px\',\'' . ( $interfaceAttributes['top'] ) . 'px\');' . PHP_EOL; $r .= $this->getInterfaceProperties($interfaceAttributes, 'i'); } return $r; }
[ "private", "function", "getInterfaces", "(", ")", "{", "$", "r", "=", "''", ";", "// Inside interfaces", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "interfaces", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module[@name=\\''", ".", "$", "module", ".", "'\\']/interface'", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "$", "interfaceAttributes", "=", "(", "array", ")", "$", "interface", ";", "$", "interfaceAttributes", "=", "$", "interfaceAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Interface in module '", ".", "$", "module", ",", "$", "interfaceAttributes", ",", "[", "'name'", "]", ")", ";", "$", "className", "=", "$", "interfaceAttributes", "[", "'name'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Interface '", ".", "$", "className", ".", "' in module '", ".", "$", "module", ",", "$", "interfaceAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var i = new Interface(\\''", ".", "$", "interfaceAttributes", "[", "'name'", "]", ".", "'\\',\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'i.moveTo(\\''", ".", "(", "$", "interfaceAttributes", "[", "'left'", "]", "/*- 1*/", ")", ".", "'px\\',\\''", ".", "(", "$", "interfaceAttributes", "[", "'top'", "]", "/*- 1*/", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getInterfaceProperties", "(", "$", "interfaceAttributes", ",", "'i'", ")", ";", "$", "r", ".=", "'i.setModule(Container.prototype.getContainerByName(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "module", ")", ".", "'\\').getId());'", ".", "PHP_EOL", ";", "}", "}", "// Outside interfaces", "$", "interfaces", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/loose/interface'", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "$", "interfaceAttributes", "=", "(", "array", ")", "$", "interface", ";", "$", "interfaceAttributes", "=", "$", "interfaceAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose interface'", ",", "$", "interfaceAttributes", ",", "[", "'name'", "]", ")", ";", "$", "className", "=", "$", "interfaceAttributes", "[", "'name'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Loose interface '", ".", "$", "className", ",", "$", "interfaceAttributes", ",", "[", "'left'", ",", "'top'", "]", ")", ";", "$", "r", ".=", "'var i = new Interface(\\''", ".", "$", "className", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "'i.moveTo(\\''", ".", "(", "$", "interfaceAttributes", "[", "'left'", "]", ")", ".", "'px\\',\\''", ".", "(", "$", "interfaceAttributes", "[", "'top'", "]", ")", ".", "'px\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getInterfaceProperties", "(", "$", "interfaceAttributes", ",", "'i'", ")", ";", "}", "return", "$", "r", ";", "}" ]
Get the project interfaces @return string
[ "Get", "the", "project", "interfaces" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L381-L440
j-d/draggy
src/Draggy/Loader.php
Loader.getClassLikeAttributeProperties
private function getClassLikeAttributeProperties($classLike, $classLikeAttributeAttributes, $varName) { $r = ''; foreach ($classLikeAttributeAttributes as $attribute) { $attributeProperties = (array)$attribute; $attributeProperties = $attributeProperties['@attributes']; if (isset( $attributeProperties['inherited'] )) { $this->checkMandatoryAttributes('Attributes ' . $classLike, $attributeProperties, ['id']); $r .= 'var a = new InheritedAttribute(\'' . $attributeProperties['id'] . '\');' . PHP_EOL; $r .= $varName . '.addInheritedAttribute(a);' . PHP_EOL; } else { $this->checkMandatoryAttributes('Attributes ' . $classLike, $attributeProperties, ['id', 'name']); $r .= 'var a = new Attribute(\'' . $attributeProperties['name'] . '\',\'' . $attributeProperties['id'] . '\');' . PHP_EOL; if (isset( $attributeProperties['type'] )) { $r .= 'a.setType(\'' . $attributeProperties['type'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['subtype'] )) { $r .= 'a.setSubtype(\'' . str_replace( '\\', '\\\\', $attributeProperties['subtype'] ) . '\');' . PHP_EOL; } if (isset( $attributeProperties['size'] )) { $r .= 'a.setSize(\'' . $attributeProperties['size'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['null'] )) { $r .= 'a.setNull(' . $attributeProperties['null'] . ');' . PHP_EOL; } if (isset( $attributeProperties['primary'] )) { $r .= 'a.setPrimary(' . $attributeProperties['primary'] . ');' . PHP_EOL; } if (isset( $attributeProperties['foreign'] )) { $r .= 'a.setForeign(' . $attributeProperties['foreign'] . ');' . PHP_EOL; } if (isset( $attributeProperties['autoincrement'] )) { $r .= 'a.setAutoincrement(' . $attributeProperties['autoincrement'] . ');' . PHP_EOL; } if (isset( $attributeProperties['unique'] )) { $r .= 'a.setUnique(' . $attributeProperties['unique'] . ');' . PHP_EOL; } if (isset( $attributeProperties['default'] )) { $r .= 'a.setDefault(\'' . str_replace( '\'', '\\\'', $attributeProperties['default'] ) . '\');' . PHP_EOL; } if (isset( $attributeProperties['description'] )) { $r .= 'a.setDescription(\'' . str_replace('\'', '\\\'', $attributeProperties['description']) . '\');' . PHP_EOL; } if (isset( $attributeProperties['getter'] )) { $r .= 'a.setGetter(' . $attributeProperties['getter'] . ');' . PHP_EOL; } if (isset( $attributeProperties['setter'] )) { $r .= 'a.setSetter(' . $attributeProperties['setter'] . ');' . PHP_EOL; } if (isset( $attributeProperties['minSize'] )) { $r .= 'a.setMinSize(\'' . $attributeProperties['minSize'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['email'] )) { $r .= 'a.setEmail(' . $attributeProperties['email'] . ');' . PHP_EOL; } if (isset( $attributeProperties['min'] )) { $r .= 'a.setMin(\'' . $attributeProperties['min'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['max'] )) { $r .= 'a.setMax(\'' . $attributeProperties['max'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['static'] )) { $r .= 'a.setStatic(\'' . $attributeProperties['static'] . '\');' . PHP_EOL; } $r .= $varName . '.addAttribute(a);' . PHP_EOL; } } return $r; }
php
private function getClassLikeAttributeProperties($classLike, $classLikeAttributeAttributes, $varName) { $r = ''; foreach ($classLikeAttributeAttributes as $attribute) { $attributeProperties = (array)$attribute; $attributeProperties = $attributeProperties['@attributes']; if (isset( $attributeProperties['inherited'] )) { $this->checkMandatoryAttributes('Attributes ' . $classLike, $attributeProperties, ['id']); $r .= 'var a = new InheritedAttribute(\'' . $attributeProperties['id'] . '\');' . PHP_EOL; $r .= $varName . '.addInheritedAttribute(a);' . PHP_EOL; } else { $this->checkMandatoryAttributes('Attributes ' . $classLike, $attributeProperties, ['id', 'name']); $r .= 'var a = new Attribute(\'' . $attributeProperties['name'] . '\',\'' . $attributeProperties['id'] . '\');' . PHP_EOL; if (isset( $attributeProperties['type'] )) { $r .= 'a.setType(\'' . $attributeProperties['type'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['subtype'] )) { $r .= 'a.setSubtype(\'' . str_replace( '\\', '\\\\', $attributeProperties['subtype'] ) . '\');' . PHP_EOL; } if (isset( $attributeProperties['size'] )) { $r .= 'a.setSize(\'' . $attributeProperties['size'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['null'] )) { $r .= 'a.setNull(' . $attributeProperties['null'] . ');' . PHP_EOL; } if (isset( $attributeProperties['primary'] )) { $r .= 'a.setPrimary(' . $attributeProperties['primary'] . ');' . PHP_EOL; } if (isset( $attributeProperties['foreign'] )) { $r .= 'a.setForeign(' . $attributeProperties['foreign'] . ');' . PHP_EOL; } if (isset( $attributeProperties['autoincrement'] )) { $r .= 'a.setAutoincrement(' . $attributeProperties['autoincrement'] . ');' . PHP_EOL; } if (isset( $attributeProperties['unique'] )) { $r .= 'a.setUnique(' . $attributeProperties['unique'] . ');' . PHP_EOL; } if (isset( $attributeProperties['default'] )) { $r .= 'a.setDefault(\'' . str_replace( '\'', '\\\'', $attributeProperties['default'] ) . '\');' . PHP_EOL; } if (isset( $attributeProperties['description'] )) { $r .= 'a.setDescription(\'' . str_replace('\'', '\\\'', $attributeProperties['description']) . '\');' . PHP_EOL; } if (isset( $attributeProperties['getter'] )) { $r .= 'a.setGetter(' . $attributeProperties['getter'] . ');' . PHP_EOL; } if (isset( $attributeProperties['setter'] )) { $r .= 'a.setSetter(' . $attributeProperties['setter'] . ');' . PHP_EOL; } if (isset( $attributeProperties['minSize'] )) { $r .= 'a.setMinSize(\'' . $attributeProperties['minSize'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['email'] )) { $r .= 'a.setEmail(' . $attributeProperties['email'] . ');' . PHP_EOL; } if (isset( $attributeProperties['min'] )) { $r .= 'a.setMin(\'' . $attributeProperties['min'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['max'] )) { $r .= 'a.setMax(\'' . $attributeProperties['max'] . '\');' . PHP_EOL; } if (isset( $attributeProperties['static'] )) { $r .= 'a.setStatic(\'' . $attributeProperties['static'] . '\');' . PHP_EOL; } $r .= $varName . '.addAttribute(a);' . PHP_EOL; } } return $r; }
[ "private", "function", "getClassLikeAttributeProperties", "(", "$", "classLike", ",", "$", "classLikeAttributeAttributes", ",", "$", "varName", ")", "{", "$", "r", "=", "''", ";", "foreach", "(", "$", "classLikeAttributeAttributes", "as", "$", "attribute", ")", "{", "$", "attributeProperties", "=", "(", "array", ")", "$", "attribute", ";", "$", "attributeProperties", "=", "$", "attributeProperties", "[", "'@attributes'", "]", ";", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'inherited'", "]", ")", ")", "{", "$", "this", "->", "checkMandatoryAttributes", "(", "'Attributes '", ".", "$", "classLike", ",", "$", "attributeProperties", ",", "[", "'id'", "]", ")", ";", "$", "r", ".=", "'var a = new InheritedAttribute(\\''", ".", "$", "attributeProperties", "[", "'id'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "varName", ".", "'.addInheritedAttribute(a);'", ".", "PHP_EOL", ";", "}", "else", "{", "$", "this", "->", "checkMandatoryAttributes", "(", "'Attributes '", ".", "$", "classLike", ",", "$", "attributeProperties", ",", "[", "'id'", ",", "'name'", "]", ")", ";", "$", "r", ".=", "'var a = new Attribute(\\''", ".", "$", "attributeProperties", "[", "'name'", "]", ".", "'\\',\\''", ".", "$", "attributeProperties", "[", "'id'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'type'", "]", ")", ")", "{", "$", "r", ".=", "'a.setType(\\''", ".", "$", "attributeProperties", "[", "'type'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'subtype'", "]", ")", ")", "{", "$", "r", ".=", "'a.setSubtype(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "attributeProperties", "[", "'subtype'", "]", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'size'", "]", ")", ")", "{", "$", "r", ".=", "'a.setSize(\\''", ".", "$", "attributeProperties", "[", "'size'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'null'", "]", ")", ")", "{", "$", "r", ".=", "'a.setNull('", ".", "$", "attributeProperties", "[", "'null'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'primary'", "]", ")", ")", "{", "$", "r", ".=", "'a.setPrimary('", ".", "$", "attributeProperties", "[", "'primary'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'foreign'", "]", ")", ")", "{", "$", "r", ".=", "'a.setForeign('", ".", "$", "attributeProperties", "[", "'foreign'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'autoincrement'", "]", ")", ")", "{", "$", "r", ".=", "'a.setAutoincrement('", ".", "$", "attributeProperties", "[", "'autoincrement'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'unique'", "]", ")", ")", "{", "$", "r", ".=", "'a.setUnique('", ".", "$", "attributeProperties", "[", "'unique'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'default'", "]", ")", ")", "{", "$", "r", ".=", "'a.setDefault(\\''", ".", "str_replace", "(", "'\\''", ",", "'\\\\\\''", ",", "$", "attributeProperties", "[", "'default'", "]", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'description'", "]", ")", ")", "{", "$", "r", ".=", "'a.setDescription(\\''", ".", "str_replace", "(", "'\\''", ",", "'\\\\\\''", ",", "$", "attributeProperties", "[", "'description'", "]", ")", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'getter'", "]", ")", ")", "{", "$", "r", ".=", "'a.setGetter('", ".", "$", "attributeProperties", "[", "'getter'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'setter'", "]", ")", ")", "{", "$", "r", ".=", "'a.setSetter('", ".", "$", "attributeProperties", "[", "'setter'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'minSize'", "]", ")", ")", "{", "$", "r", ".=", "'a.setMinSize(\\''", ".", "$", "attributeProperties", "[", "'minSize'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'email'", "]", ")", ")", "{", "$", "r", ".=", "'a.setEmail('", ".", "$", "attributeProperties", "[", "'email'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'min'", "]", ")", ")", "{", "$", "r", ".=", "'a.setMin(\\''", ".", "$", "attributeProperties", "[", "'min'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'max'", "]", ")", ")", "{", "$", "r", ".=", "'a.setMax(\\''", ".", "$", "attributeProperties", "[", "'max'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "attributeProperties", "[", "'static'", "]", ")", ")", "{", "$", "r", ".=", "'a.setStatic(\\''", ".", "$", "attributeProperties", "[", "'static'", "]", ".", "'\\');'", ".", "PHP_EOL", ";", "}", "$", "r", ".=", "$", "varName", ".", "'.addAttribute(a);'", ".", "PHP_EOL", ";", "}", "}", "return", "$", "r", ";", "}" ]
@param string $classLike @param array $classLikeAttributeAttributes @param string $varName @return string
[ "@param", "string", "$classLike", "@param", "array", "$classLikeAttributeAttributes", "@param", "string", "$varName" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L449-L532
j-d/draggy
src/Draggy/Loader.php
Loader.getAttributes
private function getAttributes() { $r = ''; // Inside classes foreach ($this->insideClasses as $insideClassModule => $insideClasses) { foreach ($insideClasses as $insideClass) { $attributes = $this->xml->xpath( '/draggy/module[@name=\'' . $insideClassModule . '\']/class[@name=\'' . $insideClass . '\']/attribute' ); $r .= 'c = Connectable.prototype.getConnectableFromName(\'' . str_replace( '\\', '\\\\', $insideClassModule . '\\' ) . $insideClass . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($insideClass, $attributes, 'c'); if (isset( $insideClass['toString'] )) { $r .= 'c.setToString(c.getAttributeFromName("' . $insideClass['toString'] . '"))' . PHP_EOL; } } } // Inside abstracts foreach ($this->insideAbstracts as $insideAbstractModule => $insideAbstracts) { foreach ($insideAbstracts as $insideAbstract) { $attributes = $this->xml->xpath( '/draggy/module[@name=\'' . $insideAbstractModule . '\']/abstract[@name=\'' . $insideAbstract . '\']/attribute' ); $r .= 's = Connectable.prototype.getConnectableFromName(\'' . str_replace( '\\', '\\\\', $insideAbstractModule . '\\' ) . $insideAbstract . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($insideAbstract, $attributes, 's'); if (isset( $insideAbstract['toString'] )) { $r .= 's.setToString(s.getAttributeFromName("' . $insideAbstract['toString'] . '"))' . PHP_EOL; } } } // Outside classes foreach ($this->outsideClasses as $outsideClass) { $attributes = $this->xml->xpath('/draggy/loose/class[@name=\'' . $outsideClass . '\']/attribute'); $r .= 'c = Connectable.prototype.getConnectableFromName(\'' . $outsideClass . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($outsideClass, $attributes, 'c'); if (isset( $outsideClass['toString'] )) { $r .= 'c.setToString(c.getAttributeFromName("' . $outsideClass['toString'] . '"))' . PHP_EOL; } } // Outside abstracts foreach ($this->outsideAbstracts as $outsideAbstract) { $attributes = $this->xml->xpath('/draggy/loose/abstract[@name=\'' . $outsideAbstract . '\']/attribute'); $r .= 's = Connectable.prototype.getConnectableFromName(\'' . $outsideAbstract . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($outsideAbstract, $attributes, 's'); if (isset( $outsideAbstract['toString'] )) { $r .= 's.setToString(s.getAttributeFromName("' . $outsideAbstract['toString'] . '"))' . PHP_EOL; } } return $r; }
php
private function getAttributes() { $r = ''; // Inside classes foreach ($this->insideClasses as $insideClassModule => $insideClasses) { foreach ($insideClasses as $insideClass) { $attributes = $this->xml->xpath( '/draggy/module[@name=\'' . $insideClassModule . '\']/class[@name=\'' . $insideClass . '\']/attribute' ); $r .= 'c = Connectable.prototype.getConnectableFromName(\'' . str_replace( '\\', '\\\\', $insideClassModule . '\\' ) . $insideClass . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($insideClass, $attributes, 'c'); if (isset( $insideClass['toString'] )) { $r .= 'c.setToString(c.getAttributeFromName("' . $insideClass['toString'] . '"))' . PHP_EOL; } } } // Inside abstracts foreach ($this->insideAbstracts as $insideAbstractModule => $insideAbstracts) { foreach ($insideAbstracts as $insideAbstract) { $attributes = $this->xml->xpath( '/draggy/module[@name=\'' . $insideAbstractModule . '\']/abstract[@name=\'' . $insideAbstract . '\']/attribute' ); $r .= 's = Connectable.prototype.getConnectableFromName(\'' . str_replace( '\\', '\\\\', $insideAbstractModule . '\\' ) . $insideAbstract . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($insideAbstract, $attributes, 's'); if (isset( $insideAbstract['toString'] )) { $r .= 's.setToString(s.getAttributeFromName("' . $insideAbstract['toString'] . '"))' . PHP_EOL; } } } // Outside classes foreach ($this->outsideClasses as $outsideClass) { $attributes = $this->xml->xpath('/draggy/loose/class[@name=\'' . $outsideClass . '\']/attribute'); $r .= 'c = Connectable.prototype.getConnectableFromName(\'' . $outsideClass . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($outsideClass, $attributes, 'c'); if (isset( $outsideClass['toString'] )) { $r .= 'c.setToString(c.getAttributeFromName("' . $outsideClass['toString'] . '"))' . PHP_EOL; } } // Outside abstracts foreach ($this->outsideAbstracts as $outsideAbstract) { $attributes = $this->xml->xpath('/draggy/loose/abstract[@name=\'' . $outsideAbstract . '\']/attribute'); $r .= 's = Connectable.prototype.getConnectableFromName(\'' . $outsideAbstract . '\');' . PHP_EOL; $r .= $this->getClassLikeAttributeProperties($outsideAbstract, $attributes, 's'); if (isset( $outsideAbstract['toString'] )) { $r .= 's.setToString(s.getAttributeFromName("' . $outsideAbstract['toString'] . '"))' . PHP_EOL; } } return $r; }
[ "private", "function", "getAttributes", "(", ")", "{", "$", "r", "=", "''", ";", "// Inside classes", "foreach", "(", "$", "this", "->", "insideClasses", "as", "$", "insideClassModule", "=>", "$", "insideClasses", ")", "{", "foreach", "(", "$", "insideClasses", "as", "$", "insideClass", ")", "{", "$", "attributes", "=", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module[@name=\\''", ".", "$", "insideClassModule", ".", "'\\']/class[@name=\\''", ".", "$", "insideClass", ".", "'\\']/attribute'", ")", ";", "$", "r", ".=", "'c = Connectable.prototype.getConnectableFromName(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "insideClassModule", ".", "'\\\\'", ")", ".", "$", "insideClass", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeAttributeProperties", "(", "$", "insideClass", ",", "$", "attributes", ",", "'c'", ")", ";", "if", "(", "isset", "(", "$", "insideClass", "[", "'toString'", "]", ")", ")", "{", "$", "r", ".=", "'c.setToString(c.getAttributeFromName(\"'", ".", "$", "insideClass", "[", "'toString'", "]", ".", "'\"))'", ".", "PHP_EOL", ";", "}", "}", "}", "// Inside abstracts", "foreach", "(", "$", "this", "->", "insideAbstracts", "as", "$", "insideAbstractModule", "=>", "$", "insideAbstracts", ")", "{", "foreach", "(", "$", "insideAbstracts", "as", "$", "insideAbstract", ")", "{", "$", "attributes", "=", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/module[@name=\\''", ".", "$", "insideAbstractModule", ".", "'\\']/abstract[@name=\\''", ".", "$", "insideAbstract", ".", "'\\']/attribute'", ")", ";", "$", "r", ".=", "'s = Connectable.prototype.getConnectableFromName(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "insideAbstractModule", ".", "'\\\\'", ")", ".", "$", "insideAbstract", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeAttributeProperties", "(", "$", "insideAbstract", ",", "$", "attributes", ",", "'s'", ")", ";", "if", "(", "isset", "(", "$", "insideAbstract", "[", "'toString'", "]", ")", ")", "{", "$", "r", ".=", "'s.setToString(s.getAttributeFromName(\"'", ".", "$", "insideAbstract", "[", "'toString'", "]", ".", "'\"))'", ".", "PHP_EOL", ";", "}", "}", "}", "// Outside classes", "foreach", "(", "$", "this", "->", "outsideClasses", "as", "$", "outsideClass", ")", "{", "$", "attributes", "=", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/loose/class[@name=\\''", ".", "$", "outsideClass", ".", "'\\']/attribute'", ")", ";", "$", "r", ".=", "'c = Connectable.prototype.getConnectableFromName(\\''", ".", "$", "outsideClass", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeAttributeProperties", "(", "$", "outsideClass", ",", "$", "attributes", ",", "'c'", ")", ";", "if", "(", "isset", "(", "$", "outsideClass", "[", "'toString'", "]", ")", ")", "{", "$", "r", ".=", "'c.setToString(c.getAttributeFromName(\"'", ".", "$", "outsideClass", "[", "'toString'", "]", ".", "'\"))'", ".", "PHP_EOL", ";", "}", "}", "// Outside abstracts", "foreach", "(", "$", "this", "->", "outsideAbstracts", "as", "$", "outsideAbstract", ")", "{", "$", "attributes", "=", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/loose/abstract[@name=\\''", ".", "$", "outsideAbstract", ".", "'\\']/attribute'", ")", ";", "$", "r", ".=", "'s = Connectable.prototype.getConnectableFromName(\\''", ".", "$", "outsideAbstract", ".", "'\\');'", ".", "PHP_EOL", ";", "$", "r", ".=", "$", "this", "->", "getClassLikeAttributeProperties", "(", "$", "outsideAbstract", ",", "$", "attributes", ",", "'s'", ")", ";", "if", "(", "isset", "(", "$", "outsideAbstract", "[", "'toString'", "]", ")", ")", "{", "$", "r", ".=", "'s.setToString(s.getAttributeFromName(\"'", ".", "$", "outsideAbstract", "[", "'toString'", "]", ".", "'\"))'", ".", "PHP_EOL", ";", "}", "}", "return", "$", "r", ";", "}" ]
Get the project attributes @return string
[ "Get", "the", "project", "attributes" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L539-L612
j-d/draggy
src/Draggy/Loader.php
Loader.getRelationships
private function getRelationships() { $r = ''; $relationships = (array)$this->xml->xpath('/draggy/relationships/relation'); foreach ($relationships as $relation) { $relationAttributes = (array)$relation; $relationAttributes = $relationAttributes['@attributes']; $this->checkMandatoryAttributes('Relationship', $relationAttributes, ['from', 'to', 'type']); $r .= 'var l = new Link(\'' . str_replace( '\\', '\\\\', $relationAttributes['from'] ) . '\',\'' . str_replace( '\\', '\\\\', $relationAttributes['to'] ) . '\',\'' . $relationAttributes['type'] . '\',' . ( isset( $relationAttributes['fromAttribute'] ) ? '\'' . $relationAttributes['fromAttribute'] . '\'' : 'undefined' ) . ', ' . ( isset( $relationAttributes['toAttribute'] ) ? '\'' . $relationAttributes['toAttribute'] . '\'' : 'undefined' ) . ')' . PHP_EOL; if (isset( $relationAttributes['broken'] )) { $r .= 'l.setBroken(' . $relationAttributes['broken'] . ');' . PHP_EOL; } if (isset( $relationAttributes['persist'] )) { if ('true' === $relationAttributes['persist']) { // Backwards compatibility $relationAttributes['persist'] = 'both'; } $r .= 'l.setPersist("' . $relationAttributes['persist'] . '");' . PHP_EOL; } else { // Backwards compatibility $r .= 'l.setPersist(true);' . PHP_EOL; } if (isset( $relationAttributes['remove'] )) { if ('true' === $relationAttributes['remove']) { // Backwards compatibility $relationAttributes['remove'] = 'both'; } $r .= 'l.setRemove("' . $relationAttributes['remove'] . '");' . PHP_EOL; } else { // Backwards compatibility $r .= 'l.setRemove(true);' . PHP_EOL; } } return $r; }
php
private function getRelationships() { $r = ''; $relationships = (array)$this->xml->xpath('/draggy/relationships/relation'); foreach ($relationships as $relation) { $relationAttributes = (array)$relation; $relationAttributes = $relationAttributes['@attributes']; $this->checkMandatoryAttributes('Relationship', $relationAttributes, ['from', 'to', 'type']); $r .= 'var l = new Link(\'' . str_replace( '\\', '\\\\', $relationAttributes['from'] ) . '\',\'' . str_replace( '\\', '\\\\', $relationAttributes['to'] ) . '\',\'' . $relationAttributes['type'] . '\',' . ( isset( $relationAttributes['fromAttribute'] ) ? '\'' . $relationAttributes['fromAttribute'] . '\'' : 'undefined' ) . ', ' . ( isset( $relationAttributes['toAttribute'] ) ? '\'' . $relationAttributes['toAttribute'] . '\'' : 'undefined' ) . ')' . PHP_EOL; if (isset( $relationAttributes['broken'] )) { $r .= 'l.setBroken(' . $relationAttributes['broken'] . ');' . PHP_EOL; } if (isset( $relationAttributes['persist'] )) { if ('true' === $relationAttributes['persist']) { // Backwards compatibility $relationAttributes['persist'] = 'both'; } $r .= 'l.setPersist("' . $relationAttributes['persist'] . '");' . PHP_EOL; } else { // Backwards compatibility $r .= 'l.setPersist(true);' . PHP_EOL; } if (isset( $relationAttributes['remove'] )) { if ('true' === $relationAttributes['remove']) { // Backwards compatibility $relationAttributes['remove'] = 'both'; } $r .= 'l.setRemove("' . $relationAttributes['remove'] . '");' . PHP_EOL; } else { // Backwards compatibility $r .= 'l.setRemove(true);' . PHP_EOL; } } return $r; }
[ "private", "function", "getRelationships", "(", ")", "{", "$", "r", "=", "''", ";", "$", "relationships", "=", "(", "array", ")", "$", "this", "->", "xml", "->", "xpath", "(", "'/draggy/relationships/relation'", ")", ";", "foreach", "(", "$", "relationships", "as", "$", "relation", ")", "{", "$", "relationAttributes", "=", "(", "array", ")", "$", "relation", ";", "$", "relationAttributes", "=", "$", "relationAttributes", "[", "'@attributes'", "]", ";", "$", "this", "->", "checkMandatoryAttributes", "(", "'Relationship'", ",", "$", "relationAttributes", ",", "[", "'from'", ",", "'to'", ",", "'type'", "]", ")", ";", "$", "r", ".=", "'var l = new Link(\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "relationAttributes", "[", "'from'", "]", ")", ".", "'\\',\\''", ".", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "relationAttributes", "[", "'to'", "]", ")", ".", "'\\',\\''", ".", "$", "relationAttributes", "[", "'type'", "]", ".", "'\\','", ".", "(", "isset", "(", "$", "relationAttributes", "[", "'fromAttribute'", "]", ")", "?", "'\\''", ".", "$", "relationAttributes", "[", "'fromAttribute'", "]", ".", "'\\''", ":", "'undefined'", ")", ".", "', '", ".", "(", "isset", "(", "$", "relationAttributes", "[", "'toAttribute'", "]", ")", "?", "'\\''", ".", "$", "relationAttributes", "[", "'toAttribute'", "]", ".", "'\\''", ":", "'undefined'", ")", ".", "')'", ".", "PHP_EOL", ";", "if", "(", "isset", "(", "$", "relationAttributes", "[", "'broken'", "]", ")", ")", "{", "$", "r", ".=", "'l.setBroken('", ".", "$", "relationAttributes", "[", "'broken'", "]", ".", "');'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "relationAttributes", "[", "'persist'", "]", ")", ")", "{", "if", "(", "'true'", "===", "$", "relationAttributes", "[", "'persist'", "]", ")", "{", "// Backwards compatibility", "$", "relationAttributes", "[", "'persist'", "]", "=", "'both'", ";", "}", "$", "r", ".=", "'l.setPersist(\"'", ".", "$", "relationAttributes", "[", "'persist'", "]", ".", "'\");'", ".", "PHP_EOL", ";", "}", "else", "{", "// Backwards compatibility", "$", "r", ".=", "'l.setPersist(true);'", ".", "PHP_EOL", ";", "}", "if", "(", "isset", "(", "$", "relationAttributes", "[", "'remove'", "]", ")", ")", "{", "if", "(", "'true'", "===", "$", "relationAttributes", "[", "'remove'", "]", ")", "{", "// Backwards compatibility", "$", "relationAttributes", "[", "'remove'", "]", "=", "'both'", ";", "}", "$", "r", ".=", "'l.setRemove(\"'", ".", "$", "relationAttributes", "[", "'remove'", "]", ".", "'\");'", ".", "PHP_EOL", ";", "}", "else", "{", "// Backwards compatibility", "$", "r", ".=", "'l.setRemove(true);'", ".", "PHP_EOL", ";", "}", "}", "return", "$", "r", ";", "}" ]
Get the project attributes @return string
[ "Get", "the", "project", "attributes" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L702-L749
j-d/draggy
src/Draggy/Loader.php
Loader.getLoaderJS
public function getLoaderJS() { if ($this->newFile) { return ''; } $r = ''; $r .= $this->getProjectProperties(); // FIRST STEP: Load all modules and entities $r .= $this->getModules(); $r .= $this->getClasses(); $r .= $this->getAbstracts(); $r .= $this->getInterfaces(); // SECOND STEP: Add the attributes $r .= $this->getAttributes(); // THIRD STEP: After attributes entity properties $r .= $this->getClassLikeAfterAttributesProperties(); // FOURTH STEP: Relationships $r .= $this->getRelationships(); $r .= $this->getAutocodeProperties(); // Finalise $r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL; $r .= 'Link.prototype.reDrawLinks();' . PHP_EOL; $r .= 'System.prototype.runtime = true;' . PHP_EOL; return $r; }
php
public function getLoaderJS() { if ($this->newFile) { return ''; } $r = ''; $r .= $this->getProjectProperties(); // FIRST STEP: Load all modules and entities $r .= $this->getModules(); $r .= $this->getClasses(); $r .= $this->getAbstracts(); $r .= $this->getInterfaces(); // SECOND STEP: Add the attributes $r .= $this->getAttributes(); // THIRD STEP: After attributes entity properties $r .= $this->getClassLikeAfterAttributesProperties(); // FOURTH STEP: Relationships $r .= $this->getRelationships(); $r .= $this->getAutocodeProperties(); // Finalise $r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL; $r .= 'Link.prototype.reDrawLinks();' . PHP_EOL; $r .= 'System.prototype.runtime = true;' . PHP_EOL; return $r; }
[ "public", "function", "getLoaderJS", "(", ")", "{", "if", "(", "$", "this", "->", "newFile", ")", "{", "return", "''", ";", "}", "$", "r", "=", "''", ";", "$", "r", ".=", "$", "this", "->", "getProjectProperties", "(", ")", ";", "// FIRST STEP: Load all modules and entities", "$", "r", ".=", "$", "this", "->", "getModules", "(", ")", ";", "$", "r", ".=", "$", "this", "->", "getClasses", "(", ")", ";", "$", "r", ".=", "$", "this", "->", "getAbstracts", "(", ")", ";", "$", "r", ".=", "$", "this", "->", "getInterfaces", "(", ")", ";", "// SECOND STEP: Add the attributes", "$", "r", ".=", "$", "this", "->", "getAttributes", "(", ")", ";", "// THIRD STEP: After attributes entity properties", "$", "r", ".=", "$", "this", "->", "getClassLikeAfterAttributesProperties", "(", ")", ";", "// FOURTH STEP: Relationships", "$", "r", ".=", "$", "this", "->", "getRelationships", "(", ")", ";", "$", "r", ".=", "$", "this", "->", "getAutocodeProperties", "(", ")", ";", "// Finalise", "$", "r", ".=", "'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();'", ".", "PHP_EOL", ";", "$", "r", ".=", "'Link.prototype.reDrawLinks();'", ".", "PHP_EOL", ";", "$", "r", ".=", "'System.prototype.runtime = true;'", ".", "PHP_EOL", ";", "return", "$", "r", ";", "}" ]
Returns all the JS code to load the project @return string
[ "Returns", "all", "the", "JS", "code", "to", "load", "the", "project" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Loader.php#L756-L789
web2all/framework
src/Web2All/Manager/PrsLogger.class.php
Web2All_Manager_PrsLogger.log
public function log($level, $message, array $context = array()) { $this->Web2All->debugLog('['.$level.'] '.$this->interpolate($message, $context)); }
php
public function log($level, $message, array $context = array()) { $this->Web2All->debugLog('['.$level.'] '.$this->interpolate($message, $context)); }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "this", "->", "Web2All", "->", "debugLog", "(", "'['", ".", "$", "level", ".", "'] '", ".", "$", "this", "->", "interpolate", "(", "$", "message", ",", "$", "context", ")", ")", ";", "}" ]
Logs with an arbitrary level. @param mixed $level @param string $message @param array $context @return void
[ "Logs", "with", "an", "arbitrary", "level", "." ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/PrsLogger.class.php#L29-L32
surebert/surebert-framework
src/sb/Excel/Reader.php
Reader.readCells
public function readCells($func, $sheet = 0) { $rows = $this->rowcount(); $cols = $this->colcount(); for ($r = 1; $r <= $rows; $r++) { for ($c = 1; $c < $cols; $c++) { $func($this->value($r, $c, $sheet), $r, $c); } } }
php
public function readCells($func, $sheet = 0) { $rows = $this->rowcount(); $cols = $this->colcount(); for ($r = 1; $r <= $rows; $r++) { for ($c = 1; $c < $cols; $c++) { $func($this->value($r, $c, $sheet), $r, $c); } } }
[ "public", "function", "readCells", "(", "$", "func", ",", "$", "sheet", "=", "0", ")", "{", "$", "rows", "=", "$", "this", "->", "rowcount", "(", ")", ";", "$", "cols", "=", "$", "this", "->", "colcount", "(", ")", ";", "for", "(", "$", "r", "=", "1", ";", "$", "r", "<=", "$", "rows", ";", "$", "r", "++", ")", "{", "for", "(", "$", "c", "=", "1", ";", "$", "c", "<", "$", "cols", ";", "$", "c", "++", ")", "{", "$", "func", "(", "$", "this", "->", "value", "(", "$", "r", ",", "$", "c", ",", "$", "sheet", ")", ",", "$", "r", ",", "$", "c", ")", ";", "}", "}", "}" ]
Fires a function per cell @param function $func The function to fire for each cell, passes (value, rownum, colnum) as arguments @param integer $sheet The sheet to read use when going through cell @example <code> $data = new \sb\Excel_Reader('/path/to/excelfile.xls'); $data->readCells(function($val, $row, $col) use($data) { echo $data->rowheight($row, 0); }); </code>
[ "Fires", "a", "function", "per", "cell", "@param", "function", "$func", "The", "function", "to", "fire", "for", "each", "cell", "passes", "(", "value", "rownum", "colnum", ")", "as", "arguments", "@param", "integer", "$sheet", "The", "sheet", "to", "read", "use", "when", "going", "through", "cell", "@example", "<code", ">", "$data", "=", "new", "\\", "sb", "\\", "Excel_Reader", "(", "/", "path", "/", "to", "/", "excelfile", ".", "xls", ")", ";", "$data", "-", ">", "readCells", "(", "function", "(", "$val", "$row", "$col", ")", "use", "(", "$data", ")", "{", "echo", "$data", "-", ">", "rowheight", "(", "$row", "0", ")", ";", "}", ")", ";", "<", "/", "code", ">" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader.php#L70-L79
surebert/surebert-framework
src/sb/Excel/Reader.php
Reader.toArray
public function toArray($sheet = 0) { $arr = array(); for ($row = 1; $row <= $this->rowcount($sheet); $row++) { for ($col = 1; $col <= $this->colcount($sheet); $col++) { $arr[$row][$col] = $this->val($row, $col, $sheet); } } return $arr; }
php
public function toArray($sheet = 0) { $arr = array(); for ($row = 1; $row <= $this->rowcount($sheet); $row++) { for ($col = 1; $col <= $this->colcount($sheet); $col++) { $arr[$row][$col] = $this->val($row, $col, $sheet); } } return $arr; }
[ "public", "function", "toArray", "(", "$", "sheet", "=", "0", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "for", "(", "$", "row", "=", "1", ";", "$", "row", "<=", "$", "this", "->", "rowcount", "(", "$", "sheet", ")", ";", "$", "row", "++", ")", "{", "for", "(", "$", "col", "=", "1", ";", "$", "col", "<=", "$", "this", "->", "colcount", "(", "$", "sheet", ")", ";", "$", "col", "++", ")", "{", "$", "arr", "[", "$", "row", "]", "[", "$", "col", "]", "=", "$", "this", "->", "val", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", ")", ";", "}", "}", "return", "$", "arr", ";", "}" ]
export to multi dimensional array @param integer $sheet @return array
[ "export", "to", "multi", "dimensional", "array" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader.php#L86-L96
surebert/surebert-framework
src/sb/Excel/Reader.php
Reader.info
public function info($row, $col, $type = '', $sheet = 0) { $col = $this->getCol($col); if (array_key_exists('cellsInfo', $this->sheets[$sheet]) && array_key_exists($row, $this->sheets[$sheet]['cellsInfo']) && array_key_exists($col, $this->sheets[$sheet]['cellsInfo'][$row]) && array_key_exists($type, $this->sheets[$sheet]['cellsInfo'][$row][$col])) { return $this->sheets[$sheet]['cellsInfo'][$row][$col][$type]; } return ""; }
php
public function info($row, $col, $type = '', $sheet = 0) { $col = $this->getCol($col); if (array_key_exists('cellsInfo', $this->sheets[$sheet]) && array_key_exists($row, $this->sheets[$sheet]['cellsInfo']) && array_key_exists($col, $this->sheets[$sheet]['cellsInfo'][$row]) && array_key_exists($type, $this->sheets[$sheet]['cellsInfo'][$row][$col])) { return $this->sheets[$sheet]['cellsInfo'][$row][$col][$type]; } return ""; }
[ "public", "function", "info", "(", "$", "row", ",", "$", "col", ",", "$", "type", "=", "''", ",", "$", "sheet", "=", "0", ")", "{", "$", "col", "=", "$", "this", "->", "getCol", "(", "$", "col", ")", ";", "if", "(", "array_key_exists", "(", "'cellsInfo'", ",", "$", "this", "->", "sheets", "[", "$", "sheet", "]", ")", "&&", "array_key_exists", "(", "$", "row", ",", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", ")", "&&", "array_key_exists", "(", "$", "col", ",", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", ")", "&&", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", ")", ")", "{", "return", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "$", "type", "]", ";", "}", "return", "\"\"", ";", "}" ]
Gets info for a specifc cell of a specific sheet @param int $row @param int $col @param string $type @param int $sheet @return string
[ "Gets", "info", "for", "a", "specifc", "cell", "of", "a", "specific", "sheet" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader.php#L106-L116
alevilar/ristorantino-vendor
Mesa/Model/Mozo.php
Mozo.mesasAbiertas
public function mesasAbiertas($mozo_id = null, $lastAccess = null){ $conditions = array(); // si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo if ( !empty($mozo_id) ){ $conditions['Mozo.id'] = $mozo_id; } else { // todos los mozos activos $conditions['Mozo.activo'] = 1; } // condiciones para traer mesas abiertas y pendientes de cobro if ( Configure::read('Site.type') == SITE_TYPE_HOTEL ) { // si es hotel $conditionsMesa = array( 'Mesa.deleted' => 0, 'Mesa.checkin >' => date('Y-m-d', strtotime('-1 month')), ); } else { // es restaurante u otros comercios $conditionsMesa = array( "Mesa.estado_id" => array( MESA_ABIERTA, MESA_CERRADA, MESA_COBRADA), 'Mesa.deleted' => 0, ); } // si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido if ( !empty($lastAccess) ) { $conditionsMesa['Mesa.modified >='] = $lastAccess; } $contain = $this->Mesa->defaultContain; $contain['conditions'] = $conditionsMesa; unset($contain[0]); $optionsCreated = array( 'contain' => array('Mesa' => $contain), 'conditions'=> $conditions, ); $mesasABM = $this->find('all', $optionsCreated); $mozosMesa = array(); foreach ( $mesasABM as $abmMesas ) { // traer todos los mozos, con su array de mesas $abmMesas['Mozo']['mesas'] = $abmMesas['Mesa']; if ( !empty($lastAccess) ) { // enviar solo los que tienen mesas modificadas if (!empty($abmMesas['Mesa']) ) { $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } else { // enviar a todos $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } return $mozosMesa; }
php
public function mesasAbiertas($mozo_id = null, $lastAccess = null){ $conditions = array(); // si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo if ( !empty($mozo_id) ){ $conditions['Mozo.id'] = $mozo_id; } else { // todos los mozos activos $conditions['Mozo.activo'] = 1; } // condiciones para traer mesas abiertas y pendientes de cobro if ( Configure::read('Site.type') == SITE_TYPE_HOTEL ) { // si es hotel $conditionsMesa = array( 'Mesa.deleted' => 0, 'Mesa.checkin >' => date('Y-m-d', strtotime('-1 month')), ); } else { // es restaurante u otros comercios $conditionsMesa = array( "Mesa.estado_id" => array( MESA_ABIERTA, MESA_CERRADA, MESA_COBRADA), 'Mesa.deleted' => 0, ); } // si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido if ( !empty($lastAccess) ) { $conditionsMesa['Mesa.modified >='] = $lastAccess; } $contain = $this->Mesa->defaultContain; $contain['conditions'] = $conditionsMesa; unset($contain[0]); $optionsCreated = array( 'contain' => array('Mesa' => $contain), 'conditions'=> $conditions, ); $mesasABM = $this->find('all', $optionsCreated); $mozosMesa = array(); foreach ( $mesasABM as $abmMesas ) { // traer todos los mozos, con su array de mesas $abmMesas['Mozo']['mesas'] = $abmMesas['Mesa']; if ( !empty($lastAccess) ) { // enviar solo los que tienen mesas modificadas if (!empty($abmMesas['Mesa']) ) { $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } else { // enviar a todos $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } return $mozosMesa; }
[ "public", "function", "mesasAbiertas", "(", "$", "mozo_id", "=", "null", ",", "$", "lastAccess", "=", "null", ")", "{", "$", "conditions", "=", "array", "(", ")", ";", "// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo", "if", "(", "!", "empty", "(", "$", "mozo_id", ")", ")", "{", "$", "conditions", "[", "'Mozo.id'", "]", "=", "$", "mozo_id", ";", "}", "else", "{", "// todos los mozos activos", "$", "conditions", "[", "'Mozo.activo'", "]", "=", "1", ";", "}", "// condiciones para traer mesas abiertas y pendientes de cobro", "if", "(", "Configure", "::", "read", "(", "'Site.type'", ")", "==", "SITE_TYPE_HOTEL", ")", "{", "// si es hotel", "$", "conditionsMesa", "=", "array", "(", "'Mesa.deleted'", "=>", "0", ",", "'Mesa.checkin >'", "=>", "date", "(", "'Y-m-d'", ",", "strtotime", "(", "'-1 month'", ")", ")", ",", ")", ";", "}", "else", "{", "// es restaurante u otros comercios", "$", "conditionsMesa", "=", "array", "(", "\"Mesa.estado_id\"", "=>", "array", "(", "MESA_ABIERTA", ",", "MESA_CERRADA", ",", "MESA_COBRADA", ")", ",", "'Mesa.deleted'", "=>", "0", ",", ")", ";", "}", "// si vino el parametro lastAccess, traer solo las mesas actualizadas luego del ultimo pedido", "if", "(", "!", "empty", "(", "$", "lastAccess", ")", ")", "{", "$", "conditionsMesa", "[", "'Mesa.modified >='", "]", "=", "$", "lastAccess", ";", "}", "$", "contain", "=", "$", "this", "->", "Mesa", "->", "defaultContain", ";", "$", "contain", "[", "'conditions'", "]", "=", "$", "conditionsMesa", ";", "unset", "(", "$", "contain", "[", "0", "]", ")", ";", "$", "optionsCreated", "=", "array", "(", "'contain'", "=>", "array", "(", "'Mesa'", "=>", "$", "contain", ")", ",", "'conditions'", "=>", "$", "conditions", ",", ")", ";", "$", "mesasABM", "=", "$", "this", "->", "find", "(", "'all'", ",", "$", "optionsCreated", ")", ";", "$", "mozosMesa", "=", "array", "(", ")", ";", "foreach", "(", "$", "mesasABM", "as", "$", "abmMesas", ")", "{", "// traer todos los mozos, con su array de mesas", "$", "abmMesas", "[", "'Mozo'", "]", "[", "'mesas'", "]", "=", "$", "abmMesas", "[", "'Mesa'", "]", ";", "if", "(", "!", "empty", "(", "$", "lastAccess", ")", ")", "{", "// enviar solo los que tienen mesas modificadas", "if", "(", "!", "empty", "(", "$", "abmMesas", "[", "'Mesa'", "]", ")", ")", "{", "$", "mozosMesa", "[", "'mozos'", "]", "[", "]", "=", "$", "abmMesas", "[", "'Mozo'", "]", ";", "}", "}", "else", "{", "// enviar a todos", "$", "mozosMesa", "[", "'mozos'", "]", "[", "]", "=", "$", "abmMesas", "[", "'Mozo'", "]", ";", "}", "}", "return", "$", "mozosMesa", ";", "}" ]
Para todos los mozos activos, me trae sus mesas abiertas @param int $mozo_id id del mozo, en caso de que no le pase ninguno, me busca todos @return array Mozos con sus mesas, Comandas, detalleComanda, productos y sabores
[ "Para", "todos", "los", "mozos", "activos", "me", "trae", "sus", "mesas", "abiertas" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mozo.php#L103-L161
alevilar/ristorantino-vendor
Mesa/Model/Mozo.php
Mozo.mesasBorradas
public function mesasBorradas($mozo_id = null, $lastAccess = null){ if ( empty($lastAccess) ) { return array(); } $conditions = array(); // si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo if ( !empty($mozo_id) ){ $conditions['Mozo.id'] = $mozo_id; } else { // todos los mozos activos $conditions['Mozo.activo'] = 1; } // traer solo las mesas actualizadas luego del ultimo pedido $conditionsMesa = array( 'OR' => array ( array( 'Mesa.deleted' => 1, 'Mesa.deleted_date >=' => $lastAccess, ), array( 'Mesa.estado_id' => MESA_CHECKOUT, 'Mesa.checkout >=' => $lastAccess, ) ) ); $contain = $this->Mesa->defaultContain; $contain['conditions'] = $conditionsMesa; unset($contain[0]); // saco al Mozo del contain $optionsCreated = array( 'contain' => array('Mesa' => $contain), 'conditions'=> $conditions, ); $mesasABM = $this->find('all', $optionsCreated); $mozosMesa = array(); foreach ( $mesasABM as $abmMesas ) { // traer todos los mozos, con su array de mesas $abmMesas['Mozo']['mesas'] = $abmMesas['Mesa']; // enviar solo los que tienen mesas borradas if (!empty($abmMesas['Mesa']) ) { $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } return $mozosMesa; }
php
public function mesasBorradas($mozo_id = null, $lastAccess = null){ if ( empty($lastAccess) ) { return array(); } $conditions = array(); // si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo if ( !empty($mozo_id) ){ $conditions['Mozo.id'] = $mozo_id; } else { // todos los mozos activos $conditions['Mozo.activo'] = 1; } // traer solo las mesas actualizadas luego del ultimo pedido $conditionsMesa = array( 'OR' => array ( array( 'Mesa.deleted' => 1, 'Mesa.deleted_date >=' => $lastAccess, ), array( 'Mesa.estado_id' => MESA_CHECKOUT, 'Mesa.checkout >=' => $lastAccess, ) ) ); $contain = $this->Mesa->defaultContain; $contain['conditions'] = $conditionsMesa; unset($contain[0]); // saco al Mozo del contain $optionsCreated = array( 'contain' => array('Mesa' => $contain), 'conditions'=> $conditions, ); $mesasABM = $this->find('all', $optionsCreated); $mozosMesa = array(); foreach ( $mesasABM as $abmMesas ) { // traer todos los mozos, con su array de mesas $abmMesas['Mozo']['mesas'] = $abmMesas['Mesa']; // enviar solo los que tienen mesas borradas if (!empty($abmMesas['Mesa']) ) { $mozosMesa['mozos'][] = $abmMesas['Mozo']; } } return $mozosMesa; }
[ "public", "function", "mesasBorradas", "(", "$", "mozo_id", "=", "null", ",", "$", "lastAccess", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "lastAccess", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "conditions", "=", "array", "(", ")", ";", "// si vino el mozo por parametro, es porque solo quiero las mesas de ese mozo", "if", "(", "!", "empty", "(", "$", "mozo_id", ")", ")", "{", "$", "conditions", "[", "'Mozo.id'", "]", "=", "$", "mozo_id", ";", "}", "else", "{", "// todos los mozos activos", "$", "conditions", "[", "'Mozo.activo'", "]", "=", "1", ";", "}", "// traer solo las mesas actualizadas luego del ultimo pedido", "$", "conditionsMesa", "=", "array", "(", "'OR'", "=>", "array", "(", "array", "(", "'Mesa.deleted'", "=>", "1", ",", "'Mesa.deleted_date >='", "=>", "$", "lastAccess", ",", ")", ",", "array", "(", "'Mesa.estado_id'", "=>", "MESA_CHECKOUT", ",", "'Mesa.checkout >='", "=>", "$", "lastAccess", ",", ")", ")", ")", ";", "$", "contain", "=", "$", "this", "->", "Mesa", "->", "defaultContain", ";", "$", "contain", "[", "'conditions'", "]", "=", "$", "conditionsMesa", ";", "unset", "(", "$", "contain", "[", "0", "]", ")", ";", "// saco al Mozo del contain", "$", "optionsCreated", "=", "array", "(", "'contain'", "=>", "array", "(", "'Mesa'", "=>", "$", "contain", ")", ",", "'conditions'", "=>", "$", "conditions", ",", ")", ";", "$", "mesasABM", "=", "$", "this", "->", "find", "(", "'all'", ",", "$", "optionsCreated", ")", ";", "$", "mozosMesa", "=", "array", "(", ")", ";", "foreach", "(", "$", "mesasABM", "as", "$", "abmMesas", ")", "{", "// traer todos los mozos, con su array de mesas", "$", "abmMesas", "[", "'Mozo'", "]", "[", "'mesas'", "]", "=", "$", "abmMesas", "[", "'Mesa'", "]", ";", "// enviar solo los que tienen mesas borradas", "if", "(", "!", "empty", "(", "$", "abmMesas", "[", "'Mesa'", "]", ")", ")", "{", "$", "mozosMesa", "[", "'mozos'", "]", "[", "]", "=", "$", "abmMesas", "[", "'Mozo'", "]", ";", "}", "}", "return", "$", "mozosMesa", ";", "}" ]
Para todos los mozos activos, me trae sus mesas eliminadas entre cada actualizacion de datos @param int $mozo_id id del mozo, en caso de que no le pase ninguno, me busca todos @return array Mozos con sus mesas, Comandas, detalleComanda, productos y sabores
[ "Para", "todos", "los", "mozos", "activos", "me", "trae", "sus", "mesas", "eliminadas", "entre", "cada", "actualizacion", "de", "datos" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Mesa/Model/Mozo.php#L171-L223
weew/http
src/Weew/Http/Data/JsonData.php
JsonData.pick
public function pick(array $keys) { $data = []; foreach ($keys as $key) { array_set($data, $key, $this->get($key)); } return $data; }
php
public function pick(array $keys) { $data = []; foreach ($keys as $key) { array_set($data, $key, $this->get($key)); } return $data; }
[ "public", "function", "pick", "(", "array", "$", "keys", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "array_set", "(", "$", "data", ",", "$", "key", ",", "$", "this", "->", "get", "(", "$", "key", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
@param array $keys @return array
[ "@param", "array", "$keys" ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/Data/JsonData.php#L56-L64
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
DocBlockConverter.convert
public function convert(\DOMElement $parent, DescriptorAbstract $element) { $child = new \DOMElement('docblock'); $parent->appendChild($child); $child->setAttribute('line', $element->getLine()); $package = str_replace('&', '&amp;', ltrim($element->getPackage(), '\\')); $parent->setAttribute('package', $package ?: 'global'); $this->addSummary($child, $element); $this->addDescription($child, $element); $this->addTags($child, $element); $this->addInheritedFromTag($child, $element); return $child; }
php
public function convert(\DOMElement $parent, DescriptorAbstract $element) { $child = new \DOMElement('docblock'); $parent->appendChild($child); $child->setAttribute('line', $element->getLine()); $package = str_replace('&', '&amp;', ltrim($element->getPackage(), '\\')); $parent->setAttribute('package', $package ?: 'global'); $this->addSummary($child, $element); $this->addDescription($child, $element); $this->addTags($child, $element); $this->addInheritedFromTag($child, $element); return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "DescriptorAbstract", "$", "element", ")", "{", "$", "child", "=", "new", "\\", "DOMElement", "(", "'docblock'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "$", "element", "->", "getLine", "(", ")", ")", ";", "$", "package", "=", "str_replace", "(", "'&'", ",", "'&amp;'", ",", "ltrim", "(", "$", "element", "->", "getPackage", "(", ")", ",", "'\\\\'", ")", ")", ";", "$", "parent", "->", "setAttribute", "(", "'package'", ",", "$", "package", "?", ":", "'global'", ")", ";", "$", "this", "->", "addSummary", "(", "$", "child", ",", "$", "element", ")", ";", "$", "this", "->", "addDescription", "(", "$", "child", ",", "$", "element", ")", ";", "$", "this", "->", "addTags", "(", "$", "child", ",", "$", "element", ")", ";", "$", "this", "->", "addInheritedFromTag", "(", "$", "child", ",", "$", "element", ")", ";", "return", "$", "child", ";", "}" ]
Exports the given reflection object to the parent XML element. This method creates a new child element on the given parent XML element and takes the properties of the Reflection argument and sets the elements and attributes on the child. If a child DOMElement is provided then the properties and attributes are set on this but the child element is not appended onto the parent. This is the responsibility of the invoker. Essentially this means that the $parent argument is ignored in this case. @param \DOMElement $parent The parent element to augment. @param DescriptorAbstract $element The data source. @return \DOMElement
[ "Exports", "the", "given", "reflection", "object", "to", "the", "parent", "XML", "element", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L59-L74
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
DocBlockConverter.addDescription
protected function addDescription(\DOMElement $node, DescriptorAbstract $element) { $node->appendChild(new \DOMElement('long-description')) ->appendChild(new \DOMText($element->getDescription())); }
php
protected function addDescription(\DOMElement $node, DescriptorAbstract $element) { $node->appendChild(new \DOMElement('long-description')) ->appendChild(new \DOMText($element->getDescription())); }
[ "protected", "function", "addDescription", "(", "\\", "DOMElement", "$", "node", ",", "DescriptorAbstract", "$", "element", ")", "{", "$", "node", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'long-description'", ")", ")", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "$", "element", "->", "getDescription", "(", ")", ")", ")", ";", "}" ]
Adds the DocBlock's long description to the $child element, @param \DOMElement $node @param DescriptorAbstract $element @return void
[ "Adds", "the", "DocBlock", "s", "long", "description", "to", "the", "$child", "element" ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L99-L103
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php
DocBlockConverter.addInheritedFromTag
protected function addInheritedFromTag(\DOMElement $docBlock, $descriptor) { $parentElement = $descriptor->getInheritedElement(); if (! $parentElement instanceof $descriptor) { return; } $child = new \DOMElement('tag'); $docBlock->appendChild($child); $rule = $this->router->match($parentElement); $child->setAttribute('name', 'inherited_from'); $child->setAttribute('description', $parentElement->getFullyQualifiedStructuralElementName()); $child->setAttribute('refers', $parentElement->getFullyQualifiedStructuralElementName()); $child->setAttribute('link', $rule ? $rule->generate($parentElement) : ''); }
php
protected function addInheritedFromTag(\DOMElement $docBlock, $descriptor) { $parentElement = $descriptor->getInheritedElement(); if (! $parentElement instanceof $descriptor) { return; } $child = new \DOMElement('tag'); $docBlock->appendChild($child); $rule = $this->router->match($parentElement); $child->setAttribute('name', 'inherited_from'); $child->setAttribute('description', $parentElement->getFullyQualifiedStructuralElementName()); $child->setAttribute('refers', $parentElement->getFullyQualifiedStructuralElementName()); $child->setAttribute('link', $rule ? $rule->generate($parentElement) : ''); }
[ "protected", "function", "addInheritedFromTag", "(", "\\", "DOMElement", "$", "docBlock", ",", "$", "descriptor", ")", "{", "$", "parentElement", "=", "$", "descriptor", "->", "getInheritedElement", "(", ")", ";", "if", "(", "!", "$", "parentElement", "instanceof", "$", "descriptor", ")", "{", "return", ";", "}", "$", "child", "=", "new", "\\", "DOMElement", "(", "'tag'", ")", ";", "$", "docBlock", "->", "appendChild", "(", "$", "child", ")", ";", "$", "rule", "=", "$", "this", "->", "router", "->", "match", "(", "$", "parentElement", ")", ";", "$", "child", "->", "setAttribute", "(", "'name'", ",", "'inherited_from'", ")", ";", "$", "child", "->", "setAttribute", "(", "'description'", ",", "$", "parentElement", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'refers'", ",", "$", "parentElement", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'link'", ",", "$", "rule", "?", "$", "rule", "->", "generate", "(", "$", "parentElement", ")", ":", "''", ")", ";", "}" ]
Adds the 'inherited_from' tag when a Descriptor inherits from another Descriptor. @param \DOMElement $docBlock @param DescriptorAbstract $descriptor @return void
[ "Adds", "the", "inherited_from", "tag", "when", "a", "Descriptor", "inherits", "from", "another", "Descriptor", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/DocBlockConverter.php#L137-L153
frdl/webfan
.ApplicationComposer/lib/webdof/valFormats.php
valFormats._isuuidversion
protected function _isuuidversion($in, $strict = true) { if(false !== $strict) { $in = strtolower($in ); $alphanums = "a-f"; }else{ $alphanums = "a-z"; } if(!preg_match("/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i",$in, $matches) )return false; $version = $matches['version']; if(false !== $strict && (empty($version) || !$this->_isint($version) || intval($version)<1 || intval($version)> 6))return false; return $version; }
php
protected function _isuuidversion($in, $strict = true) { if(false !== $strict) { $in = strtolower($in ); $alphanums = "a-f"; }else{ $alphanums = "a-z"; } if(!preg_match("/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i",$in, $matches) )return false; $version = $matches['version']; if(false !== $strict && (empty($version) || !$this->_isint($version) || intval($version)<1 || intval($version)> 6))return false; return $version; }
[ "protected", "function", "_isuuidversion", "(", "$", "in", ",", "$", "strict", "=", "true", ")", "{", "if", "(", "false", "!==", "$", "strict", ")", "{", "$", "in", "=", "strtolower", "(", "$", "in", ")", ";", "$", "alphanums", "=", "\"a-f\"", ";", "}", "else", "{", "$", "alphanums", "=", "\"a-z\"", ";", "}", "if", "(", "!", "preg_match", "(", "\"/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i\"", ",", "$", "in", ",", "$", "matches", ")", ")", "return", "false", ";", "$", "version", "=", "$", "matches", "[", "'version'", "]", ";", "if", "(", "false", "!==", "$", "strict", "&&", "(", "empty", "(", "$", "version", ")", "||", "!", "$", "this", "->", "_isint", "(", "$", "version", ")", "||", "intval", "(", "$", "version", ")", "<", "1", "||", "intval", "(", "$", "version", ")", ">", "6", ")", ")", "return", "false", ";", "return", "$", "version", ";", "}" ]
returns UUID version or FALSE if no UUID format
[ "returns", "UUID", "version", "or", "FALSE", "if", "no", "UUID", "format" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/valFormats.php#L892-L909
frdl/webfan
.ApplicationComposer/lib/webdof/valFormats.php
valFormats._camelcase2whitespace
protected function _camelcase2whitespace($camelCaseString, $space = " "){ $re = '/(?<=[a-z])(?=[A-Z])/x'; $a = preg_split($re, $camelCaseString); return join($a, $space); }
php
protected function _camelcase2whitespace($camelCaseString, $space = " "){ $re = '/(?<=[a-z])(?=[A-Z])/x'; $a = preg_split($re, $camelCaseString); return join($a, $space); }
[ "protected", "function", "_camelcase2whitespace", "(", "$", "camelCaseString", ",", "$", "space", "=", "\" \"", ")", "{", "$", "re", "=", "'/(?<=[a-z])(?=[A-Z])/x'", ";", "$", "a", "=", "preg_split", "(", "$", "re", ",", "$", "camelCaseString", ")", ";", "return", "join", "(", "$", "a", ",", "$", "space", ")", ";", "}" ]
http://stackoverflow.com/questions/4519739/split-camelcase-word-into-words-with-php-preg-match-regular-expression Converts camelCase string to have spaces between each. @param $camelCaseString @return string
[ "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "4519739", "/", "split", "-", "camelcase", "-", "word", "-", "into", "-", "words", "-", "with", "-", "php", "-", "preg", "-", "match", "-", "regular", "-", "expression", "Converts", "camelCase", "string", "to", "have", "spaces", "between", "each", "." ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/valFormats.php#L1018-L1022
frdl/webfan
.ApplicationComposer/lib/webdof/valFormats.php
valFormats._ip2long
protected function _ip2long($ip, $getVersion = TRUE) { $version = $this->_isip($ip); if($getVersion === FALSE && $version === FALSE)return FALSE; if($getVersion === FALSE && $version === 'ipv4')return $this->_ip2long_v4($ip); if($getVersion === FALSE && $version === 'ipv6')return $this->_ip2long_v6($ip); if($getVersion === TRUE && $version === FALSE)return array('version' => FALSE, 'int' => FALSE); if($getVersion === TRUE && $version === 'ipv4')return array('version' => $version, 'int' => $this->_ip2long_v4($ip)); if($getVersion === TRUE && $version === 'ipv6')return array('version' => $version, 'int' => $this->_ip2long_v6($ip)); return trigger_error('inalid argument getVersion in ipFormat::ip2long()!', E_USER_ERROR); }
php
protected function _ip2long($ip, $getVersion = TRUE) { $version = $this->_isip($ip); if($getVersion === FALSE && $version === FALSE)return FALSE; if($getVersion === FALSE && $version === 'ipv4')return $this->_ip2long_v4($ip); if($getVersion === FALSE && $version === 'ipv6')return $this->_ip2long_v6($ip); if($getVersion === TRUE && $version === FALSE)return array('version' => FALSE, 'int' => FALSE); if($getVersion === TRUE && $version === 'ipv4')return array('version' => $version, 'int' => $this->_ip2long_v4($ip)); if($getVersion === TRUE && $version === 'ipv6')return array('version' => $version, 'int' => $this->_ip2long_v6($ip)); return trigger_error('inalid argument getVersion in ipFormat::ip2long()!', E_USER_ERROR); }
[ "protected", "function", "_ip2long", "(", "$", "ip", ",", "$", "getVersion", "=", "TRUE", ")", "{", "$", "version", "=", "$", "this", "->", "_isip", "(", "$", "ip", ")", ";", "if", "(", "$", "getVersion", "===", "FALSE", "&&", "$", "version", "===", "FALSE", ")", "return", "FALSE", ";", "if", "(", "$", "getVersion", "===", "FALSE", "&&", "$", "version", "===", "'ipv4'", ")", "return", "$", "this", "->", "_ip2long_v4", "(", "$", "ip", ")", ";", "if", "(", "$", "getVersion", "===", "FALSE", "&&", "$", "version", "===", "'ipv6'", ")", "return", "$", "this", "->", "_ip2long_v6", "(", "$", "ip", ")", ";", "if", "(", "$", "getVersion", "===", "TRUE", "&&", "$", "version", "===", "FALSE", ")", "return", "array", "(", "'version'", "=>", "FALSE", ",", "'int'", "=>", "FALSE", ")", ";", "if", "(", "$", "getVersion", "===", "TRUE", "&&", "$", "version", "===", "'ipv4'", ")", "return", "array", "(", "'version'", "=>", "$", "version", ",", "'int'", "=>", "$", "this", "->", "_ip2long_v4", "(", "$", "ip", ")", ")", ";", "if", "(", "$", "getVersion", "===", "TRUE", "&&", "$", "version", "===", "'ipv6'", ")", "return", "array", "(", "'version'", "=>", "$", "version", ",", "'int'", "=>", "$", "this", "->", "_ip2long_v6", "(", "$", "ip", ")", ")", ";", "return", "trigger_error", "(", "'inalid argument getVersion in ipFormat::ip2long()!'", ",", "E_USER_ERROR", ")", ";", "}" ]
IP Addresses... - php.net
[ "IP", "Addresses", "...", "-", "php", ".", "net" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/valFormats.php#L1038-L1050
WellCommerce/StandardEditionBundle
DataFixtures/ORM/LoadMediaData.php
LoadMediaData.load
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } $rootPath = $this->container->get('kernel')->getRootDir() . '/../web/themes/wellcommerce-default-theme/assets/products/'; $uploader = $this->container->get('media.uploader'); $uploadPath = $uploader->getUploadDir('images'); $filesystem = $this->container->get('filesystem'); foreach (self::$samples as $photo) { $image = new UploadedFile( $rootPath . $photo, $photo, 'image/jpeg', filesize($rootPath . $photo) ); $media = new Media(); $media->setName($image->getClientOriginalName()); $media->setExtension($image->guessClientExtension()); $media->setMime($image->getClientMimeType()); $media->setSize($image->getClientSize()); $manager->persist($media); $filesystem->copy($rootPath . $photo, $uploadPath . '/' . $media->getPath()); $this->setReference('photo_' . $photo, $media); } $manager->flush(); }
php
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } $rootPath = $this->container->get('kernel')->getRootDir() . '/../web/themes/wellcommerce-default-theme/assets/products/'; $uploader = $this->container->get('media.uploader'); $uploadPath = $uploader->getUploadDir('images'); $filesystem = $this->container->get('filesystem'); foreach (self::$samples as $photo) { $image = new UploadedFile( $rootPath . $photo, $photo, 'image/jpeg', filesize($rootPath . $photo) ); $media = new Media(); $media->setName($image->getClientOriginalName()); $media->setExtension($image->guessClientExtension()); $media->setMime($image->getClientMimeType()); $media->setSize($image->getClientSize()); $manager->persist($media); $filesystem->copy($rootPath . $photo, $uploadPath . '/' . $media->getPath()); $this->setReference('photo_' . $photo, $media); } $manager->flush(); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "rootPath", "=", "$", "this", "->", "container", "->", "get", "(", "'kernel'", ")", "->", "getRootDir", "(", ")", ".", "'/../web/themes/wellcommerce-default-theme/assets/products/'", ";", "$", "uploader", "=", "$", "this", "->", "container", "->", "get", "(", "'media.uploader'", ")", ";", "$", "uploadPath", "=", "$", "uploader", "->", "getUploadDir", "(", "'images'", ")", ";", "$", "filesystem", "=", "$", "this", "->", "container", "->", "get", "(", "'filesystem'", ")", ";", "foreach", "(", "self", "::", "$", "samples", "as", "$", "photo", ")", "{", "$", "image", "=", "new", "UploadedFile", "(", "$", "rootPath", ".", "$", "photo", ",", "$", "photo", ",", "'image/jpeg'", ",", "filesize", "(", "$", "rootPath", ".", "$", "photo", ")", ")", ";", "$", "media", "=", "new", "Media", "(", ")", ";", "$", "media", "->", "setName", "(", "$", "image", "->", "getClientOriginalName", "(", ")", ")", ";", "$", "media", "->", "setExtension", "(", "$", "image", "->", "guessClientExtension", "(", ")", ")", ";", "$", "media", "->", "setMime", "(", "$", "image", "->", "getClientMimeType", "(", ")", ")", ";", "$", "media", "->", "setSize", "(", "$", "image", "->", "getClientSize", "(", ")", ")", ";", "$", "manager", "->", "persist", "(", "$", "media", ")", ";", "$", "filesystem", "->", "copy", "(", "$", "rootPath", ".", "$", "photo", ",", "$", "uploadPath", ".", "'/'", ".", "$", "media", "->", "getPath", "(", ")", ")", ";", "$", "this", "->", "setReference", "(", "'photo_'", ".", "$", "photo", ",", "$", "media", ")", ";", "}", "$", "manager", "->", "flush", "(", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadMediaData.php#L44-L74
Baachi/CouchDB
src/CouchDB/Util/BatchUpdater.php
BatchUpdater.execute
public function execute() { $response = $this->client->request('POST', "/{$this->database->getName()}/_bulk_docs", [ 'body' => JSONEncoder::encode($this->data), 'headers' => ['Content-Type' => 'application/json'], ]); return JSONEncoder::decode((string) $response->getBody()); }
php
public function execute() { $response = $this->client->request('POST', "/{$this->database->getName()}/_bulk_docs", [ 'body' => JSONEncoder::encode($this->data), 'headers' => ['Content-Type' => 'application/json'], ]); return JSONEncoder::decode((string) $response->getBody()); }
[ "public", "function", "execute", "(", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "\"/{$this->database->getName()}/_bulk_docs\"", ",", "[", "'body'", "=>", "JSONEncoder", "::", "encode", "(", "$", "this", "->", "data", ")", ",", "'headers'", "=>", "[", "'Content-Type'", "=>", "'application/json'", "]", ",", "]", ")", ";", "return", "JSONEncoder", "::", "decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ")", ";", "}" ]
Execute the queue. @return array
[ "Execute", "the", "queue", "." ]
train
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Util/BatchUpdater.php#L77-L85
Humanized/yii2-location
models/nuts/NutsLocationSearch.php
NutsLocationSearch.search
public function search($params) { $this->load($params); $query = NutsLocation::find(); $query->where(['country_id'=>$this->country_id,'postcode'=>$this->postcode,]); $this->pageSize = 1; $dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => ($this->pagination ? [ 'pageSize' => $this->pageSize, ] : FALSE), 'sort' => [ 'attributes' => [ 'postcode' ], ] ]); return $dataProvider; }
php
public function search($params) { $this->load($params); $query = NutsLocation::find(); $query->where(['country_id'=>$this->country_id,'postcode'=>$this->postcode,]); $this->pageSize = 1; $dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => ($this->pagination ? [ 'pageSize' => $this->pageSize, ] : FALSE), 'sort' => [ 'attributes' => [ 'postcode' ], ] ]); return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "this", "->", "load", "(", "$", "params", ")", ";", "$", "query", "=", "NutsLocation", "::", "find", "(", ")", ";", "$", "query", "->", "where", "(", "[", "'country_id'", "=>", "$", "this", "->", "country_id", ",", "'postcode'", "=>", "$", "this", "->", "postcode", ",", "]", ")", ";", "$", "this", "->", "pageSize", "=", "1", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", "'pagination'", "=>", "(", "$", "this", "->", "pagination", "?", "[", "'pageSize'", "=>", "$", "this", "->", "pageSize", ",", "]", ":", "FALSE", ")", ",", "'sort'", "=>", "[", "'attributes'", "=>", "[", "'postcode'", "]", ",", "]", "]", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Creates data provider instance with search query applied @param array $params @return ActiveDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/Humanized/yii2-location/blob/48ac12ceab741fc4c82ac8e979415a11bf9175f2/models/nuts/NutsLocationSearch.php#L46-L70
NuclearCMS/Hierarchy
src/Support/migrations/2016_07_31_120003_HierarchyCreateNodesTable.php
HierarchyCreateNodesTable.up
public function up() { Schema::create('nodes', function (Blueprint $table) { $table->increments('id'); $table->integer('node_type_id')->unsigned(); $table->integer('user_id')->unsigned(); NestedSet::columns($table); $table->boolean('mailing')->default(0); $table->boolean('visible')->default(1); $table->boolean('sterile')->default(0); $table->boolean('home')->default(0); $table->boolean('locked')->default(0); $table->integer('status')->default(30); $table->boolean('hides_children')->default(0); $table->double('priority')->unsigned()->default(1); $table->timestamp('published_at')->nullable(); $table->string('children_order')->default('_lft'); $table->string('children_order_direction', 4)->default('asc'); $table->enum('children_display_mode', ['tree', 'list'])->default('list'); $table->timestamps(); $table->index('mailing'); $table->index('home'); $table->index('node_type_id'); $table->foreign('node_type_id') ->references('id') ->on('node_types') ->onDelete('cascade'); $table->foreign('user_id') ->references('id') ->on('users'); }); }
php
public function up() { Schema::create('nodes', function (Blueprint $table) { $table->increments('id'); $table->integer('node_type_id')->unsigned(); $table->integer('user_id')->unsigned(); NestedSet::columns($table); $table->boolean('mailing')->default(0); $table->boolean('visible')->default(1); $table->boolean('sterile')->default(0); $table->boolean('home')->default(0); $table->boolean('locked')->default(0); $table->integer('status')->default(30); $table->boolean('hides_children')->default(0); $table->double('priority')->unsigned()->default(1); $table->timestamp('published_at')->nullable(); $table->string('children_order')->default('_lft'); $table->string('children_order_direction', 4)->default('asc'); $table->enum('children_display_mode', ['tree', 'list'])->default('list'); $table->timestamps(); $table->index('mailing'); $table->index('home'); $table->index('node_type_id'); $table->foreign('node_type_id') ->references('id') ->on('node_types') ->onDelete('cascade'); $table->foreign('user_id') ->references('id') ->on('users'); }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "'nodes'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "increments", "(", "'id'", ")", ";", "$", "table", "->", "integer", "(", "'node_type_id'", ")", "->", "unsigned", "(", ")", ";", "$", "table", "->", "integer", "(", "'user_id'", ")", "->", "unsigned", "(", ")", ";", "NestedSet", "::", "columns", "(", "$", "table", ")", ";", "$", "table", "->", "boolean", "(", "'mailing'", ")", "->", "default", "(", "0", ")", ";", "$", "table", "->", "boolean", "(", "'visible'", ")", "->", "default", "(", "1", ")", ";", "$", "table", "->", "boolean", "(", "'sterile'", ")", "->", "default", "(", "0", ")", ";", "$", "table", "->", "boolean", "(", "'home'", ")", "->", "default", "(", "0", ")", ";", "$", "table", "->", "boolean", "(", "'locked'", ")", "->", "default", "(", "0", ")", ";", "$", "table", "->", "integer", "(", "'status'", ")", "->", "default", "(", "30", ")", ";", "$", "table", "->", "boolean", "(", "'hides_children'", ")", "->", "default", "(", "0", ")", ";", "$", "table", "->", "double", "(", "'priority'", ")", "->", "unsigned", "(", ")", "->", "default", "(", "1", ")", ";", "$", "table", "->", "timestamp", "(", "'published_at'", ")", "->", "nullable", "(", ")", ";", "$", "table", "->", "string", "(", "'children_order'", ")", "->", "default", "(", "'_lft'", ")", ";", "$", "table", "->", "string", "(", "'children_order_direction'", ",", "4", ")", "->", "default", "(", "'asc'", ")", ";", "$", "table", "->", "enum", "(", "'children_display_mode'", ",", "[", "'tree'", ",", "'list'", "]", ")", "->", "default", "(", "'list'", ")", ";", "$", "table", "->", "timestamps", "(", ")", ";", "$", "table", "->", "index", "(", "'mailing'", ")", ";", "$", "table", "->", "index", "(", "'home'", ")", ";", "$", "table", "->", "index", "(", "'node_type_id'", ")", ";", "$", "table", "->", "foreign", "(", "'node_type_id'", ")", "->", "references", "(", "'id'", ")", "->", "on", "(", "'node_types'", ")", "->", "onDelete", "(", "'cascade'", ")", ";", "$", "table", "->", "foreign", "(", "'user_id'", ")", "->", "references", "(", "'id'", ")", "->", "on", "(", "'users'", ")", ";", "}", ")", ";", "}" ]
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Support/migrations/2016_07_31_120003_HierarchyCreateNodesTable.php#L14-L53
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Scrybe/Template/Factory.php
Factory.get
public function get($name) { if (!isset($this->engines[$name])) { throw new \InvalidArgumentException('Template engine "'.$name.'" is not known or registered'); } return $this->engines[$name]; }
php
public function get($name) { if (!isset($this->engines[$name])) { throw new \InvalidArgumentException('Template engine "'.$name.'" is not known or registered'); } return $this->engines[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "engines", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Template engine \"'", ".", "$", "name", ".", "'\" is not known or registered'", ")", ";", "}", "return", "$", "this", "->", "engines", "[", "$", "name", "]", ";", "}" ]
Returns a new instance of the template engine belonging to the given name. @param string $name @throws \InvalidArgumentException if the given name is not registered @return TemplateInterface
[ "Returns", "a", "new", "instance", "of", "the", "template", "engine", "belonging", "to", "the", "given", "name", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Template/Factory.php#L66-L73
Josantonius/WP_Image
src/class-wp-image.php
WP_Image.save
public static function save( $url, $post_ID, $featured = false ) { $url = filter_var( $url, FILTER_VALIDATE_URL ); if ( false === $url || false === get_post_status( $post_ID ) ) { return false; } $filename = basename( $url ); $filepath = self::upload( $url, $filename ); $attachment = [ 'post_mime_type' => wp_check_filetype( $filename, null )['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', 'post_status' => 'inherit', ]; $attach_id = wp_insert_attachment( $attachment, $filepath, $post_ID ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath ); wp_update_attachment_metadata( $attach_id, $attach_data ); if ( $featured ) { set_post_thumbnail( $post_ID, $attach_id ); } return wp_get_attachment_url( $attach_id ); }
php
public static function save( $url, $post_ID, $featured = false ) { $url = filter_var( $url, FILTER_VALIDATE_URL ); if ( false === $url || false === get_post_status( $post_ID ) ) { return false; } $filename = basename( $url ); $filepath = self::upload( $url, $filename ); $attachment = [ 'post_mime_type' => wp_check_filetype( $filename, null )['type'], 'post_title' => sanitize_file_name( $filename ), 'post_content' => '', 'post_status' => 'inherit', ]; $attach_id = wp_insert_attachment( $attachment, $filepath, $post_ID ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath ); wp_update_attachment_metadata( $attach_id, $attach_data ); if ( $featured ) { set_post_thumbnail( $post_ID, $attach_id ); } return wp_get_attachment_url( $attach_id ); }
[ "public", "static", "function", "save", "(", "$", "url", ",", "$", "post_ID", ",", "$", "featured", "=", "false", ")", "{", "$", "url", "=", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ")", ";", "if", "(", "false", "===", "$", "url", "||", "false", "===", "get_post_status", "(", "$", "post_ID", ")", ")", "{", "return", "false", ";", "}", "$", "filename", "=", "basename", "(", "$", "url", ")", ";", "$", "filepath", "=", "self", "::", "upload", "(", "$", "url", ",", "$", "filename", ")", ";", "$", "attachment", "=", "[", "'post_mime_type'", "=>", "wp_check_filetype", "(", "$", "filename", ",", "null", ")", "[", "'type'", "]", ",", "'post_title'", "=>", "sanitize_file_name", "(", "$", "filename", ")", ",", "'post_content'", "=>", "''", ",", "'post_status'", "=>", "'inherit'", ",", "]", ";", "$", "attach_id", "=", "wp_insert_attachment", "(", "$", "attachment", ",", "$", "filepath", ",", "$", "post_ID", ")", ";", "require_once", "(", "ABSPATH", ".", "'wp-admin/includes/image.php'", ")", ";", "$", "attach_data", "=", "wp_generate_attachment_metadata", "(", "$", "attach_id", ",", "$", "filepath", ")", ";", "wp_update_attachment_metadata", "(", "$", "attach_id", ",", "$", "attach_data", ")", ";", "if", "(", "$", "featured", ")", "{", "set_post_thumbnail", "(", "$", "post_ID", ",", "$", "attach_id", ")", ";", "}", "return", "wp_get_attachment_url", "(", "$", "attach_id", ")", ";", "}" ]
Save image and associate it with a specific post. @param string $url → external url image. @param int $post_ID → post id. @param boolean $featured → if image is featured. @return string|false → URI for an attachment file or false on failure.
[ "Save", "image", "and", "associate", "it", "with", "a", "specific", "post", "." ]
train
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L31-L62
Josantonius/WP_Image
src/class-wp-image.php
WP_Image.upload
public static function upload( $url, $filename ) { $dir = wp_upload_dir(); if ( ! isset( $dir['path'], $dir['basedir'] ) ) { return false; } $path = wp_mkdir_p( $dir['path'] ) ? $dir['path'] : $dir['basedir']; $path = rtrim( $path, '/' ) . '/'; $image_data = @file_get_contents( $url ); if ( $image_data ) { $state = @file_put_contents( $path . $filename, $image_data ); } return ( isset( $state ) && $state ) ? $path . $filename : false; }
php
public static function upload( $url, $filename ) { $dir = wp_upload_dir(); if ( ! isset( $dir['path'], $dir['basedir'] ) ) { return false; } $path = wp_mkdir_p( $dir['path'] ) ? $dir['path'] : $dir['basedir']; $path = rtrim( $path, '/' ) . '/'; $image_data = @file_get_contents( $url ); if ( $image_data ) { $state = @file_put_contents( $path . $filename, $image_data ); } return ( isset( $state ) && $state ) ? $path . $filename : false; }
[ "public", "static", "function", "upload", "(", "$", "url", ",", "$", "filename", ")", "{", "$", "dir", "=", "wp_upload_dir", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "dir", "[", "'path'", "]", ",", "$", "dir", "[", "'basedir'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "path", "=", "wp_mkdir_p", "(", "$", "dir", "[", "'path'", "]", ")", "?", "$", "dir", "[", "'path'", "]", ":", "$", "dir", "[", "'basedir'", "]", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "$", "image_data", "=", "@", "file_get_contents", "(", "$", "url", ")", ";", "if", "(", "$", "image_data", ")", "{", "$", "state", "=", "@", "file_put_contents", "(", "$", "path", ".", "$", "filename", ",", "$", "image_data", ")", ";", "}", "return", "(", "isset", "(", "$", "state", ")", "&&", "$", "state", ")", "?", "$", "path", ".", "$", "filename", ":", "false", ";", "}" ]
Upload image to WordPress upload directory. @since 1.0.2 @param string $url → external url image. @param string $filename → filename. @return string|false → path to upload image or false on failure.
[ "Upload", "image", "to", "WordPress", "upload", "directory", "." ]
train
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L74-L92
Josantonius/WP_Image
src/class-wp-image.php
WP_Image.delete_all_attachment
public static function delete_all_attachment( $post_ID, $force = false ) { if ( get_post_status( $post_ID ) === false ) { return false; } $counter = 0; $attachments = get_posts( [ 'post_type' => 'attachment', 'posts_per_page' => 100, 'post_status' => 'any', 'post_mime_type' => 'image/jpeg, image/png, image/gif', 'post_parent' => $post_ID, ] ); foreach ( $attachments as $attachment ) { if ( wp_delete_attachment( $attachment->ID, $force ) !== false ) { $counter++; } } return $counter; }
php
public static function delete_all_attachment( $post_ID, $force = false ) { if ( get_post_status( $post_ID ) === false ) { return false; } $counter = 0; $attachments = get_posts( [ 'post_type' => 'attachment', 'posts_per_page' => 100, 'post_status' => 'any', 'post_mime_type' => 'image/jpeg, image/png, image/gif', 'post_parent' => $post_ID, ] ); foreach ( $attachments as $attachment ) { if ( wp_delete_attachment( $attachment->ID, $force ) !== false ) { $counter++; } } return $counter; }
[ "public", "static", "function", "delete_all_attachment", "(", "$", "post_ID", ",", "$", "force", "=", "false", ")", "{", "if", "(", "get_post_status", "(", "$", "post_ID", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "counter", "=", "0", ";", "$", "attachments", "=", "get_posts", "(", "[", "'post_type'", "=>", "'attachment'", ",", "'posts_per_page'", "=>", "100", ",", "'post_status'", "=>", "'any'", ",", "'post_mime_type'", "=>", "'image/jpeg, image/png, image/gif'", ",", "'post_parent'", "=>", "$", "post_ID", ",", "]", ")", ";", "foreach", "(", "$", "attachments", "as", "$", "attachment", ")", "{", "if", "(", "wp_delete_attachment", "(", "$", "attachment", "->", "ID", ",", "$", "force", ")", "!==", "false", ")", "{", "$", "counter", "++", ";", "}", "}", "return", "$", "counter", ";", "}" ]
Deletes an attachment and all of its derivatives. @since 1.0.3 @param int $post_ID → post id. @param boolean $force → force deletion. @return int|false → attachments deleted.
[ "Deletes", "an", "attachment", "and", "all", "of", "its", "derivatives", "." ]
train
https://github.com/Josantonius/WP_Image/blob/59a2b7bb79db81e70d7b6c3eb3a5ce603c20e204/src/class-wp-image.php#L104-L129
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.delete
public function delete($id) { $this->fireEvent('deleting', [$id]); $deleted = $this->model->destroy($id); $this->fireEvent('deleted', [$id, $deleted]); return $deleted; }
php
public function delete($id) { $this->fireEvent('deleting', [$id]); $deleted = $this->model->destroy($id); $this->fireEvent('deleted', [$id, $deleted]); return $deleted; }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "this", "->", "fireEvent", "(", "'deleting'", ",", "[", "$", "id", "]", ")", ";", "$", "deleted", "=", "$", "this", "->", "model", "->", "destroy", "(", "$", "id", ")", ";", "$", "this", "->", "fireEvent", "(", "'deleted'", ",", "[", "$", "id", ",", "$", "deleted", "]", ")", ";", "return", "$", "deleted", ";", "}" ]
Find and delete a resource by ID. @param int $id @return bool
[ "Find", "and", "delete", "a", "resource", "by", "ID", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L68-L77
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.getAll
public function getAll($orderBy = array('id', 'asc')) { list($column, $order) = $orderBy; return $this->newQuery()->orderBy($column, $order)->get(); }
php
public function getAll($orderBy = array('id', 'asc')) { list($column, $order) = $orderBy; return $this->newQuery()->orderBy($column, $order)->get(); }
[ "public", "function", "getAll", "(", "$", "orderBy", "=", "array", "(", "'id'", ",", "'asc'", ")", ")", "{", "list", "(", "$", "column", ",", "$", "order", ")", "=", "$", "orderBy", ";", "return", "$", "this", "->", "newQuery", "(", ")", "->", "orderBy", "(", "$", "column", ",", "$", "order", ")", "->", "get", "(", ")", ";", "}" ]
Get all resources. @param array $orderBy @return mixed
[ "Get", "all", "resources", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L117-L122
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.getAllPaginated
public function getAllPaginated($orderBy = array('id', 'asc'), $perPage = 25) { list($column, $order) = $orderBy; return $this->newQuery()->orderBy($column, $order)->paginate($perPage); }
php
public function getAllPaginated($orderBy = array('id', 'asc'), $perPage = 25) { list($column, $order) = $orderBy; return $this->newQuery()->orderBy($column, $order)->paginate($perPage); }
[ "public", "function", "getAllPaginated", "(", "$", "orderBy", "=", "array", "(", "'id'", ",", "'asc'", ")", ",", "$", "perPage", "=", "25", ")", "{", "list", "(", "$", "column", ",", "$", "order", ")", "=", "$", "orderBy", ";", "return", "$", "this", "->", "newQuery", "(", ")", "->", "orderBy", "(", "$", "column", ",", "$", "order", ")", "->", "paginate", "(", "$", "perPage", ")", ";", "}" ]
Get all resources. @param array $orderBy @return mixed
[ "Get", "all", "resources", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L130-L135
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.store
public function store($request) { $this->fireEvent('creating', [$request]); $created = $this->model->create($request); $this->fireEvent('created', [$created]); return $created; }
php
public function store($request) { $this->fireEvent('creating', [$request]); $created = $this->model->create($request); $this->fireEvent('created', [$created]); return $created; }
[ "public", "function", "store", "(", "$", "request", ")", "{", "$", "this", "->", "fireEvent", "(", "'creating'", ",", "[", "$", "request", "]", ")", ";", "$", "created", "=", "$", "this", "->", "model", "->", "create", "(", "$", "request", ")", ";", "$", "this", "->", "fireEvent", "(", "'created'", ",", "[", "$", "created", "]", ")", ";", "return", "$", "created", ";", "}" ]
Store a new resource. @param mixed $request @return mixed
[ "Store", "a", "new", "resource", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L143-L152
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.update
public function update($id, $request) { $this->fireEvent('updating', [$id, $request]); $updated = $this->find($id)->update($request); $this->fireEvent('updated', [$id, $updated]); return $updated; }
php
public function update($id, $request) { $this->fireEvent('updating', [$id, $request]); $updated = $this->find($id)->update($request); $this->fireEvent('updated', [$id, $updated]); return $updated; }
[ "public", "function", "update", "(", "$", "id", ",", "$", "request", ")", "{", "$", "this", "->", "fireEvent", "(", "'updating'", ",", "[", "$", "id", ",", "$", "request", "]", ")", ";", "$", "updated", "=", "$", "this", "->", "find", "(", "$", "id", ")", "->", "update", "(", "$", "request", ")", ";", "$", "this", "->", "fireEvent", "(", "'updated'", ",", "[", "$", "id", ",", "$", "updated", "]", ")", ";", "return", "$", "updated", ";", "}" ]
Update an existing resource. @param int $id @param mixed $request @return mixed
[ "Update", "an", "existing", "resource", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L161-L170
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.with
public function with($relationships) { if (! is_array($relationships)) { $relationships = explode(', ', $relationships); } if (! in_array($relationships, $this->withRelationships)) { foreach ($relationships as $with) { $this->withRelationships[] = $with; } } return $this; }
php
public function with($relationships) { if (! is_array($relationships)) { $relationships = explode(', ', $relationships); } if (! in_array($relationships, $this->withRelationships)) { foreach ($relationships as $with) { $this->withRelationships[] = $with; } } return $this; }
[ "public", "function", "with", "(", "$", "relationships", ")", "{", "if", "(", "!", "is_array", "(", "$", "relationships", ")", ")", "{", "$", "relationships", "=", "explode", "(", "', '", ",", "$", "relationships", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "relationships", ",", "$", "this", "->", "withRelationships", ")", ")", "{", "foreach", "(", "$", "relationships", "as", "$", "with", ")", "{", "$", "this", "->", "withRelationships", "[", "]", "=", "$", "with", ";", "}", "}", "return", "$", "this", ";", "}" ]
Assign eager loading relationships. @param string|array $relationships @return AbstractEloquentRepository
[ "Assign", "eager", "loading", "relationships", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L178-L191
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.newQuery
protected function newQuery() { $query = $this->model->newQuery(); foreach ($this->withRelationships as $relationship) { $query->with($relationship); } return $query; }
php
protected function newQuery() { $query = $this->model->newQuery(); foreach ($this->withRelationships as $relationship) { $query->with($relationship); } return $query; }
[ "protected", "function", "newQuery", "(", ")", "{", "$", "query", "=", "$", "this", "->", "model", "->", "newQuery", "(", ")", ";", "foreach", "(", "$", "this", "->", "withRelationships", "as", "$", "relationship", ")", "{", "$", "query", "->", "with", "(", "$", "relationship", ")", ";", "}", "return", "$", "query", ";", "}" ]
Create a new newQuery instance with eager loaded relationships. @return newQuery
[ "Create", "a", "new", "newQuery", "instance", "with", "eager", "loaded", "relationships", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L232-L241
caffeinated/beverage
src/Repositories/AbstractEloquentRepository.php
AbstractEloquentRepository.fireEvent
protected function fireEvent($event, $data) { $fireableEvent = isset($this->fireEvents[$event]) ? $this->fireEvents[$event] : null; if (! is_null($fireableEvent)) { return $this->event->fire($fireableEvent, $data); } return null; }
php
protected function fireEvent($event, $data) { $fireableEvent = isset($this->fireEvents[$event]) ? $this->fireEvents[$event] : null; if (! is_null($fireableEvent)) { return $this->event->fire($fireableEvent, $data); } return null; }
[ "protected", "function", "fireEvent", "(", "$", "event", ",", "$", "data", ")", "{", "$", "fireableEvent", "=", "isset", "(", "$", "this", "->", "fireEvents", "[", "$", "event", "]", ")", "?", "$", "this", "->", "fireEvents", "[", "$", "event", "]", ":", "null", ";", "if", "(", "!", "is_null", "(", "$", "fireableEvent", ")", ")", "{", "return", "$", "this", "->", "event", "->", "fire", "(", "$", "fireableEvent", ",", "$", "data", ")", ";", "}", "return", "null", ";", "}" ]
Fire off an event if one is defined. @param string $event @param array $data @return mixed
[ "Fire", "off", "an", "event", "if", "one", "is", "defined", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Repositories/AbstractEloquentRepository.php#L250-L259
bpolaszek/simple-dbal
src/Model/Adapter/Mysqli/MysqliAsync.php
MysqliAsync.pollEvery
public static function pollEvery(float $wait) { if (false === strpos((string) $wait, '.')) { self::$sleep = (int) $wait; self::$usleep = 0; } else { list($seconds, $hundreds) = explode('.', (string) $wait); self::$sleep = (int) $seconds; self::$usleep = (int) (((float) sprintf('0.%d', $hundreds)) * 1000000); } }
php
public static function pollEvery(float $wait) { if (false === strpos((string) $wait, '.')) { self::$sleep = (int) $wait; self::$usleep = 0; } else { list($seconds, $hundreds) = explode('.', (string) $wait); self::$sleep = (int) $seconds; self::$usleep = (int) (((float) sprintf('0.%d', $hundreds)) * 1000000); } }
[ "public", "static", "function", "pollEvery", "(", "float", "$", "wait", ")", "{", "if", "(", "false", "===", "strpos", "(", "(", "string", ")", "$", "wait", ",", "'.'", ")", ")", "{", "self", "::", "$", "sleep", "=", "(", "int", ")", "$", "wait", ";", "self", "::", "$", "usleep", "=", "0", ";", "}", "else", "{", "list", "(", "$", "seconds", ",", "$", "hundreds", ")", "=", "explode", "(", "'.'", ",", "(", "string", ")", "$", "wait", ")", ";", "self", "::", "$", "sleep", "=", "(", "int", ")", "$", "seconds", ";", "self", "::", "$", "usleep", "=", "(", "int", ")", "(", "(", "(", "float", ")", "sprintf", "(", "'0.%d'", ",", "$", "hundreds", ")", ")", "*", "1000000", ")", ";", "}", "}" ]
Poll every $wait seconds. To poll every 100ms, call pollEvery(0.100). @param float $wait
[ "Poll", "every", "$wait", "seconds", ".", "To", "poll", "every", "100ms", "call", "pollEvery", "(", "0", ".", "100", ")", "." ]
train
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/MysqliAsync.php#L64-L74
bpolaszek/simple-dbal
src/Model/Adapter/Mysqli/MysqliAsync.php
MysqliAsync.wait
private function wait() { do { if (empty($this->queries)) { break; } $links = $errors = $reject = []; foreach ($this->queries as $link) { $links[] = $errors[] = $reject[] = $link['l']; } if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) { continue; } foreach ($this->queries as $l => $link) { $promise = $this->getPromise($link); $cnx = $this->getConnection($link); try { $result = $cnx->reap_async_query(); if ($result instanceof mysqli_result) { $promise->resolve($result); } else { $errNo = mysqli_errno($cnx); $errStr = mysqli_error($cnx); if (0 !== $errNo || 0 !== strlen($errStr)) { throw new mysqli_sql_exception($errStr, $errNo); } else { $promise->resolve($cnx); } } } catch (mysqli_sql_exception $e) { $promise->reject($e); } $this->processed++; unset($this->queries[$l]); } } while ($this->processed < count($this->queries)); $this->reset(); }
php
private function wait() { do { if (empty($this->queries)) { break; } $links = $errors = $reject = []; foreach ($this->queries as $link) { $links[] = $errors[] = $reject[] = $link['l']; } if (!mysqli_poll($links, $errors, $reject, self::$sleep, self::$usleep)) { continue; } foreach ($this->queries as $l => $link) { $promise = $this->getPromise($link); $cnx = $this->getConnection($link); try { $result = $cnx->reap_async_query(); if ($result instanceof mysqli_result) { $promise->resolve($result); } else { $errNo = mysqli_errno($cnx); $errStr = mysqli_error($cnx); if (0 !== $errNo || 0 !== strlen($errStr)) { throw new mysqli_sql_exception($errStr, $errNo); } else { $promise->resolve($cnx); } } } catch (mysqli_sql_exception $e) { $promise->reject($e); } $this->processed++; unset($this->queries[$l]); } } while ($this->processed < count($this->queries)); $this->reset(); }
[ "private", "function", "wait", "(", ")", "{", "do", "{", "if", "(", "empty", "(", "$", "this", "->", "queries", ")", ")", "{", "break", ";", "}", "$", "links", "=", "$", "errors", "=", "$", "reject", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "queries", "as", "$", "link", ")", "{", "$", "links", "[", "]", "=", "$", "errors", "[", "]", "=", "$", "reject", "[", "]", "=", "$", "link", "[", "'l'", "]", ";", "}", "if", "(", "!", "mysqli_poll", "(", "$", "links", ",", "$", "errors", ",", "$", "reject", ",", "self", "::", "$", "sleep", ",", "self", "::", "$", "usleep", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "this", "->", "queries", "as", "$", "l", "=>", "$", "link", ")", "{", "$", "promise", "=", "$", "this", "->", "getPromise", "(", "$", "link", ")", ";", "$", "cnx", "=", "$", "this", "->", "getConnection", "(", "$", "link", ")", ";", "try", "{", "$", "result", "=", "$", "cnx", "->", "reap_async_query", "(", ")", ";", "if", "(", "$", "result", "instanceof", "mysqli_result", ")", "{", "$", "promise", "->", "resolve", "(", "$", "result", ")", ";", "}", "else", "{", "$", "errNo", "=", "mysqli_errno", "(", "$", "cnx", ")", ";", "$", "errStr", "=", "mysqli_error", "(", "$", "cnx", ")", ";", "if", "(", "0", "!==", "$", "errNo", "||", "0", "!==", "strlen", "(", "$", "errStr", ")", ")", "{", "throw", "new", "mysqli_sql_exception", "(", "$", "errStr", ",", "$", "errNo", ")", ";", "}", "else", "{", "$", "promise", "->", "resolve", "(", "$", "cnx", ")", ";", "}", "}", "}", "catch", "(", "mysqli_sql_exception", "$", "e", ")", "{", "$", "promise", "->", "reject", "(", "$", "e", ")", ";", "}", "$", "this", "->", "processed", "++", ";", "unset", "(", "$", "this", "->", "queries", "[", "$", "l", "]", ")", ";", "}", "}", "while", "(", "$", "this", "->", "processed", "<", "count", "(", "$", "this", "->", "queries", ")", ")", ";", "$", "this", "->", "reset", "(", ")", ";", "}" ]
Wait for pending queries to complete.
[ "Wait", "for", "pending", "queries", "to", "complete", "." ]
train
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/Mysqli/MysqliAsync.php#L106-L143
j-d/draggy
src/Draggy/Autocode/Templates/PHP/Symfony2/Repository.php
Repository.getFileLines
public function getFileLines() { $lines = []; $lines = array_merge($lines, $this->surroundDocumentationBlock($this->getRepositoryDocumentationLines())); $lines[] = 'class ' . $this->getEntity()->getName() . 'Repository extends EntityRepository'; $lines[] = '{'; $lines[] = '/**'; $lines[] = ' * @param EntityManager|ObjectManager $em The EntityManager to use.'; //ObjectManager| $lines[] = ' */'; $lines[] = 'function __construct($em)'; $lines[] = '{'; $lines[] = '/** @var ClassMetadata $metadata */'; $lines[] = '$metadata = $em->getClassMetadata(\'' . $this->getEntity()->getModule() . ':' . $this->getEntity()->getName() . '\');'; $lines[] = ''; $lines[] = 'parent::__construct($em, $metadata);'; $lines[] = '}'; $lines[] = ''; $lines[] = $this->getUserAdditions('methods'); $lines[] = $this->getEndUserAdditions(); $lines[] = '}'; return $lines; }
php
public function getFileLines() { $lines = []; $lines = array_merge($lines, $this->surroundDocumentationBlock($this->getRepositoryDocumentationLines())); $lines[] = 'class ' . $this->getEntity()->getName() . 'Repository extends EntityRepository'; $lines[] = '{'; $lines[] = '/**'; $lines[] = ' * @param EntityManager|ObjectManager $em The EntityManager to use.'; //ObjectManager| $lines[] = ' */'; $lines[] = 'function __construct($em)'; $lines[] = '{'; $lines[] = '/** @var ClassMetadata $metadata */'; $lines[] = '$metadata = $em->getClassMetadata(\'' . $this->getEntity()->getModule() . ':' . $this->getEntity()->getName() . '\');'; $lines[] = ''; $lines[] = 'parent::__construct($em, $metadata);'; $lines[] = '}'; $lines[] = ''; $lines[] = $this->getUserAdditions('methods'); $lines[] = $this->getEndUserAdditions(); $lines[] = '}'; return $lines; }
[ "public", "function", "getFileLines", "(", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "lines", "=", "array_merge", "(", "$", "lines", ",", "$", "this", "->", "surroundDocumentationBlock", "(", "$", "this", "->", "getRepositoryDocumentationLines", "(", ")", ")", ")", ";", "$", "lines", "[", "]", "=", "'class '", ".", "$", "this", "->", "getEntity", "(", ")", "->", "getName", "(", ")", ".", "'Repository extends EntityRepository'", ";", "$", "lines", "[", "]", "=", "'{'", ";", "$", "lines", "[", "]", "=", "'/**'", ";", "$", "lines", "[", "]", "=", "' * @param EntityManager|ObjectManager $em The EntityManager to use.'", ";", "//ObjectManager|", "$", "lines", "[", "]", "=", "' */'", ";", "$", "lines", "[", "]", "=", "'function __construct($em)'", ";", "$", "lines", "[", "]", "=", "'{'", ";", "$", "lines", "[", "]", "=", "'/** @var ClassMetadata $metadata */'", ";", "$", "lines", "[", "]", "=", "'$metadata = $em->getClassMetadata(\\''", ".", "$", "this", "->", "getEntity", "(", ")", "->", "getModule", "(", ")", ".", "':'", ".", "$", "this", "->", "getEntity", "(", ")", "->", "getName", "(", ")", ".", "'\\');'", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'parent::__construct($em, $metadata);'", ";", "$", "lines", "[", "]", "=", "'}'", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "$", "this", "->", "getUserAdditions", "(", "'methods'", ")", ";", "$", "lines", "[", "]", "=", "$", "this", "->", "getEndUserAdditions", "(", ")", ";", "$", "lines", "[", "]", "=", "'}'", ";", "return", "$", "lines", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Symfony2/Repository.php#L102-L125
php-lug/lug
src/Component/Resource/Repository/Doctrine/ORM/Repository.php
Repository.findForIndex
public function findForIndex(array $criteria, array $orderBy = []) { return new Pagerfanta(new DoctrineORMAdapter( $this->buildQueryBuilder($criteria, $orderBy, true), true, true )); }
php
public function findForIndex(array $criteria, array $orderBy = []) { return new Pagerfanta(new DoctrineORMAdapter( $this->buildQueryBuilder($criteria, $orderBy, true), true, true )); }
[ "public", "function", "findForIndex", "(", "array", "$", "criteria", ",", "array", "$", "orderBy", "=", "[", "]", ")", "{", "return", "new", "Pagerfanta", "(", "new", "DoctrineORMAdapter", "(", "$", "this", "->", "buildQueryBuilder", "(", "$", "criteria", ",", "$", "orderBy", ",", "true", ")", ",", "true", ",", "true", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/Repository.php#L49-L56
php-lug/lug
src/Component/Resource/Repository/Doctrine/ORM/Repository.php
Repository.findBy
public function findBy(array $criteria, array $orderBy = [], $limit = null, $offset = null) { $queryBuilder = $this->buildQueryBuilder($criteria, $orderBy); if ($limit !== null) { $queryBuilder->setMaxResults($limit); } if ($offset !== null) { $queryBuilder->setFirstResult($offset); } return $queryBuilder->getQuery()->getResult(); }
php
public function findBy(array $criteria, array $orderBy = [], $limit = null, $offset = null) { $queryBuilder = $this->buildQueryBuilder($criteria, $orderBy); if ($limit !== null) { $queryBuilder->setMaxResults($limit); } if ($offset !== null) { $queryBuilder->setFirstResult($offset); } return $queryBuilder->getQuery()->getResult(); }
[ "public", "function", "findBy", "(", "array", "$", "criteria", ",", "array", "$", "orderBy", "=", "[", "]", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "buildQueryBuilder", "(", "$", "criteria", ",", "$", "orderBy", ")", ";", "if", "(", "$", "limit", "!==", "null", ")", "{", "$", "queryBuilder", "->", "setMaxResults", "(", "$", "limit", ")", ";", "}", "if", "(", "$", "offset", "!==", "null", ")", "{", "$", "queryBuilder", "->", "setFirstResult", "(", "$", "offset", ")", ";", "}", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/Repository.php#L93-L106
php-lug/lug
src/Component/Resource/Repository/Doctrine/ORM/Repository.php
Repository.createQueryBuilder
public function createQueryBuilder($alias = null, $indexBy = null) { return parent::createQueryBuilder($alias ?: $this->getAlias(), $indexBy); }
php
public function createQueryBuilder($alias = null, $indexBy = null) { return parent::createQueryBuilder($alias ?: $this->getAlias(), $indexBy); }
[ "public", "function", "createQueryBuilder", "(", "$", "alias", "=", "null", ",", "$", "indexBy", "=", "null", ")", "{", "return", "parent", "::", "createQueryBuilder", "(", "$", "alias", "?", ":", "$", "this", "->", "getAlias", "(", ")", ",", "$", "indexBy", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/Repository.php#L111-L114
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.makeRoot
public function makeRoot($runValidation = true, $attributes = null) { $this->operation = self::OPERATION_MAKE_ROOT; return $this->owner->save($runValidation, $attributes); }
php
public function makeRoot($runValidation = true, $attributes = null) { $this->operation = self::OPERATION_MAKE_ROOT; return $this->owner->save($runValidation, $attributes); }
[ "public", "function", "makeRoot", "(", "$", "runValidation", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_MAKE_ROOT", ";", "return", "$", "this", "->", "owner", "->", "save", "(", "$", "runValidation", ",", "$", "attributes", ")", ";", "}" ]
Creates the root node if the active record is new or moves it as the root node. @param boolean $runValidation @param array $attributes @return boolean
[ "Creates", "the", "root", "node", "if", "the", "active", "record", "is", "new", "or", "moves", "it", "as", "the", "root", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L88-L92
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.prependTo
public function prependTo($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_PREPEND_TO; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
php
public function prependTo($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_PREPEND_TO; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
[ "public", "function", "prependTo", "(", "$", "node", ",", "$", "runValidation", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_PREPEND_TO", ";", "$", "this", "->", "node", "=", "$", "node", ";", "return", "$", "this", "->", "owner", "->", "save", "(", "$", "runValidation", ",", "$", "attributes", ")", ";", "}" ]
Creates a node as the first child of the target node if the active record is new or moves it as the first child of the target node. @param ActiveRecord $node @param boolean $runValidation @param array $attributes @return boolean
[ "Creates", "a", "node", "as", "the", "first", "child", "of", "the", "target", "node", "if", "the", "active", "record", "is", "new", "or", "moves", "it", "as", "the", "first", "child", "of", "the", "target", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L102-L107
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.appendTo
public function appendTo($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_APPEND_TO; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
php
public function appendTo($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_APPEND_TO; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
[ "public", "function", "appendTo", "(", "$", "node", ",", "$", "runValidation", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_APPEND_TO", ";", "$", "this", "->", "node", "=", "$", "node", ";", "return", "$", "this", "->", "owner", "->", "save", "(", "$", "runValidation", ",", "$", "attributes", ")", ";", "}" ]
Creates a node as the last child of the target node if the active record is new or moves it as the last child of the target node. @param ActiveRecord $node @param boolean $runValidation @param array $attributes @return boolean
[ "Creates", "a", "node", "as", "the", "last", "child", "of", "the", "target", "node", "if", "the", "active", "record", "is", "new", "or", "moves", "it", "as", "the", "last", "child", "of", "the", "target", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L117-L122
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.insertBefore
public function insertBefore($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_INSERT_BEFORE; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
php
public function insertBefore($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_INSERT_BEFORE; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
[ "public", "function", "insertBefore", "(", "$", "node", ",", "$", "runValidation", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_INSERT_BEFORE", ";", "$", "this", "->", "node", "=", "$", "node", ";", "return", "$", "this", "->", "owner", "->", "save", "(", "$", "runValidation", ",", "$", "attributes", ")", ";", "}" ]
Creates a node as the previous sibling of the target node if the active record is new or moves it as the previous sibling of the target node. @param ActiveRecord $node @param boolean $runValidation @param array $attributes @return boolean
[ "Creates", "a", "node", "as", "the", "previous", "sibling", "of", "the", "target", "node", "if", "the", "active", "record", "is", "new", "or", "moves", "it", "as", "the", "previous", "sibling", "of", "the", "target", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L132-L137
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.insertAfter
public function insertAfter($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_INSERT_AFTER; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
php
public function insertAfter($node, $runValidation = true, $attributes = null) { $this->operation = self::OPERATION_INSERT_AFTER; $this->node = $node; return $this->owner->save($runValidation, $attributes); }
[ "public", "function", "insertAfter", "(", "$", "node", ",", "$", "runValidation", "=", "true", ",", "$", "attributes", "=", "null", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_INSERT_AFTER", ";", "$", "this", "->", "node", "=", "$", "node", ";", "return", "$", "this", "->", "owner", "->", "save", "(", "$", "runValidation", ",", "$", "attributes", ")", ";", "}" ]
Creates a node as the next sibling of the target node if the active record is new or moves it as the next sibling of the target node. @param ActiveRecord $node @param boolean $runValidation @param array $attributes @return boolean
[ "Creates", "a", "node", "as", "the", "next", "sibling", "of", "the", "target", "node", "if", "the", "active", "record", "is", "new", "or", "moves", "it", "as", "the", "next", "sibling", "of", "the", "target", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L147-L152
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.deleteWithChildren
public function deleteWithChildren() { $this->operation = self::OPERATION_DELETE_WITH_CHILDREN; try { return $this->deleteWithChildrenInternal(); } catch (\Exception $e) { throw $e; } }
php
public function deleteWithChildren() { $this->operation = self::OPERATION_DELETE_WITH_CHILDREN; try { return $this->deleteWithChildrenInternal(); } catch (\Exception $e) { throw $e; } }
[ "public", "function", "deleteWithChildren", "(", ")", "{", "$", "this", "->", "operation", "=", "self", "::", "OPERATION_DELETE_WITH_CHILDREN", ";", "try", "{", "return", "$", "this", "->", "deleteWithChildrenInternal", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
}
[ "}" ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L185-L193
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.parents
public function parents($depth = null) { $condition = [ 'and', [$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]], [$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]], ]; if ($depth !== null) { $condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]]; } $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); }
php
public function parents($depth = null) { $condition = [ 'and', [$this->leftAttribute => ['$lt' => $this->owner->getAttribute($this->leftAttribute)]], [$this->rightAttribute => ['$gt' => $this->owner->getAttribute($this->rightAttribute)]], ]; if ($depth !== null) { $condition[] = [$this->depthAttribute => ['$gte' => $this->owner->getAttribute($this->depthAttribute) - $depth]]; } $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); }
[ "public", "function", "parents", "(", "$", "depth", "=", "null", ")", "{", "$", "condition", "=", "[", "'and'", ",", "[", "$", "this", "->", "leftAttribute", "=>", "[", "'$lt'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", "]", "]", ",", "[", "$", "this", "->", "rightAttribute", "=>", "[", "'$gt'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", "]", "]", ",", "]", ";", "if", "(", "$", "depth", "!==", "null", ")", "{", "$", "condition", "[", "]", "=", "[", "$", "this", "->", "depthAttribute", "=>", "[", "'$gte'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "depthAttribute", ")", "-", "$", "depth", "]", "]", ";", "}", "$", "this", "->", "applyTreeAttributeCondition", "(", "$", "condition", ")", ";", "return", "$", "this", "->", "owner", "->", "find", "(", ")", "->", "andWhere", "(", "$", "condition", ")", "->", "addOrderBy", "(", "[", "$", "this", "->", "leftAttribute", "=>", "SORT_ASC", "]", ")", ";", "}" ]
Gets the parents of the node. @param integer|null $depth the depth @return \yii\db\ActiveQuery
[ "Gets", "the", "parents", "of", "the", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L223-L237
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.leaves
public function leaves() { $condition = [ 'and', [$this->leftAttribute => ['$gt' => $this->owner->getAttribute($this->leftAttribute)]], [$this->rightAttribute => ['$lt' => $this->owner->getAttribute($this->rightAttribute)]], ['$where' => "this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1"] ]; $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); }
php
public function leaves() { $condition = [ 'and', [$this->leftAttribute => ['$gt' => $this->owner->getAttribute($this->leftAttribute)]], [$this->rightAttribute => ['$lt' => $this->owner->getAttribute($this->rightAttribute)]], ['$where' => "this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1"] ]; $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); }
[ "public", "function", "leaves", "(", ")", "{", "$", "condition", "=", "[", "'and'", ",", "[", "$", "this", "->", "leftAttribute", "=>", "[", "'$gt'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", "]", "]", ",", "[", "$", "this", "->", "rightAttribute", "=>", "[", "'$lt'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", "]", "]", ",", "[", "'$where'", "=>", "\"this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1\"", "]", "]", ";", "$", "this", "->", "applyTreeAttributeCondition", "(", "$", "condition", ")", ";", "return", "$", "this", "->", "owner", "->", "find", "(", ")", "->", "andWhere", "(", "$", "condition", ")", "->", "addOrderBy", "(", "[", "$", "this", "->", "leftAttribute", "=>", "SORT_ASC", "]", ")", ";", "}" ]
Gets the leaves of the node. @return \yii\db\ActiveQuery
[ "Gets", "the", "leaves", "of", "the", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L264-L275
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.prev
public function prev() { $condition = [$this->rightAttribute => $this->owner->getAttribute($this->leftAttribute) - 1]; $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition); }
php
public function prev() { $condition = [$this->rightAttribute => $this->owner->getAttribute($this->leftAttribute) - 1]; $this->applyTreeAttributeCondition($condition); return $this->owner->find()->andWhere($condition); }
[ "public", "function", "prev", "(", ")", "{", "$", "condition", "=", "[", "$", "this", "->", "rightAttribute", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", "-", "1", "]", ";", "$", "this", "->", "applyTreeAttributeCondition", "(", "$", "condition", ")", ";", "return", "$", "this", "->", "owner", "->", "find", "(", ")", "->", "andWhere", "(", "$", "condition", ")", ";", "}" ]
Gets the previous sibling of the node. @return \yii\db\ActiveQuery
[ "Gets", "the", "previous", "sibling", "of", "the", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L281-L286
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.isChildOf
public function isChildOf($node) { $result = $this->owner->getAttribute($this->leftAttribute) > $node->getAttribute($this->leftAttribute) && $this->owner->getAttribute($this->rightAttribute) < $node->getAttribute($this->rightAttribute); if ($result && $this->treeAttribute !== false) { $result = $this->owner->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute); } return $result; }
php
public function isChildOf($node) { $result = $this->owner->getAttribute($this->leftAttribute) > $node->getAttribute($this->leftAttribute) && $this->owner->getAttribute($this->rightAttribute) < $node->getAttribute($this->rightAttribute); if ($result && $this->treeAttribute !== false) { $result = $this->owner->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute); } return $result; }
[ "public", "function", "isChildOf", "(", "$", "node", ")", "{", "$", "result", "=", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", ">", "$", "node", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", "&&", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", "<", "$", "node", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", ";", "if", "(", "$", "result", "&&", "$", "this", "->", "treeAttribute", "!==", "false", ")", "{", "$", "result", "=", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "treeAttribute", ")", "===", "$", "node", "->", "getAttribute", "(", "$", "this", "->", "treeAttribute", ")", ";", "}", "return", "$", "result", ";", "}" ]
Determines whether the node is child of the parent node. @param ActiveRecord $node the parent node @return boolean whether the node is child of the parent node
[ "Determines", "whether", "the", "node", "is", "child", "of", "the", "parent", "node", "." ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L312-L320
letyii/yii2-mongo-nested-set
NestedSetsBehavior.php
NestedSetsBehavior.buildTreeHtml
public function buildTreeHtml($keys = [], $items = [], $config = [], $selected = []) { $configDefault = [ 'id' => 'nestable', 'class' => 'dd', 'containerClass' => 'dd-list', 'itemClass' => 'dd-item', 'labelClass' => 'dd-handle', 'actions' => [], ]; $config = array_merge($configDefault, $config); // root items $asRoot = false; if (empty($items)) { $asRoot = true; $items[] = [ '_id' => $this->owner->getAttribute('_id'), 'name' => $this->owner->getAttribute('name'), 'lft' => $this->owner->getAttribute($this->leftAttribute), 'rgt' => $this->owner->getAttribute($this->rightAttribute), ]; $children = $this->children()->all(); foreach ($children as $child) { $items[] = [ '_id' => $child->owner->getAttribute('_id'), 'name' => $child->owner->getAttribute('name'), $this->leftAttribute => $child->owner->getAttribute($this->leftAttribute), $this->rightAttribute => $child->owner->getAttribute($this->rightAttribute), ]; } $keys = $this->buildTreeKeys($items); } $list = Html::beginTag('ol', ['class' => $config['containerClass']]); foreach ($keys as $key => $row) { if (isset($config['actions'])) { $actions = str_replace ('{_id}', $items[$key]['_id'], $config['actions']); if (is_array($selected) && in_array($items[$key]['_id'], $selected)) { $actions = str_replace ('{check}', 'checked', $actions); } } if (count($row)) { $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>' . $this->buildTreeHtml($row, $items, $config, $selected), ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]); } else { $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]); } } $list .= Html::endTag('ol'); // if (strpos($list, Html::beginTag('li', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']])) === false) { // $list = ''; // } if ($asRoot){ $list = Html::tag('div', $list, ['id' => $config['id'], 'class' => $config['class']]); } return $list; }
php
public function buildTreeHtml($keys = [], $items = [], $config = [], $selected = []) { $configDefault = [ 'id' => 'nestable', 'class' => 'dd', 'containerClass' => 'dd-list', 'itemClass' => 'dd-item', 'labelClass' => 'dd-handle', 'actions' => [], ]; $config = array_merge($configDefault, $config); // root items $asRoot = false; if (empty($items)) { $asRoot = true; $items[] = [ '_id' => $this->owner->getAttribute('_id'), 'name' => $this->owner->getAttribute('name'), 'lft' => $this->owner->getAttribute($this->leftAttribute), 'rgt' => $this->owner->getAttribute($this->rightAttribute), ]; $children = $this->children()->all(); foreach ($children as $child) { $items[] = [ '_id' => $child->owner->getAttribute('_id'), 'name' => $child->owner->getAttribute('name'), $this->leftAttribute => $child->owner->getAttribute($this->leftAttribute), $this->rightAttribute => $child->owner->getAttribute($this->rightAttribute), ]; } $keys = $this->buildTreeKeys($items); } $list = Html::beginTag('ol', ['class' => $config['containerClass']]); foreach ($keys as $key => $row) { if (isset($config['actions'])) { $actions = str_replace ('{_id}', $items[$key]['_id'], $config['actions']); if (is_array($selected) && in_array($items[$key]['_id'], $selected)) { $actions = str_replace ('{check}', 'checked', $actions); } } if (count($row)) { $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>' . $this->buildTreeHtml($row, $items, $config, $selected), ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]); } else { $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]); } } $list .= Html::endTag('ol'); // if (strpos($list, Html::beginTag('li', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']])) === false) { // $list = ''; // } if ($asRoot){ $list = Html::tag('div', $list, ['id' => $config['id'], 'class' => $config['class']]); } return $list; }
[ "public", "function", "buildTreeHtml", "(", "$", "keys", "=", "[", "]", ",", "$", "items", "=", "[", "]", ",", "$", "config", "=", "[", "]", ",", "$", "selected", "=", "[", "]", ")", "{", "$", "configDefault", "=", "[", "'id'", "=>", "'nestable'", ",", "'class'", "=>", "'dd'", ",", "'containerClass'", "=>", "'dd-list'", ",", "'itemClass'", "=>", "'dd-item'", ",", "'labelClass'", "=>", "'dd-handle'", ",", "'actions'", "=>", "[", "]", ",", "]", ";", "$", "config", "=", "array_merge", "(", "$", "configDefault", ",", "$", "config", ")", ";", "// root items\r", "$", "asRoot", "=", "false", ";", "if", "(", "empty", "(", "$", "items", ")", ")", "{", "$", "asRoot", "=", "true", ";", "$", "items", "[", "]", "=", "[", "'_id'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "'_id'", ")", ",", "'name'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "'name'", ")", ",", "'lft'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", ",", "'rgt'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", ",", "]", ";", "$", "children", "=", "$", "this", "->", "children", "(", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "items", "[", "]", "=", "[", "'_id'", "=>", "$", "child", "->", "owner", "->", "getAttribute", "(", "'_id'", ")", ",", "'name'", "=>", "$", "child", "->", "owner", "->", "getAttribute", "(", "'name'", ")", ",", "$", "this", "->", "leftAttribute", "=>", "$", "child", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "leftAttribute", ")", ",", "$", "this", "->", "rightAttribute", "=>", "$", "child", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "rightAttribute", ")", ",", "]", ";", "}", "$", "keys", "=", "$", "this", "->", "buildTreeKeys", "(", "$", "items", ")", ";", "}", "$", "list", "=", "Html", "::", "beginTag", "(", "'ol'", ",", "[", "'class'", "=>", "$", "config", "[", "'containerClass'", "]", "]", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", "=>", "$", "row", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'actions'", "]", ")", ")", "{", "$", "actions", "=", "str_replace", "(", "'{_id}'", ",", "$", "items", "[", "$", "key", "]", "[", "'_id'", "]", ",", "$", "config", "[", "'actions'", "]", ")", ";", "if", "(", "is_array", "(", "$", "selected", ")", "&&", "in_array", "(", "$", "items", "[", "$", "key", "]", "[", "'_id'", "]", ",", "$", "selected", ")", ")", "{", "$", "actions", "=", "str_replace", "(", "'{check}'", ",", "'checked'", ",", "$", "actions", ")", ";", "}", "}", "if", "(", "count", "(", "$", "row", ")", ")", "{", "$", "list", ".=", "Html", "::", "tag", "(", "'li'", ",", "$", "actions", ".", "'<div class=\"'", ".", "$", "config", "[", "'labelClass'", "]", ".", "'\">'", ".", "$", "items", "[", "$", "key", "]", "[", "'name'", "]", ".", "'</div>'", ".", "$", "this", "->", "buildTreeHtml", "(", "$", "row", ",", "$", "items", ",", "$", "config", ",", "$", "selected", ")", ",", "[", "'class'", "=>", "$", "config", "[", "'itemClass'", "]", ",", "'data-id'", "=>", "$", "items", "[", "$", "key", "]", "[", "'_id'", "]", "]", ")", ";", "}", "else", "{", "$", "list", ".=", "Html", "::", "tag", "(", "'li'", ",", "$", "actions", ".", "'<div class=\"'", ".", "$", "config", "[", "'labelClass'", "]", ".", "'\">'", ".", "$", "items", "[", "$", "key", "]", "[", "'name'", "]", ".", "'</div>'", ",", "[", "'class'", "=>", "$", "config", "[", "'itemClass'", "]", ",", "'data-id'", "=>", "$", "items", "[", "$", "key", "]", "[", "'_id'", "]", "]", ")", ";", "}", "}", "$", "list", ".=", "Html", "::", "endTag", "(", "'ol'", ")", ";", "// if (strpos($list, Html::beginTag('li', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']])) === false) {\r", "// $list = '';\r", "// }\r", "if", "(", "$", "asRoot", ")", "{", "$", "list", "=", "Html", "::", "tag", "(", "'div'", ",", "$", "list", ",", "[", "'id'", "=>", "$", "config", "[", "'id'", "]", ",", "'class'", "=>", "$", "config", "[", "'class'", "]", "]", ")", ";", "}", "return", "$", "list", ";", "}" ]
Build tree html @param type $keys @param type $items @param type $config @return string HTML
[ "Build", "tree", "html" ]
train
https://github.com/letyii/yii2-mongo-nested-set/blob/cb88a2e8665c62192a013cd7b1cbcd53148f0ec5/NestedSetsBehavior.php#L718-L777
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.fetchData
protected function fetchData( $filename, $useApc = false ) { if ( $useApc === true ) { $data = $this->backend->fetch( $filename ); return ( is_object( $data ) ) ? $data->data : false; } else { return ( include $filename ); } }
php
protected function fetchData( $filename, $useApc = false ) { if ( $useApc === true ) { $data = $this->backend->fetch( $filename ); return ( is_object( $data ) ) ? $data->data : false; } else { return ( include $filename ); } }
[ "protected", "function", "fetchData", "(", "$", "filename", ",", "$", "useApc", "=", "false", ")", "{", "if", "(", "$", "useApc", "===", "true", ")", "{", "$", "data", "=", "$", "this", "->", "backend", "->", "fetch", "(", "$", "filename", ")", ";", "return", "(", "is_object", "(", "$", "data", ")", ")", "?", "$", "data", "->", "data", ":", "false", ";", "}", "else", "{", "return", "(", "include", "$", "filename", ")", ";", "}", "}" ]
Fetches the data from the cache. @param string $filename The ID/filename from where to fetch the object @param bool $useApc Use APC or the file system @return mixed The fetched data or false on failure
[ "Fetches", "the", "data", "from", "the", "cache", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L56-L67
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.fetchObject
protected function fetchObject( $filename ) { $data = $this->backend->fetch( $filename ); return ( is_object( $data ) ) ? $data : false; }
php
protected function fetchObject( $filename ) { $data = $this->backend->fetch( $filename ); return ( is_object( $data ) ) ? $data : false; }
[ "protected", "function", "fetchObject", "(", "$", "filename", ")", "{", "$", "data", "=", "$", "this", "->", "backend", "->", "fetch", "(", "$", "filename", ")", ";", "return", "(", "is_object", "(", "$", "data", ")", ")", "?", "$", "data", ":", "false", ";", "}" ]
Fetches the object from the cache. @param string $filename The ID/filename from where to fetch the data @return mixed The fetched object or false on failure
[ "Fetches", "the", "object", "from", "the", "cache", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L75-L79
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.prepareData
protected function prepareData( $data, $useApc = false ) { if ( $useApc === true ) { if ( is_resource( $data ) ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array', 'object' ) ); } return new ezcCacheStorageFileApcArrayDataStruct( $data, $this->properties['location'] ); } else { if ( is_object( $data ) || is_resource( $data ) ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array' ) ); } return "<?php\nreturn " . var_export( $data, true ) . ";\n?>\n"; } }
php
protected function prepareData( $data, $useApc = false ) { if ( $useApc === true ) { if ( is_resource( $data ) ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array', 'object' ) ); } return new ezcCacheStorageFileApcArrayDataStruct( $data, $this->properties['location'] ); } else { if ( is_object( $data ) || is_resource( $data ) ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array' ) ); } return "<?php\nreturn " . var_export( $data, true ) . ";\n?>\n"; } }
[ "protected", "function", "prepareData", "(", "$", "data", ",", "$", "useApc", "=", "false", ")", "{", "if", "(", "$", "useApc", "===", "true", ")", "{", "if", "(", "is_resource", "(", "$", "data", ")", ")", "{", "throw", "new", "ezcCacheInvalidDataException", "(", "gettype", "(", "$", "data", ")", ",", "array", "(", "'simple'", ",", "'array'", ",", "'object'", ")", ")", ";", "}", "return", "new", "ezcCacheStorageFileApcArrayDataStruct", "(", "$", "data", ",", "$", "this", "->", "properties", "[", "'location'", "]", ")", ";", "}", "else", "{", "if", "(", "is_object", "(", "$", "data", ")", "||", "is_resource", "(", "$", "data", ")", ")", "{", "throw", "new", "ezcCacheInvalidDataException", "(", "gettype", "(", "$", "data", ")", ",", "array", "(", "'simple'", ",", "'array'", ")", ")", ";", "}", "return", "\"<?php\\nreturn \"", ".", "var_export", "(", "$", "data", ",", "true", ")", ".", "\";\\n?>\\n\"", ";", "}", "}" ]
Wraps the data in order to be stored in APC ($useApc = true) or on the file system ($useApc = false). @throws ezcCacheInvalidDataException If the data submitted can not be handled by this storage (object, resource). @param mixed $data Simple type or array @param bool $useApc Use APC or not @return mixed Prepared data
[ "Wraps", "the", "data", "in", "order", "to", "be", "stored", "in", "APC", "(", "$useApc", "=", "true", ")", "or", "on", "the", "file", "system", "(", "$useApc", "=", "false", ")", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L93-L112
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.store
public function store( $id, $data, $attributes = array() ) { // Generates the identifier $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); // Purges the Registry Cache if ( isset( $this->registry[$filename] ) ) { unset( $this->registry[$filename] ); } // Deletes the files if it already exists on the filesystem if ( file_exists( $filename ) ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existing cache file.' ); } } // Deletes the data from APC if it already exists $this->backend->delete( $filename ); // Prepares the data for filesystem storage $dataStr = $this->prepareData( $data ); // Tries to create the directory on the filesystem $dirname = dirname( $filename ); if ( !is_dir( $dirname ) && !mkdir( $dirname, 0777, true ) ) { throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to store cache file.' ); } // Tries to write the file the filesystem if ( @file_put_contents( $filename, $dataStr ) !== strlen( $dataStr ) ) { throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' ); } // Tries to set the file permissions if ( ezcBaseFeatures::os() !== "Windows" ) { chmod( $filename, $this->options->permissions ); } // Prepares the data for APC storage $dataObj = $this->prepareData( $data, true ); $dataObj->mtime = @filemtime( $filename ); $dataObj->atime = time(); // Stores it in APC $this->registerIdentifier( $id, $attributes, $filename ); if ( !$this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ) ) { throw new ezcCacheApcException( "APC store failed." ); } // Returns the ID for no good reason return $id; }
php
public function store( $id, $data, $attributes = array() ) { // Generates the identifier $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); // Purges the Registry Cache if ( isset( $this->registry[$filename] ) ) { unset( $this->registry[$filename] ); } // Deletes the files if it already exists on the filesystem if ( file_exists( $filename ) ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existing cache file.' ); } } // Deletes the data from APC if it already exists $this->backend->delete( $filename ); // Prepares the data for filesystem storage $dataStr = $this->prepareData( $data ); // Tries to create the directory on the filesystem $dirname = dirname( $filename ); if ( !is_dir( $dirname ) && !mkdir( $dirname, 0777, true ) ) { throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to store cache file.' ); } // Tries to write the file the filesystem if ( @file_put_contents( $filename, $dataStr ) !== strlen( $dataStr ) ) { throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' ); } // Tries to set the file permissions if ( ezcBaseFeatures::os() !== "Windows" ) { chmod( $filename, $this->options->permissions ); } // Prepares the data for APC storage $dataObj = $this->prepareData( $data, true ); $dataObj->mtime = @filemtime( $filename ); $dataObj->atime = time(); // Stores it in APC $this->registerIdentifier( $id, $attributes, $filename ); if ( !$this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ) ) { throw new ezcCacheApcException( "APC store failed." ); } // Returns the ID for no good reason return $id; }
[ "public", "function", "store", "(", "$", "id", ",", "$", "data", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "// Generates the identifier", "$", "filename", "=", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "// Purges the Registry Cache", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ";", "}", "// Deletes the files if it already exists on the filesystem", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "if", "(", "unlink", "(", "$", "filename", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not delete existing cache file.'", ")", ";", "}", "}", "// Deletes the data from APC if it already exists", "$", "this", "->", "backend", "->", "delete", "(", "$", "filename", ")", ";", "// Prepares the data for filesystem storage", "$", "dataStr", "=", "$", "this", "->", "prepareData", "(", "$", "data", ")", ";", "// Tries to create the directory on the filesystem", "$", "dirname", "=", "dirname", "(", "$", "filename", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dirname", ")", "&&", "!", "mkdir", "(", "$", "dirname", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "dirname", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not create directory to store cache file.'", ")", ";", "}", "// Tries to write the file the filesystem", "if", "(", "@", "file_put_contents", "(", "$", "filename", ",", "$", "dataStr", ")", "!==", "strlen", "(", "$", "dataStr", ")", ")", "{", "throw", "new", "ezcBaseFileIoException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not write data to cache file.'", ")", ";", "}", "// Tries to set the file permissions", "if", "(", "ezcBaseFeatures", "::", "os", "(", ")", "!==", "\"Windows\"", ")", "{", "chmod", "(", "$", "filename", ",", "$", "this", "->", "options", "->", "permissions", ")", ";", "}", "// Prepares the data for APC storage", "$", "dataObj", "=", "$", "this", "->", "prepareData", "(", "$", "data", ",", "true", ")", ";", "$", "dataObj", "->", "mtime", "=", "@", "filemtime", "(", "$", "filename", ")", ";", "$", "dataObj", "->", "atime", "=", "time", "(", ")", ";", "// Stores it in APC", "$", "this", "->", "registerIdentifier", "(", "$", "id", ",", "$", "attributes", ",", "$", "filename", ")", ";", "if", "(", "!", "$", "this", "->", "backend", "->", "store", "(", "$", "filename", ",", "$", "dataObj", ",", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'ttl'", "]", ")", ")", "{", "throw", "new", "ezcCacheApcException", "(", "\"APC store failed.\"", ")", ";", "}", "// Returns the ID for no good reason", "return", "$", "id", ";", "}" ]
Stores data to the cache storage. @throws ezcBaseFilePermissionException If the directory to store the cache file could not be created. This exception means most likely that your cache directory has been corrupted by external influences (file permission change). @throws ezcBaseFileIoException If an error occured while writing the data to the cache. If this exception occurs, a serious error occured and your storage might be corruped (e.g. broken network connection, file system broken, ...). @throws ezcCacheInvalidDataException If the data submitted can not be handled by the implementation of {@link ezcCacheStorageFile}. Most implementations can not handle objects and resources. @throws ezcCacheApcException If the data could not be stored in APC. @param string $id Unique identifier @param mixed $data The data to store @param array(string=>string) $attributes Attributes describing the cached data @return string The ID string of the newly cached data
[ "Stores", "data", "to", "the", "cache", "storage", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L139-L199
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.restore
public function restore( $id, $attributes = array(), $search = false ) { // Generates the identifier $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); // Grabs the data object from the APC $dataObj = $this->fetchObject( $filename ); $useApc = false; // Checks the APC object exists if ( $dataObj !== false && is_object( $dataObj ) && isset( $dataObj->atime ) ) { $useApc = true; } // Checks the APC object is still valid if ( !isset( $this->registry[$filename] ) && $useApc === true && time() === $dataObj->atime ) { // Make sure the FileSystem still has the file and that it hasn't changed if ( file_exists( $filename ) !== false && @filemtime( $filename ) === $dataObj->mtime ) { $dataObj->atime = time(); $this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ); } else { $useApc = false; $this->backend->delete( $filename ); } } // Searches the filesystem for the file if ( !isset( $this->registry[$filename] ) && $useApc === false && file_exists( $filename ) === false ) { if ( $search === true && count( $files = $this->search( $id, $attributes ) ) === 1 ) { $filename = $files[0][2]; } else { // There are more elements found during search, so false is returned return false; } } // Returns false if no data is stored anywhere if ( $useApc === false && file_exists( $filename ) === false ) { // Purges APC $this->backend->delete( $filename ); // Purges Registry Cache if ( isset( $this->registry[$filename] ) ) { unset( $this->registry[$filename] ); } return false; } // Creates a Registry Object -- should only happen once per page load if ( !isset( $this->registry[$filename] ) ) { $this->registry[$filename] = new stdClass(); $this->registry[$filename]->data = false; $this->registry[$filename]->mtime = $useApc ? $dataObj->mtime : null; $this->registry[$filename]->lifetime = $this->calcLifetime( $filename, $useApc ); } // Purges the data if it is expired if ( $this->properties['options']['ttl'] !== false && $this->calcLifetime( $filename, $useApc ) > $this->properties['options']['ttl'] ) { $this->delete( $id, $attributes, false ); // don't search return false; } // Returns the data from the Registry Cache if ( $this->registry[$filename]->data !== false ) { return ( $this->registry[$filename]->data ); } // Returns data from APC else if ( $useApc === true && ( isset( $dataObj->data ) || is_null( $dataObj->data ) ) ) { $this->registry[$filename]->data = $dataObj->data; // primes the Registry cache return ( $dataObj->data ); } // Returns data from the filesystem else if ( file_exists( $filename ) !== false ) { // Grabs the data from the filesystem $dataStr = $this->fetchData( $filename ); // Stores it in the Registry Cache $this->registry[$filename]->data = $dataStr; // Prepares the data for APC storage $dataObj = $this->prepareData( $dataStr, true ); $dataObj->mtime = @filemtime( $filename ); $dataObj->atime = time(); // Stores it in APC $this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ); // Returns the data return ( $dataStr ); } else { return false; } }
php
public function restore( $id, $attributes = array(), $search = false ) { // Generates the identifier $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); // Grabs the data object from the APC $dataObj = $this->fetchObject( $filename ); $useApc = false; // Checks the APC object exists if ( $dataObj !== false && is_object( $dataObj ) && isset( $dataObj->atime ) ) { $useApc = true; } // Checks the APC object is still valid if ( !isset( $this->registry[$filename] ) && $useApc === true && time() === $dataObj->atime ) { // Make sure the FileSystem still has the file and that it hasn't changed if ( file_exists( $filename ) !== false && @filemtime( $filename ) === $dataObj->mtime ) { $dataObj->atime = time(); $this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ); } else { $useApc = false; $this->backend->delete( $filename ); } } // Searches the filesystem for the file if ( !isset( $this->registry[$filename] ) && $useApc === false && file_exists( $filename ) === false ) { if ( $search === true && count( $files = $this->search( $id, $attributes ) ) === 1 ) { $filename = $files[0][2]; } else { // There are more elements found during search, so false is returned return false; } } // Returns false if no data is stored anywhere if ( $useApc === false && file_exists( $filename ) === false ) { // Purges APC $this->backend->delete( $filename ); // Purges Registry Cache if ( isset( $this->registry[$filename] ) ) { unset( $this->registry[$filename] ); } return false; } // Creates a Registry Object -- should only happen once per page load if ( !isset( $this->registry[$filename] ) ) { $this->registry[$filename] = new stdClass(); $this->registry[$filename]->data = false; $this->registry[$filename]->mtime = $useApc ? $dataObj->mtime : null; $this->registry[$filename]->lifetime = $this->calcLifetime( $filename, $useApc ); } // Purges the data if it is expired if ( $this->properties['options']['ttl'] !== false && $this->calcLifetime( $filename, $useApc ) > $this->properties['options']['ttl'] ) { $this->delete( $id, $attributes, false ); // don't search return false; } // Returns the data from the Registry Cache if ( $this->registry[$filename]->data !== false ) { return ( $this->registry[$filename]->data ); } // Returns data from APC else if ( $useApc === true && ( isset( $dataObj->data ) || is_null( $dataObj->data ) ) ) { $this->registry[$filename]->data = $dataObj->data; // primes the Registry cache return ( $dataObj->data ); } // Returns data from the filesystem else if ( file_exists( $filename ) !== false ) { // Grabs the data from the filesystem $dataStr = $this->fetchData( $filename ); // Stores it in the Registry Cache $this->registry[$filename]->data = $dataStr; // Prepares the data for APC storage $dataObj = $this->prepareData( $dataStr, true ); $dataObj->mtime = @filemtime( $filename ); $dataObj->atime = time(); // Stores it in APC $this->backend->store( $filename, $dataObj, $this->properties['options']['ttl'] ); // Returns the data return ( $dataStr ); } else { return false; } }
[ "public", "function", "restore", "(", "$", "id", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "// Generates the identifier", "$", "filename", "=", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "// Grabs the data object from the APC", "$", "dataObj", "=", "$", "this", "->", "fetchObject", "(", "$", "filename", ")", ";", "$", "useApc", "=", "false", ";", "// Checks the APC object exists", "if", "(", "$", "dataObj", "!==", "false", "&&", "is_object", "(", "$", "dataObj", ")", "&&", "isset", "(", "$", "dataObj", "->", "atime", ")", ")", "{", "$", "useApc", "=", "true", ";", "}", "// Checks the APC object is still valid", "if", "(", "!", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", "&&", "$", "useApc", "===", "true", "&&", "time", "(", ")", "===", "$", "dataObj", "->", "atime", ")", "{", "// Make sure the FileSystem still has the file and that it hasn't changed", "if", "(", "file_exists", "(", "$", "filename", ")", "!==", "false", "&&", "@", "filemtime", "(", "$", "filename", ")", "===", "$", "dataObj", "->", "mtime", ")", "{", "$", "dataObj", "->", "atime", "=", "time", "(", ")", ";", "$", "this", "->", "backend", "->", "store", "(", "$", "filename", ",", "$", "dataObj", ",", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'ttl'", "]", ")", ";", "}", "else", "{", "$", "useApc", "=", "false", ";", "$", "this", "->", "backend", "->", "delete", "(", "$", "filename", ")", ";", "}", "}", "// Searches the filesystem for the file", "if", "(", "!", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", "&&", "$", "useApc", "===", "false", "&&", "file_exists", "(", "$", "filename", ")", "===", "false", ")", "{", "if", "(", "$", "search", "===", "true", "&&", "count", "(", "$", "files", "=", "$", "this", "->", "search", "(", "$", "id", ",", "$", "attributes", ")", ")", "===", "1", ")", "{", "$", "filename", "=", "$", "files", "[", "0", "]", "[", "2", "]", ";", "}", "else", "{", "// There are more elements found during search, so false is returned", "return", "false", ";", "}", "}", "// Returns false if no data is stored anywhere", "if", "(", "$", "useApc", "===", "false", "&&", "file_exists", "(", "$", "filename", ")", "===", "false", ")", "{", "// Purges APC", "$", "this", "->", "backend", "->", "delete", "(", "$", "filename", ")", ";", "// Purges Registry Cache", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ";", "}", "return", "false", ";", "}", "// Creates a Registry Object -- should only happen once per page load", "if", "(", "!", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ")", "{", "$", "this", "->", "registry", "[", "$", "filename", "]", "=", "new", "stdClass", "(", ")", ";", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "data", "=", "false", ";", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "mtime", "=", "$", "useApc", "?", "$", "dataObj", "->", "mtime", ":", "null", ";", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "lifetime", "=", "$", "this", "->", "calcLifetime", "(", "$", "filename", ",", "$", "useApc", ")", ";", "}", "// Purges the data if it is expired", "if", "(", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'ttl'", "]", "!==", "false", "&&", "$", "this", "->", "calcLifetime", "(", "$", "filename", ",", "$", "useApc", ")", ">", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'ttl'", "]", ")", "{", "$", "this", "->", "delete", "(", "$", "id", ",", "$", "attributes", ",", "false", ")", ";", "// don't search", "return", "false", ";", "}", "// Returns the data from the Registry Cache", "if", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "data", "!==", "false", ")", "{", "return", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "data", ")", ";", "}", "// Returns data from APC", "else", "if", "(", "$", "useApc", "===", "true", "&&", "(", "isset", "(", "$", "dataObj", "->", "data", ")", "||", "is_null", "(", "$", "dataObj", "->", "data", ")", ")", ")", "{", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "data", "=", "$", "dataObj", "->", "data", ";", "// primes the Registry cache", "return", "(", "$", "dataObj", "->", "data", ")", ";", "}", "// Returns data from the filesystem", "else", "if", "(", "file_exists", "(", "$", "filename", ")", "!==", "false", ")", "{", "// Grabs the data from the filesystem", "$", "dataStr", "=", "$", "this", "->", "fetchData", "(", "$", "filename", ")", ";", "// Stores it in the Registry Cache", "$", "this", "->", "registry", "[", "$", "filename", "]", "->", "data", "=", "$", "dataStr", ";", "// Prepares the data for APC storage", "$", "dataObj", "=", "$", "this", "->", "prepareData", "(", "$", "dataStr", ",", "true", ")", ";", "$", "dataObj", "->", "mtime", "=", "@", "filemtime", "(", "$", "filename", ")", ";", "$", "dataObj", "->", "atime", "=", "time", "(", ")", ";", "// Stores it in APC", "$", "this", "->", "backend", "->", "store", "(", "$", "filename", ",", "$", "dataObj", ",", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'ttl'", "]", ")", ";", "// Returns the data", "return", "(", "$", "dataStr", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Restores the data from the cache. @param string $id The item ID to restore @param array(string=>string) $attributes Attributes describing the data to restore @param bool $search Whether to search for items if not found directly @return mixed The cached data on success, otherwise false
[ "Restores", "the", "data", "from", "the", "cache", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L209-L333
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.delete
public function delete( $id = null, $attributes = array(), $search = false ) { $location = $this->properties['location']; // Generates the identifier $filename = $location . $this->generateIdentifier( $id, $attributes ); // Initializes the array $delFiles = array(); clearstatcache(); // Checks if the file exists on the filesystem if ( file_exists( $filename ) ) { $delFiles[] = array( $id, $attributes, $filename ); } else if ( $search === true ) { $delFiles = $this->search( $id, $attributes ); } $deletedIds = array(); // Deletes the files foreach ( $delFiles as $count => $filename ) { // Deletes from Registry Cache if ( isset( $this->registry[$filename[2]] ) ) { unset( $this->registry[$filename[2]] ); } // Deletes from APC $this->backend->delete( $filename[2] ); $this->unRegisterIdentifier( $filename[0], $filename[1], $filename[2], true ); if ( isset( $this->registry[$location][$filename[0]][$filename[2]] ) ) { unset( $this->registry[$location][$filename[0]][$filename[2]] ); } // Deletes from the filesystem if ( @unlink( $filename[2] ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $deletedIds[] = $filename[0]; } $this->storeSearchRegistry(); return $deletedIds; }
php
public function delete( $id = null, $attributes = array(), $search = false ) { $location = $this->properties['location']; // Generates the identifier $filename = $location . $this->generateIdentifier( $id, $attributes ); // Initializes the array $delFiles = array(); clearstatcache(); // Checks if the file exists on the filesystem if ( file_exists( $filename ) ) { $delFiles[] = array( $id, $attributes, $filename ); } else if ( $search === true ) { $delFiles = $this->search( $id, $attributes ); } $deletedIds = array(); // Deletes the files foreach ( $delFiles as $count => $filename ) { // Deletes from Registry Cache if ( isset( $this->registry[$filename[2]] ) ) { unset( $this->registry[$filename[2]] ); } // Deletes from APC $this->backend->delete( $filename[2] ); $this->unRegisterIdentifier( $filename[0], $filename[1], $filename[2], true ); if ( isset( $this->registry[$location][$filename[0]][$filename[2]] ) ) { unset( $this->registry[$location][$filename[0]][$filename[2]] ); } // Deletes from the filesystem if ( @unlink( $filename[2] ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $deletedIds[] = $filename[0]; } $this->storeSearchRegistry(); return $deletedIds; }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "location", "=", "$", "this", "->", "properties", "[", "'location'", "]", ";", "// Generates the identifier", "$", "filename", "=", "$", "location", ".", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "// Initializes the array", "$", "delFiles", "=", "array", "(", ")", ";", "clearstatcache", "(", ")", ";", "// Checks if the file exists on the filesystem", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "delFiles", "[", "]", "=", "array", "(", "$", "id", ",", "$", "attributes", ",", "$", "filename", ")", ";", "}", "else", "if", "(", "$", "search", "===", "true", ")", "{", "$", "delFiles", "=", "$", "this", "->", "search", "(", "$", "id", ",", "$", "attributes", ")", ";", "}", "$", "deletedIds", "=", "array", "(", ")", ";", "// Deletes the files", "foreach", "(", "$", "delFiles", "as", "$", "count", "=>", "$", "filename", ")", "{", "// Deletes from Registry Cache", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "[", "2", "]", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "registry", "[", "$", "filename", "[", "2", "]", "]", ")", ";", "}", "// Deletes from APC", "$", "this", "->", "backend", "->", "delete", "(", "$", "filename", "[", "2", "]", ")", ";", "$", "this", "->", "unRegisterIdentifier", "(", "$", "filename", "[", "0", "]", ",", "$", "filename", "[", "1", "]", ",", "$", "filename", "[", "2", "]", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "location", "]", "[", "$", "filename", "[", "0", "]", "]", "[", "$", "filename", "[", "2", "]", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "registry", "[", "$", "location", "]", "[", "$", "filename", "[", "0", "]", "]", "[", "$", "filename", "[", "2", "]", "]", ")", ";", "}", "// Deletes from the filesystem", "if", "(", "@", "unlink", "(", "$", "filename", "[", "2", "]", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not unlink cache file.'", ")", ";", "}", "$", "deletedIds", "[", "]", "=", "$", "filename", "[", "0", "]", ";", "}", "$", "this", "->", "storeSearchRegistry", "(", ")", ";", "return", "$", "deletedIds", ";", "}" ]
Deletes the data associated with $id or $attributes from the cache. @throws ezcBaseFilePermissionException If an already existsing cache file could not be unlinked. This exception means most likely that your cache directory has been corrupted by external influences (file permission change). @param string $id The item ID to purge @param array(string=>string) $attributes Attributes describing the data to restore @param bool $search Whether to search for items if not found directly
[ "Deletes", "the", "data", "associated", "with", "$id", "or", "$attributes", "from", "the", "cache", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L348-L400
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.validateLocation
protected function validateLocation() { if ( file_exists( $this->properties['location'] ) === false ) { throw new ezcBaseFileNotFoundException( $this->properties['location'], 'cache location' ); } if ( is_dir( $this->properties['location'] ) === false ) { throw new ezcBaseFileNotFoundException( $this->properties['location'], 'cache location', 'Cache location not a directory.' ); } if ( is_writeable( $this->properties['location'] ) === false ) { throw new ezcBaseFilePermissionException( $this->properties['location'], ezcBaseFileException::WRITE, 'Cache location is not a directory.' ); } }
php
protected function validateLocation() { if ( file_exists( $this->properties['location'] ) === false ) { throw new ezcBaseFileNotFoundException( $this->properties['location'], 'cache location' ); } if ( is_dir( $this->properties['location'] ) === false ) { throw new ezcBaseFileNotFoundException( $this->properties['location'], 'cache location', 'Cache location not a directory.' ); } if ( is_writeable( $this->properties['location'] ) === false ) { throw new ezcBaseFilePermissionException( $this->properties['location'], ezcBaseFileException::WRITE, 'Cache location is not a directory.' ); } }
[ "protected", "function", "validateLocation", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "properties", "[", "'location'", "]", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "this", "->", "properties", "[", "'location'", "]", ",", "'cache location'", ")", ";", "}", "if", "(", "is_dir", "(", "$", "this", "->", "properties", "[", "'location'", "]", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "this", "->", "properties", "[", "'location'", "]", ",", "'cache location'", ",", "'Cache location not a directory.'", ")", ";", "}", "if", "(", "is_writeable", "(", "$", "this", "->", "properties", "[", "'location'", "]", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "this", "->", "properties", "[", "'location'", "]", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Cache location is not a directory.'", ")", ";", "}", "}" ]
Checks the path in the location property exists, and is read-/writable. It throws an exception if not. @throws ezcBaseFileNotFoundException If the storage location does not exist. This should usually not happen, since {@link ezcCacheManager::createCache()} already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured. @throws ezcBaseFileNotFoundException If the storage location is not a directory. This should usually not happen, since {@link ezcCacheManager::createCache()} already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured. @throws ezcBaseFilePermissionException If the storage location is not writeable. This should usually not happen, since {@link ezcCacheManager::createCache()} already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured.
[ "Checks", "the", "path", "in", "the", "location", "property", "exists", "and", "is", "read", "-", "/", "writable", ".", "It", "throws", "an", "exception", "if", "not", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L425-L441
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php
ezcCacheStorageFileApcArray.calcLifetime
protected function calcLifetime( $filename, $useApc = false ) { $ttl = $this->options->ttl; // Calculate when the APC object was created if ( $useApc === true ) { // we've likely already looked this thing up in APC, so we'll grab the local object if ( isset( $this->registry[$filename] ) ) { $dataObj = $this->registry[$filename]; } else // otherwise we'll grab it from APC { $dataObj = $this->fetchObject( $filename ); } if ( is_object( $dataObj ) ) { if ( $ttl === false ) { return 1; } return ( ( $lifeTime = ( time() - $dataObj->mtime ) ) > $ttl ? $ttl - $lifeTime : 0 ); } else { return 0; } } // Calculate when the filesystem file was created else { if ( ( file_exists( $filename ) !== false ) && ( ( $modTime = @filemtime( $filename ) ) !== false ) ) { if ( $ttl === false ) { return 1; } return ( ( $lifeTime = ( time() - $modTime ) ) < $ttl ? $ttl - $lifeTime : 0 ); } else { return 0; } } }
php
protected function calcLifetime( $filename, $useApc = false ) { $ttl = $this->options->ttl; // Calculate when the APC object was created if ( $useApc === true ) { // we've likely already looked this thing up in APC, so we'll grab the local object if ( isset( $this->registry[$filename] ) ) { $dataObj = $this->registry[$filename]; } else // otherwise we'll grab it from APC { $dataObj = $this->fetchObject( $filename ); } if ( is_object( $dataObj ) ) { if ( $ttl === false ) { return 1; } return ( ( $lifeTime = ( time() - $dataObj->mtime ) ) > $ttl ? $ttl - $lifeTime : 0 ); } else { return 0; } } // Calculate when the filesystem file was created else { if ( ( file_exists( $filename ) !== false ) && ( ( $modTime = @filemtime( $filename ) ) !== false ) ) { if ( $ttl === false ) { return 1; } return ( ( $lifeTime = ( time() - $modTime ) ) < $ttl ? $ttl - $lifeTime : 0 ); } else { return 0; } } }
[ "protected", "function", "calcLifetime", "(", "$", "filename", ",", "$", "useApc", "=", "false", ")", "{", "$", "ttl", "=", "$", "this", "->", "options", "->", "ttl", ";", "// Calculate when the APC object was created", "if", "(", "$", "useApc", "===", "true", ")", "{", "// we've likely already looked this thing up in APC, so we'll grab the local object", "if", "(", "isset", "(", "$", "this", "->", "registry", "[", "$", "filename", "]", ")", ")", "{", "$", "dataObj", "=", "$", "this", "->", "registry", "[", "$", "filename", "]", ";", "}", "else", "// otherwise we'll grab it from APC", "{", "$", "dataObj", "=", "$", "this", "->", "fetchObject", "(", "$", "filename", ")", ";", "}", "if", "(", "is_object", "(", "$", "dataObj", ")", ")", "{", "if", "(", "$", "ttl", "===", "false", ")", "{", "return", "1", ";", "}", "return", "(", "(", "$", "lifeTime", "=", "(", "time", "(", ")", "-", "$", "dataObj", "->", "mtime", ")", ")", ">", "$", "ttl", "?", "$", "ttl", "-", "$", "lifeTime", ":", "0", ")", ";", "}", "else", "{", "return", "0", ";", "}", "}", "// Calculate when the filesystem file was created", "else", "{", "if", "(", "(", "file_exists", "(", "$", "filename", ")", "!==", "false", ")", "&&", "(", "(", "$", "modTime", "=", "@", "filemtime", "(", "$", "filename", ")", ")", "!==", "false", ")", ")", "{", "if", "(", "$", "ttl", "===", "false", ")", "{", "return", "1", ";", "}", "return", "(", "(", "$", "lifeTime", "=", "(", "time", "(", ")", "-", "$", "modTime", ")", ")", "<", "$", "ttl", "?", "$", "ttl", "-", "$", "lifeTime", ":", "0", ")", ";", "}", "else", "{", "return", "0", ";", "}", "}", "}" ]
Calculates the lifetime remaining for a cache object. If the TTL option is set to false, this method will always return 1 for existing items. @param string $filename The file to calculate the remaining lifetime for @param bool $useApc Use APC or not @return int The remaining lifetime in seconds (0 if no time remaining)
[ "Calculates", "the", "lifetime", "remaining", "for", "a", "cache", "object", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/apc_array.php#L453-L508