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
leedavis81/altr-ego
library/AltrEgo/Adapter/Php54.php
Php54._get
public function _get($name) { $object = $this->getObject(); $callable = function() use ($name, $object) { if (!property_exists($object, $name) && !method_exists($object, '__get')) { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($object)); } if (is_array($object->$name)) { $object->$name = new \ArrayObject($object->$name); } return $object->$name; }; return $this->breakScopeAndExecute($callable); }
php
public function _get($name) { $object = $this->getObject(); $callable = function() use ($name, $object) { if (!property_exists($object, $name) && !method_exists($object, '__get')) { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($object)); } if (is_array($object->$name)) { $object->$name = new \ArrayObject($object->$name); } return $object->$name; }; return $this->breakScopeAndExecute($callable); }
[ "public", "function", "_get", "(", "$", "name", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "$", "callable", "=", "function", "(", ")", "use", "(", "$", "name", ",", "$", "object", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "name", ")", "&&", "!", "method_exists", "(", "$", "object", ",", "'__get'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Property '", ".", "$", "name", ".", "' doesn\\'t exist on object of class '", ".", "get_class", "(", "$", "object", ")", ")", ";", "}", "if", "(", "is_array", "(", "$", "object", "->", "$", "name", ")", ")", "{", "$", "object", "->", "$", "name", "=", "new", "\\", "ArrayObject", "(", "$", "object", "->", "$", "name", ")", ";", "}", "return", "$", "object", "->", "$", "name", ";", "}", ";", "return", "$", "this", "->", "breakScopeAndExecute", "(", "$", "callable", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_get()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php54.php#L63-L78
leedavis81/altr-ego
library/AltrEgo/Adapter/Php54.php
Php54._set
public function _set($name, $value) { $object = $this->getObject(); $callable = function() use ($name, $value, $object) { if (!property_exists($object, $name) && !method_exists($object, '__set')) { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($object)); } $object->$name = $value; }; $this->breakScopeAndExecute($callable); }
php
public function _set($name, $value) { $object = $this->getObject(); $callable = function() use ($name, $value, $object) { if (!property_exists($object, $name) && !method_exists($object, '__set')) { throw new \Exception('Property ' . $name . ' doesn\'t exist on object of class ' . get_class($object)); } $object->$name = $value; }; $this->breakScopeAndExecute($callable); }
[ "public", "function", "_set", "(", "$", "name", ",", "$", "value", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "$", "callable", "=", "function", "(", ")", "use", "(", "$", "name", ",", "$", "value", ",", "$", "object", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "name", ")", "&&", "!", "method_exists", "(", "$", "object", ",", "'__set'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Property '", ".", "$", "name", ".", "' doesn\\'t exist on object of class '", ".", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "object", "->", "$", "name", "=", "$", "value", ";", "}", ";", "$", "this", "->", "breakScopeAndExecute", "(", "$", "callable", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_set()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php54.php#L83-L94
leedavis81/altr-ego
library/AltrEgo/Adapter/Php54.php
Php54._callStatic
public static function _callStatic($object, $name, $arguments) { if (is_object($object)) { $class = ($object instanceof AltrEgo) ? get_class($object->getObject()) : get_class($object); } elseif (!class_exists($object)) { throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'); } $callable = \Closure::bind(function() use ($name, $arguments, $class){ return call_user_func_array(array($class, $name), array($arguments)); }, null, $class); return $callable(); }
php
public static function _callStatic($object, $name, $arguments) { if (is_object($object)) { $class = ($object instanceof AltrEgo) ? get_class($object->getObject()) : get_class($object); } elseif (!class_exists($object)) { throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'); } $callable = \Closure::bind(function() use ($name, $arguments, $class){ return call_user_func_array(array($class, $name), array($arguments)); }, null, $class); return $callable(); }
[ "public", "static", "function", "_callStatic", "(", "$", "object", ",", "$", "name", ",", "$", "arguments", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "$", "class", "=", "(", "$", "object", "instanceof", "AltrEgo", ")", "?", "get_class", "(", "$", "object", "->", "getObject", "(", ")", ")", ":", "get_class", "(", "$", "object", ")", ";", "}", "elseif", "(", "!", "class_exists", "(", "$", "object", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name'", ")", ";", "}", "$", "callable", "=", "\\", "Closure", "::", "bind", "(", "function", "(", ")", "use", "(", "$", "name", ",", "$", "arguments", ",", "$", "class", ")", "{", "return", "call_user_func_array", "(", "array", "(", "$", "class", ",", "$", "name", ")", ",", "array", "(", "$", "arguments", ")", ")", ";", "}", ",", "null", ",", "$", "class", ")", ";", "return", "$", "callable", "(", ")", ";", "}" ]
(non-PHPdoc) @see AltrEgo\Adapter.AdapterInterface::_callStatic()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/leedavis81/altr-ego/blob/1556556a33c2b6caddef94444522c5bbffc217c7/library/AltrEgo/Adapter/Php54.php#L108-L121
spiral-modules/scaffolder
source/Scaffolder/AbstractCommand.php
AbstractCommand.createDeclaration
protected function createDeclaration(array $parameters = []): ClassDeclaration { return $this->container->get(FactoryInterface::class)->make( $this->config->declarationClass(static::ELEMENT), [ 'name' => $this->getClass(), 'comment' => (string)$this->option('comment') ] + $parameters + $this->config->declarationOptions(static::ELEMENT) ); }
php
protected function createDeclaration(array $parameters = []): ClassDeclaration { return $this->container->get(FactoryInterface::class)->make( $this->config->declarationClass(static::ELEMENT), [ 'name' => $this->getClass(), 'comment' => (string)$this->option('comment') ] + $parameters + $this->config->declarationOptions(static::ELEMENT) ); }
[ "protected", "function", "createDeclaration", "(", "array", "$", "parameters", "=", "[", "]", ")", ":", "ClassDeclaration", "{", "return", "$", "this", "->", "container", "->", "get", "(", "FactoryInterface", "::", "class", ")", "->", "make", "(", "$", "this", "->", "config", "->", "declarationClass", "(", "static", "::", "ELEMENT", ")", ",", "[", "'name'", "=>", "$", "this", "->", "getClass", "(", ")", ",", "'comment'", "=>", "(", "string", ")", "$", "this", "->", "option", "(", "'comment'", ")", "]", "+", "$", "parameters", "+", "$", "this", "->", "config", "->", "declarationOptions", "(", "static", "::", "ELEMENT", ")", ")", ";", "}" ]
@param array $parameters @return ClassDeclaration
[ "@param", "array", "$parameters" ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/AbstractCommand.php#L56-L65
spiral-modules/scaffolder
source/Scaffolder/AbstractCommand.php
AbstractCommand.writeDeclaration
protected function writeDeclaration(ClassDeclaration $declaration, string $type = null) { $type = $type ?? static::ELEMENT; $filename = $this->config->classFilename($type, $this->argument('name')); $filename = $this->files->normalizePath($filename); if ($this->files->exists($filename)) { $this->writeln( "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " . "file '<comment>{$filename}</comment>' already exists.</fg=red>" ); return; } //File declaration $file = new FileDeclaration( $this->config->classNamespace($type, $this->argument('name')) ); $file->setComment($this->config->headerLines()); $file->addElement($declaration); $this->files->write( $filename, $file->render(), FilesInterface::READONLY, true ); $this->writeln( "Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'." ); }
php
protected function writeDeclaration(ClassDeclaration $declaration, string $type = null) { $type = $type ?? static::ELEMENT; $filename = $this->config->classFilename($type, $this->argument('name')); $filename = $this->files->normalizePath($filename); if ($this->files->exists($filename)) { $this->writeln( "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " . "file '<comment>{$filename}</comment>' already exists.</fg=red>" ); return; } //File declaration $file = new FileDeclaration( $this->config->classNamespace($type, $this->argument('name')) ); $file->setComment($this->config->headerLines()); $file->addElement($declaration); $this->files->write( $filename, $file->render(), FilesInterface::READONLY, true ); $this->writeln( "Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'." ); }
[ "protected", "function", "writeDeclaration", "(", "ClassDeclaration", "$", "declaration", ",", "string", "$", "type", "=", "null", ")", "{", "$", "type", "=", "$", "type", "??", "static", "::", "ELEMENT", ";", "$", "filename", "=", "$", "this", "->", "config", "->", "classFilename", "(", "$", "type", ",", "$", "this", "->", "argument", "(", "'name'", ")", ")", ";", "$", "filename", "=", "$", "this", "->", "files", "->", "normalizePath", "(", "$", "filename", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "filename", ")", ")", "{", "$", "this", "->", "writeln", "(", "\"<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, \"", ".", "\"file '<comment>{$filename}</comment>' already exists.</fg=red>\"", ")", ";", "return", ";", "}", "//File declaration", "$", "file", "=", "new", "FileDeclaration", "(", "$", "this", "->", "config", "->", "classNamespace", "(", "$", "type", ",", "$", "this", "->", "argument", "(", "'name'", ")", ")", ")", ";", "$", "file", "->", "setComment", "(", "$", "this", "->", "config", "->", "headerLines", "(", ")", ")", ";", "$", "file", "->", "addElement", "(", "$", "declaration", ")", ";", "$", "this", "->", "files", "->", "write", "(", "$", "filename", ",", "$", "file", "->", "render", "(", ")", ",", "FilesInterface", "::", "READONLY", ",", "true", ")", ";", "$", "this", "->", "writeln", "(", "\"Declaration of '<info>{$declaration->getName()}</info>' \"", ".", "\"has been successfully written into '<comment>{$filename}</comment>'.\"", ")", ";", "}" ]
Write declaration into file. @param ClassDeclaration $declaration @param string $type If null static::ELEMENT to be used.
[ "Write", "declaration", "into", "file", "." ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/AbstractCommand.php#L86-L121
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.insert
public function insert($sessionId, $clientId) { $this->session_id = $sessionId; $this->client_id = $clientId; $this->time = time(); $ret = $this->_db->insertObject($this->_tbl, $this, 'session_id'); if (!$ret) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr())); return false; } else { return true; } }
php
public function insert($sessionId, $clientId) { $this->session_id = $sessionId; $this->client_id = $clientId; $this->time = time(); $ret = $this->_db->insertObject($this->_tbl, $this, 'session_id'); if (!$ret) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr())); return false; } else { return true; } }
[ "public", "function", "insert", "(", "$", "sessionId", ",", "$", "clientId", ")", "{", "$", "this", "->", "session_id", "=", "$", "sessionId", ";", "$", "this", "->", "client_id", "=", "$", "clientId", ";", "$", "this", "->", "time", "=", "time", "(", ")", ";", "$", "ret", "=", "$", "this", "->", "_db", "->", "insertObject", "(", "$", "this", "->", "_tbl", ",", "$", "this", ",", "'session_id'", ")", ";", "if", "(", "!", "$", "ret", ")", "{", "$", "this", "->", "setError", "(", "JText", "::", "sprintf", "(", "'JLIB_DATABASE_ERROR_STORE_FAILED'", ",", "strtolower", "(", "get_class", "(", "$", "this", ")", ")", ",", "$", "this", "->", "_db", "->", "stderr", "(", ")", ")", ")", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Insert a session @param string $sessionId The session id @param integer $clientId The id of the client application @return boolean True on success @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Insert", "a", "session" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L48-L66
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.update
public function update($updateNulls = false) { $this->time = time(); $ret = $this->_db->updateObject($this->_tbl, $this, 'session_id', $updateNulls); if (!$ret) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr())); return false; } else { return true; } }
php
public function update($updateNulls = false) { $this->time = time(); $ret = $this->_db->updateObject($this->_tbl, $this, 'session_id', $updateNulls); if (!$ret) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_STORE_FAILED', strtolower(get_class($this)), $this->_db->stderr())); return false; } else { return true; } }
[ "public", "function", "update", "(", "$", "updateNulls", "=", "false", ")", "{", "$", "this", "->", "time", "=", "time", "(", ")", ";", "$", "ret", "=", "$", "this", "->", "_db", "->", "updateObject", "(", "$", "this", "->", "_tbl", ",", "$", "this", ",", "'session_id'", ",", "$", "updateNulls", ")", ";", "if", "(", "!", "$", "ret", ")", "{", "$", "this", "->", "setError", "(", "JText", "::", "sprintf", "(", "'JLIB_DATABASE_ERROR_STORE_FAILED'", ",", "strtolower", "(", "get_class", "(", "$", "this", ")", ")", ",", "$", "this", "->", "_db", "->", "stderr", "(", ")", ")", ")", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Updates the session @param boolean $updateNulls True to update fields even if they are null. @return boolean True on success. @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Updates", "the", "session" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L78-L93
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.destroy
public function destroy($userId, $clientIds = array()) { $clientIds = implode(',', $clientIds); $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userId)) ->where($this->_db->quoteName('client_id') . ' IN (' . $clientIds . ')'); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->setError($this->_db->stderr()); return false; } return true; }
php
public function destroy($userId, $clientIds = array()) { $clientIds = implode(',', $clientIds); $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userId)) ->where($this->_db->quoteName('client_id') . ' IN (' . $clientIds . ')'); $this->_db->setQuery($query); if (!$this->_db->execute()) { $this->setError($this->_db->stderr()); return false; } return true; }
[ "public", "function", "destroy", "(", "$", "userId", ",", "$", "clientIds", "=", "array", "(", ")", ")", "{", "$", "clientIds", "=", "implode", "(", "','", ",", "$", "clientIds", ")", ";", "$", "query", "=", "$", "this", "->", "_db", "->", "getQuery", "(", "true", ")", "->", "delete", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "$", "this", "->", "_tbl", ")", ")", "->", "where", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "'userid'", ")", ".", "' = '", ".", "$", "this", "->", "_db", "->", "quote", "(", "$", "userId", ")", ")", "->", "where", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "'client_id'", ")", ".", "' IN ('", ".", "$", "clientIds", ".", "')'", ")", ";", "$", "this", "->", "_db", "->", "setQuery", "(", "$", "query", ")", ";", "if", "(", "!", "$", "this", "->", "_db", "->", "execute", "(", ")", ")", "{", "$", "this", "->", "setError", "(", "$", "this", "->", "_db", "->", "stderr", "(", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Destroys the pre-existing session @param integer $userId Identifier of the user for this session. @param array $clientIds Array of client ids for which session(s) will be destroyed @return boolean True on success. @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Destroys", "the", "pre", "-", "existing", "session" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L106-L124
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.purge
public function purge($maxLifetime = 1440) { $past = time() - $maxLifetime; $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('time') . ' < ' . (int) $past); $this->_db->setQuery($query); return $this->_db->execute(); }
php
public function purge($maxLifetime = 1440) { $past = time() - $maxLifetime; $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('time') . ' < ' . (int) $past); $this->_db->setQuery($query); return $this->_db->execute(); }
[ "public", "function", "purge", "(", "$", "maxLifetime", "=", "1440", ")", "{", "$", "past", "=", "time", "(", ")", "-", "$", "maxLifetime", ";", "$", "query", "=", "$", "this", "->", "_db", "->", "getQuery", "(", "true", ")", "->", "delete", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "$", "this", "->", "_tbl", ")", ")", "->", "where", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "'time'", ")", ".", "' < '", ".", "(", "int", ")", "$", "past", ")", ";", "$", "this", "->", "_db", "->", "setQuery", "(", "$", "query", ")", ";", "return", "$", "this", "->", "_db", "->", "execute", "(", ")", ";", "}" ]
Purge old sessions @param integer $maxLifetime Session age in seconds @return mixed Resource on success, null on fail @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Purge", "old", "sessions" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L136-L145
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.exists
public function exists($userid) { $query = $this->_db->getQuery(true) ->select('COUNT(userid)') ->from($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid)); $this->_db->setQuery($query); if (!$result = $this->_db->loadResult()) { $this->setError($this->_db->stderr()); return false; } return (boolean) $result; }
php
public function exists($userid) { $query = $this->_db->getQuery(true) ->select('COUNT(userid)') ->from($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($userid)); $this->_db->setQuery($query); if (!$result = $this->_db->loadResult()) { $this->setError($this->_db->stderr()); return false; } return (boolean) $result; }
[ "public", "function", "exists", "(", "$", "userid", ")", "{", "$", "query", "=", "$", "this", "->", "_db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'COUNT(userid)'", ")", "->", "from", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "$", "this", "->", "_tbl", ")", ")", "->", "where", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "'userid'", ")", ".", "' = '", ".", "$", "this", "->", "_db", "->", "quote", "(", "$", "userid", ")", ")", ";", "$", "this", "->", "_db", "->", "setQuery", "(", "$", "query", ")", ";", "if", "(", "!", "$", "result", "=", "$", "this", "->", "_db", "->", "loadResult", "(", ")", ")", "{", "$", "this", "->", "setError", "(", "$", "this", "->", "_db", "->", "stderr", "(", ")", ")", ";", "return", "false", ";", "}", "return", "(", "boolean", ")", "$", "result", ";", "}" ]
Find out if a user has one or more active sessions @param integer $userid The identifier of the user @return boolean True if a session for this user exists @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Find", "out", "if", "a", "user", "has", "one", "or", "more", "active", "sessions" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L157-L173
joomlatools/joomlatools-platform-legacy
code/table/session.php
JTableSession.delete
public function delete($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->$k = $oid; } $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->$k)); $this->_db->setQuery($query); $this->_db->execute(); return true; }
php
public function delete($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->$k = $oid; } $query = $this->_db->getQuery(true) ->delete($this->_db->quoteName($this->_tbl)) ->where($this->_db->quoteName($this->_tbl_key) . ' = ' . $this->_db->quote($this->$k)); $this->_db->setQuery($query); $this->_db->execute(); return true; }
[ "public", "function", "delete", "(", "$", "oid", "=", "null", ")", "{", "$", "k", "=", "$", "this", "->", "_tbl_key", ";", "if", "(", "$", "oid", ")", "{", "$", "this", "->", "$", "k", "=", "$", "oid", ";", "}", "$", "query", "=", "$", "this", "->", "_db", "->", "getQuery", "(", "true", ")", "->", "delete", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "$", "this", "->", "_tbl", ")", ")", "->", "where", "(", "$", "this", "->", "_db", "->", "quoteName", "(", "$", "this", "->", "_tbl_key", ")", ".", "' = '", ".", "$", "this", "->", "_db", "->", "quote", "(", "$", "this", "->", "$", "k", ")", ")", ";", "$", "this", "->", "_db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "this", "->", "_db", "->", "execute", "(", ")", ";", "return", "true", ";", "}" ]
Overloaded delete method We must override it because of the non-integer primary key @param integer $oid The object id (optional). @return mixed True if successful otherwise an error message @since 11.1 @deprecated 13.3 Use SQL queries to interact with the session table.
[ "Overloaded", "delete", "method" ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/table/session.php#L187-L204
zhiyicx/thinksns-theme-stv1
_static/js/um/php/Uploader.class.php
Uploader.upFile
private function upFile($base64) { //处理base64上传 if ('base64' == $base64) { $content = $_POST[ $this->fileField ]; $this->base64ToImage($content); return; } //处理普通上传 $file = $this->file = $_FILES[ $this->fileField ]; if (!$file) { $this->stateInfo = $this->getStateInfo('POST'); return; } if ($this->file[ 'error' ]) { $this->stateInfo = $this->getStateInfo($file[ 'error' ]); return; } if (!is_uploaded_file($file[ 'tmp_name' ])) { $this->stateInfo = $this->getStateInfo('UNKNOWN'); return; } $this->oriName = $file[ 'name' ]; $this->fileSize = $file[ 'size' ]; $this->fileType = $this->getFileExt(); if (!$this->checkSize()) { $this->stateInfo = $this->getStateInfo('SIZE'); return; } if (!$this->checkType()) { $this->stateInfo = $this->getStateInfo('TYPE'); return; } $folder = $this->getFolder(); if ($folder === false) { $this->stateInfo = $this->getStateInfo('DIR_ERROR'); return; } $this->fullName = $folder.'/'.$this->getName(); if ($this->stateInfo == $this->stateMap[ 0 ]) { if (!move_uploaded_file($file[ 'tmp_name' ], $this->fullName)) { $this->stateInfo = $this->getStateInfo('MOVE'); } } }
php
private function upFile($base64) { //处理base64上传 if ('base64' == $base64) { $content = $_POST[ $this->fileField ]; $this->base64ToImage($content); return; } //处理普通上传 $file = $this->file = $_FILES[ $this->fileField ]; if (!$file) { $this->stateInfo = $this->getStateInfo('POST'); return; } if ($this->file[ 'error' ]) { $this->stateInfo = $this->getStateInfo($file[ 'error' ]); return; } if (!is_uploaded_file($file[ 'tmp_name' ])) { $this->stateInfo = $this->getStateInfo('UNKNOWN'); return; } $this->oriName = $file[ 'name' ]; $this->fileSize = $file[ 'size' ]; $this->fileType = $this->getFileExt(); if (!$this->checkSize()) { $this->stateInfo = $this->getStateInfo('SIZE'); return; } if (!$this->checkType()) { $this->stateInfo = $this->getStateInfo('TYPE'); return; } $folder = $this->getFolder(); if ($folder === false) { $this->stateInfo = $this->getStateInfo('DIR_ERROR'); return; } $this->fullName = $folder.'/'.$this->getName(); if ($this->stateInfo == $this->stateMap[ 0 ]) { if (!move_uploaded_file($file[ 'tmp_name' ], $this->fullName)) { $this->stateInfo = $this->getStateInfo('MOVE'); } } }
[ "private", "function", "upFile", "(", "$", "base64", ")", "{", "//处理base64上传", "if", "(", "'base64'", "==", "$", "base64", ")", "{", "$", "content", "=", "$", "_POST", "[", "$", "this", "->", "fileField", "]", ";", "$", "this", "->", "base64ToImage", "(", "$", "content", ")", ";", "return", ";", "}", "//处理普通上传", "$", "file", "=", "$", "this", "->", "file", "=", "$", "_FILES", "[", "$", "this", "->", "fileField", "]", ";", "if", "(", "!", "$", "file", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'POST'", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "file", "[", "'error'", "]", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "$", "file", "[", "'error'", "]", ")", ";", "return", ";", "}", "if", "(", "!", "is_uploaded_file", "(", "$", "file", "[", "'tmp_name'", "]", ")", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'UNKNOWN'", ")", ";", "return", ";", "}", "$", "this", "->", "oriName", "=", "$", "file", "[", "'name'", "]", ";", "$", "this", "->", "fileSize", "=", "$", "file", "[", "'size'", "]", ";", "$", "this", "->", "fileType", "=", "$", "this", "->", "getFileExt", "(", ")", ";", "if", "(", "!", "$", "this", "->", "checkSize", "(", ")", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'SIZE'", ")", ";", "return", ";", "}", "if", "(", "!", "$", "this", "->", "checkType", "(", ")", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'TYPE'", ")", ";", "return", ";", "}", "$", "folder", "=", "$", "this", "->", "getFolder", "(", ")", ";", "if", "(", "$", "folder", "===", "false", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'DIR_ERROR'", ")", ";", "return", ";", "}", "$", "this", "->", "fullName", "=", "$", "folder", ".", "'/'", ".", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "$", "this", "->", "stateInfo", "==", "$", "this", "->", "stateMap", "[", "0", "]", ")", "{", "if", "(", "!", "move_uploaded_file", "(", "$", "file", "[", "'tmp_name'", "]", ",", "$", "this", "->", "fullName", ")", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'MOVE'", ")", ";", "}", "}", "}" ]
上传文件的主处理方法 @param $base64 @return mixed
[ "上传文件的主处理方法" ]
train
https://github.com/zhiyicx/thinksns-theme-stv1/blob/e250d1eb7a6af9390cc657bc1c2f9072b81ac0c9/_static/js/um/php/Uploader.class.php#L56-L114
zhiyicx/thinksns-theme-stv1
_static/js/um/php/Uploader.class.php
Uploader.base64ToImage
private function base64ToImage($base64Data) { $img = base64_decode($base64Data); $this->fileName = time().rand(1, 10000).'.png'; $this->fullName = $this->getFolder().'/'.$this->fileName; if (!file_put_contents($this->fullName, $img)) { $this->stateInfo = $this->getStateInfo('IO'); return; } $this->oriName = ''; $this->fileSize = strlen($img); $this->fileType = '.png'; }
php
private function base64ToImage($base64Data) { $img = base64_decode($base64Data); $this->fileName = time().rand(1, 10000).'.png'; $this->fullName = $this->getFolder().'/'.$this->fileName; if (!file_put_contents($this->fullName, $img)) { $this->stateInfo = $this->getStateInfo('IO'); return; } $this->oriName = ''; $this->fileSize = strlen($img); $this->fileType = '.png'; }
[ "private", "function", "base64ToImage", "(", "$", "base64Data", ")", "{", "$", "img", "=", "base64_decode", "(", "$", "base64Data", ")", ";", "$", "this", "->", "fileName", "=", "time", "(", ")", ".", "rand", "(", "1", ",", "10000", ")", ".", "'.png'", ";", "$", "this", "->", "fullName", "=", "$", "this", "->", "getFolder", "(", ")", ".", "'/'", ".", "$", "this", "->", "fileName", ";", "if", "(", "!", "file_put_contents", "(", "$", "this", "->", "fullName", ",", "$", "img", ")", ")", "{", "$", "this", "->", "stateInfo", "=", "$", "this", "->", "getStateInfo", "(", "'IO'", ")", ";", "return", ";", "}", "$", "this", "->", "oriName", "=", "''", ";", "$", "this", "->", "fileSize", "=", "strlen", "(", "$", "img", ")", ";", "$", "this", "->", "fileType", "=", "'.png'", ";", "}" ]
处理base64编码的图片上传 @param $base64Data @return mixed
[ "处理base64编码的图片上传" ]
train
https://github.com/zhiyicx/thinksns-theme-stv1/blob/e250d1eb7a6af9390cc657bc1c2f9072b81ac0c9/_static/js/um/php/Uploader.class.php#L121-L134
zhiyicx/thinksns-theme-stv1
_static/js/um/php/Uploader.class.php
Uploader.getFolder
private function getFolder() { $pathStr = $this->config[ 'savePath' ]; if (strrchr($pathStr, '/') != '/') { $pathStr .= '/'; } $pathStr .= date('Ymd'); if (!file_exists($pathStr)) { if (!mkdir($pathStr, 0777, true)) { return false; } } return $pathStr; }
php
private function getFolder() { $pathStr = $this->config[ 'savePath' ]; if (strrchr($pathStr, '/') != '/') { $pathStr .= '/'; } $pathStr .= date('Ymd'); if (!file_exists($pathStr)) { if (!mkdir($pathStr, 0777, true)) { return false; } } return $pathStr; }
[ "private", "function", "getFolder", "(", ")", "{", "$", "pathStr", "=", "$", "this", "->", "config", "[", "'savePath'", "]", ";", "if", "(", "strrchr", "(", "$", "pathStr", ",", "'/'", ")", "!=", "'/'", ")", "{", "$", "pathStr", ".=", "'/'", ";", "}", "$", "pathStr", ".=", "date", "(", "'Ymd'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "pathStr", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "pathStr", ",", "0777", ",", "true", ")", ")", "{", "return", "false", ";", "}", "}", "return", "$", "pathStr", ";", "}" ]
按照日期自动创建存储文件夹 @return string
[ "按照日期自动创建存储文件夹" ]
train
https://github.com/zhiyicx/thinksns-theme-stv1/blob/e250d1eb7a6af9390cc657bc1c2f9072b81ac0c9/_static/js/um/php/Uploader.class.php#L202-L216
yuncms/framework
src/admin/models/UserSearch.php
UserSearch.search
public function search($params) { $query = User::find()->orderBy(['id' => SORT_DESC]); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere([ 'id' => $this->id, ]); if ($this->created_at !== null) { $date = Carbon::parse($this->created_at); $query->andWhere(['between', 'created_at', $date->timestamp, $date->addDays(1)->timestamp]); } $query->andFilterWhere(['like', 'username', $this->username]) ->andFilterWhere(['like', 'email', $this->email]) ->andFilterWhere(['registration_ip' => $this->registration_ip]); return $dataProvider; }
php
public function search($params) { $query = User::find()->orderBy(['id' => SORT_DESC]); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere([ 'id' => $this->id, ]); if ($this->created_at !== null) { $date = Carbon::parse($this->created_at); $query->andWhere(['between', 'created_at', $date->timestamp, $date->addDays(1)->timestamp]); } $query->andFilterWhere(['like', 'username', $this->username]) ->andFilterWhere(['like', 'email', $this->email]) ->andFilterWhere(['registration_ip' => $this->registration_ip]); return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "query", "=", "User", "::", "find", "(", ")", "->", "orderBy", "(", "[", "'id'", "=>", "SORT_DESC", "]", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", "]", ")", ";", "if", "(", "!", "(", "$", "this", "->", "load", "(", "$", "params", ")", "&&", "$", "this", "->", "validate", "(", ")", ")", ")", "{", "return", "$", "dataProvider", ";", "}", "$", "query", "->", "andFilterWhere", "(", "[", "'id'", "=>", "$", "this", "->", "id", ",", "]", ")", ";", "if", "(", "$", "this", "->", "created_at", "!==", "null", ")", "{", "$", "date", "=", "Carbon", "::", "parse", "(", "$", "this", "->", "created_at", ")", ";", "$", "query", "->", "andWhere", "(", "[", "'between'", ",", "'created_at'", ",", "$", "date", "->", "timestamp", ",", "$", "date", "->", "addDays", "(", "1", ")", "->", "timestamp", "]", ")", ";", "}", "$", "query", "->", "andFilterWhere", "(", "[", "'like'", ",", "'username'", ",", "$", "this", "->", "username", "]", ")", "->", "andFilterWhere", "(", "[", "'like'", ",", "'email'", ",", "$", "this", "->", "email", "]", ")", "->", "andFilterWhere", "(", "[", "'registration_ip'", "=>", "$", "this", "->", "registration_ip", "]", ")", ";", "return", "$", "dataProvider", ";", "}" ]
@param $params @return ActiveDataProvider
[ "@param", "$params" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/UserSearch.php#L63-L89
yuncms/framework
src/admin/controllers/AssignmentController.php
AssignmentController.findModel
protected function findModel($id) { /** @var \yii\web\IdentityInterface $class */ $class = $this->userClassName; if (($user = $class::findIdentity($id)) !== null) { return new AdminAssignment($id, $user); } else { throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.')); } }
php
protected function findModel($id) { /** @var \yii\web\IdentityInterface $class */ $class = $this->userClassName; if (($user = $class::findIdentity($id)) !== null) { return new AdminAssignment($id, $user); } else { throw new NotFoundHttpException(Yii::t('yuncms', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "/** @var \\yii\\web\\IdentityInterface $class */", "$", "class", "=", "$", "this", "->", "userClassName", ";", "if", "(", "(", "$", "user", "=", "$", "class", "::", "findIdentity", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "new", "AdminAssignment", "(", "$", "id", ",", "$", "user", ")", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "Yii", "::", "t", "(", "'yuncms'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the Assignment model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return AdminAssignment the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "Assignment", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/controllers/AssignmentController.php#L127-L136
steeffeen/FancyManiaLinks
FML/Controls/FrameInstance.php
FrameInstance.setModelId
public function setModelId($modelId) { $this->modelId = (string)$modelId; $this->model = null; return $this; }
php
public function setModelId($modelId) { $this->modelId = (string)$modelId; $this->model = null; return $this; }
[ "public", "function", "setModelId", "(", "$", "modelId", ")", "{", "$", "this", "->", "modelId", "=", "(", "string", ")", "$", "modelId", ";", "$", "this", "->", "model", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set the FrameModel id @api @param string $modelId FrameModel id @return static
[ "Set", "the", "FrameModel", "id" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/FrameInstance.php#L74-L79
steeffeen/FancyManiaLinks
FML/Controls/FrameInstance.php
FrameInstance.setModel
public function setModel(FrameModel $frameModel) { $this->modelId = null; $this->model = $frameModel; return $this; }
php
public function setModel(FrameModel $frameModel) { $this->modelId = null; $this->model = $frameModel; return $this; }
[ "public", "function", "setModel", "(", "FrameModel", "$", "frameModel", ")", "{", "$", "this", "->", "modelId", "=", "null", ";", "$", "this", "->", "model", "=", "$", "frameModel", ";", "return", "$", "this", ";", "}" ]
Set the FrameModel @api @param FrameModel $frameModel FrameModel @return static
[ "Set", "the", "FrameModel" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/FrameInstance.php#L99-L104
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.escapeText
public static function escapeText($text, $addApostrophes = true) { $dangers = array('\\', '"', "\n"); $replacements = array('\\\\', '\\"', '\\n'); $escapedText = str_ireplace($dangers, $replacements, $text); if ($addApostrophes) { $escapedText = '"' . $escapedText . '"'; } return $escapedText; }
php
public static function escapeText($text, $addApostrophes = true) { $dangers = array('\\', '"', "\n"); $replacements = array('\\\\', '\\"', '\\n'); $escapedText = str_ireplace($dangers, $replacements, $text); if ($addApostrophes) { $escapedText = '"' . $escapedText . '"'; } return $escapedText; }
[ "public", "static", "function", "escapeText", "(", "$", "text", ",", "$", "addApostrophes", "=", "true", ")", "{", "$", "dangers", "=", "array", "(", "'\\\\'", ",", "'\"'", ",", "\"\\n\"", ")", ";", "$", "replacements", "=", "array", "(", "'\\\\\\\\'", ",", "'\\\\\"'", ",", "'\\\\n'", ")", ";", "$", "escapedText", "=", "str_ireplace", "(", "$", "dangers", ",", "$", "replacements", ",", "$", "text", ")", ";", "if", "(", "$", "addApostrophes", ")", "{", "$", "escapedText", "=", "'\"'", ".", "$", "escapedText", ".", "'\"'", ";", "}", "return", "$", "escapedText", ";", "}" ]
Escape dangerous characters in the given text @api @param string $text Text to escape @param bool $addApostrophes (optional) Add apostrophes before and after the text @return string
[ "Escape", "dangerous", "characters", "in", "the", "given", "text" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L52-L61
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getReal
public static function getReal($value) { $value = (float)$value; $stringVal = (string)$value; if (!fmod($value, 1)) { $stringVal .= "."; } return $stringVal; }
php
public static function getReal($value) { $value = (float)$value; $stringVal = (string)$value; if (!fmod($value, 1)) { $stringVal .= "."; } return $stringVal; }
[ "public", "static", "function", "getReal", "(", "$", "value", ")", "{", "$", "value", "=", "(", "float", ")", "$", "value", ";", "$", "stringVal", "=", "(", "string", ")", "$", "value", ";", "if", "(", "!", "fmod", "(", "$", "value", ",", "1", ")", ")", "{", "$", "stringVal", ".=", "\".\"", ";", "}", "return", "$", "stringVal", ";", "}" ]
Get the 'Real' string representation of the given value @api @param float $value Float value to convert to a ManiaScript 'Real' @return string
[ "Get", "the", "Real", "string", "representation", "of", "the", "given", "value" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L105-L113
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getVec2
public static function getVec2($valueX, $valueY = null) { if (is_array($valueX)) { $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); } return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . ">"; }
php
public static function getVec2($valueX, $valueY = null) { if (is_array($valueX)) { $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); } return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . ">"; }
[ "public", "static", "function", "getVec2", "(", "$", "valueX", ",", "$", "valueY", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "valueX", ")", ")", "{", "$", "valueY", "=", "(", "isset", "(", "$", "valueX", "[", "1", "]", ")", "?", "$", "valueX", "[", "1", "]", ":", "0.", ")", ";", "$", "valueX", "=", "(", "isset", "(", "$", "valueX", "[", "0", "]", ")", "?", "$", "valueX", "[", "0", "]", ":", "0.", ")", ";", "}", "return", "\"<\"", ".", "static", "::", "getReal", "(", "$", "valueX", ")", ".", "\",\"", ".", "static", "::", "getReal", "(", "$", "valueY", ")", ".", "\">\"", ";", "}" ]
Get the Vec3 representation for the given values @api @param float|float[] $valueX Value X @param float $valueY (optional) Value Y @return string
[ "Get", "the", "Vec3", "representation", "for", "the", "given", "values" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L139-L146
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getVec3
public static function getVec3($valueX, $valueY = null, $valueZ = null) { if (is_array($valueX)) { $valueZ = (isset($valueX[2]) ? $valueX[2] : 0.); $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); } return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . "," . static::getReal($valueZ) . ">"; }
php
public static function getVec3($valueX, $valueY = null, $valueZ = null) { if (is_array($valueX)) { $valueZ = (isset($valueX[2]) ? $valueX[2] : 0.); $valueY = (isset($valueX[1]) ? $valueX[1] : 0.); $valueX = (isset($valueX[0]) ? $valueX[0] : 0.); } return "<" . static::getReal($valueX) . "," . static::getReal($valueY) . "," . static::getReal($valueZ) . ">"; }
[ "public", "static", "function", "getVec3", "(", "$", "valueX", ",", "$", "valueY", "=", "null", ",", "$", "valueZ", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "valueX", ")", ")", "{", "$", "valueZ", "=", "(", "isset", "(", "$", "valueX", "[", "2", "]", ")", "?", "$", "valueX", "[", "2", "]", ":", "0.", ")", ";", "$", "valueY", "=", "(", "isset", "(", "$", "valueX", "[", "1", "]", ")", "?", "$", "valueX", "[", "1", "]", ":", "0.", ")", ";", "$", "valueX", "=", "(", "isset", "(", "$", "valueX", "[", "0", "]", ")", "?", "$", "valueX", "[", "0", "]", ":", "0.", ")", ";", "}", "return", "\"<\"", ".", "static", "::", "getReal", "(", "$", "valueX", ")", ".", "\",\"", ".", "static", "::", "getReal", "(", "$", "valueY", ")", ".", "\",\"", ".", "static", "::", "getReal", "(", "$", "valueZ", ")", ".", "\">\"", ";", "}" ]
Get the Vec3 representation for the given values @api @param float|float[] $valueX Value X @param float $valueY (optional) Value Y @param float $valueZ (optional) Value Z @return string
[ "Get", "the", "Vec3", "representation", "for", "the", "given", "values" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L157-L165
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getArray
public static function getArray(array $array, $associative = true) { $arrayText = "["; $index = 0; $count = count($array); foreach ($array as $key => $value) { if ($associative) { $arrayText .= static::getValue($key); $arrayText .= " => "; } $arrayText .= static::getValue($value); if ($index < $count - 1) { $arrayText .= ", "; $index++; } } return $arrayText . "]"; }
php
public static function getArray(array $array, $associative = true) { $arrayText = "["; $index = 0; $count = count($array); foreach ($array as $key => $value) { if ($associative) { $arrayText .= static::getValue($key); $arrayText .= " => "; } $arrayText .= static::getValue($value); if ($index < $count - 1) { $arrayText .= ", "; $index++; } } return $arrayText . "]"; }
[ "public", "static", "function", "getArray", "(", "array", "$", "array", ",", "$", "associative", "=", "true", ")", "{", "$", "arrayText", "=", "\"[\"", ";", "$", "index", "=", "0", ";", "$", "count", "=", "count", "(", "$", "array", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "associative", ")", "{", "$", "arrayText", ".=", "static", "::", "getValue", "(", "$", "key", ")", ";", "$", "arrayText", ".=", "\" => \"", ";", "}", "$", "arrayText", ".=", "static", "::", "getValue", "(", "$", "value", ")", ";", "if", "(", "$", "index", "<", "$", "count", "-", "1", ")", "{", "$", "arrayText", ".=", "\", \"", ";", "$", "index", "++", ";", "}", "}", "return", "$", "arrayText", ".", "\"]\"", ";", "}" ]
Get the string representation of the given array @api @param array $array Array to convert to a ManiaScript array @param bool $associative (optional) Whether the array should be associative @return string
[ "Get", "the", "string", "representation", "of", "the", "given", "array" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L175-L192
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getValue
public static function getValue($value) { if (is_string($value)) { return static::escapeText($value); } if (is_bool($value)) { return static::getBoolean($value); } if (is_array($value)) { return static::getArray($value); } return $value; }
php
public static function getValue($value) { if (is_string($value)) { return static::escapeText($value); } if (is_bool($value)) { return static::getBoolean($value); } if (is_array($value)) { return static::getArray($value); } return $value; }
[ "public", "static", "function", "getValue", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "static", "::", "escapeText", "(", "$", "value", ")", ";", "}", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "return", "static", "::", "getBoolean", "(", "$", "value", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "static", "::", "getArray", "(", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
Get the string representation for the given value @api @param mixed $value Value @return string
[ "Get", "the", "string", "representation", "for", "the", "given", "value" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L201-L213
steeffeen/FancyManiaLinks
FML/Script/Builder.php
Builder.getInclude
public static function getInclude($file, $namespace = null) { if (!$namespace && stripos($file, ".") === false) { $namespace = $file; } $file = static::escapeText($file); $includeText = "#Include {$file}"; if ($namespace) { $includeText .= " as {$namespace}"; } return $includeText . " "; }
php
public static function getInclude($file, $namespace = null) { if (!$namespace && stripos($file, ".") === false) { $namespace = $file; } $file = static::escapeText($file); $includeText = "#Include {$file}"; if ($namespace) { $includeText .= " as {$namespace}"; } return $includeText . " "; }
[ "public", "static", "function", "getInclude", "(", "$", "file", ",", "$", "namespace", "=", "null", ")", "{", "if", "(", "!", "$", "namespace", "&&", "stripos", "(", "$", "file", ",", "\".\"", ")", "===", "false", ")", "{", "$", "namespace", "=", "$", "file", ";", "}", "$", "file", "=", "static", "::", "escapeText", "(", "$", "file", ")", ";", "$", "includeText", "=", "\"#Include\t{$file}\"", ";", "if", "(", "$", "namespace", ")", "{", "$", "includeText", ".=", "\"\tas {$namespace}\"", ";", "}", "return", "$", "includeText", ".", "\"\n\"", ";", "}" ]
Get the include command for the given file and namespace @api @param string $file Include file @param string $namespace (optional) Include namespace @return string
[ "Get", "the", "include", "command", "for", "the", "given", "file", "and", "namespace" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Builder.php#L223-L235
ppetermann/king23
src/Mongo/MongoService.php
MongoService.getByCriteria
public function getByCriteria($collection, $criteria) { if ($data = $this->findOne($collection, $criteria)) { /** @var MongoObject $obj */ $obj = $this->container->get( $this->classMap->getClassForResult($collection, $data) ); $obj->setCollection($collection); $obj->loadFromArray($data); return $obj; } return null; }
php
public function getByCriteria($collection, $criteria) { if ($data = $this->findOne($collection, $criteria)) { /** @var MongoObject $obj */ $obj = $this->container->get( $this->classMap->getClassForResult($collection, $data) ); $obj->setCollection($collection); $obj->loadFromArray($data); return $obj; } return null; }
[ "public", "function", "getByCriteria", "(", "$", "collection", ",", "$", "criteria", ")", "{", "if", "(", "$", "data", "=", "$", "this", "->", "findOne", "(", "$", "collection", ",", "$", "criteria", ")", ")", "{", "/** @var MongoObject $obj */", "$", "obj", "=", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "classMap", "->", "getClassForResult", "(", "$", "collection", ",", "$", "data", ")", ")", ";", "$", "obj", "->", "setCollection", "(", "$", "collection", ")", ";", "$", "obj", "->", "loadFromArray", "(", "$", "data", ")", ";", "return", "$", "obj", ";", "}", "return", "null", ";", "}" ]
convenience method to retrieve object by criteria, should be used in public static method by the derived class @param string $collection @param array $criteria @return MongoObject @throws \MongoException
[ "convenience", "method", "to", "retrieve", "object", "by", "criteria", "should", "be", "used", "in", "public", "static", "method", "by", "the", "derived", "class" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L92-L107
ppetermann/king23
src/Mongo/MongoService.php
MongoService.aggregate
public function aggregate($collection, array $pipeline, $options = []) { $data = $this->dbConnection->selectCollection($collection)->aggregate($pipeline); if ($data['ok'] != 1) { throw new Exception("Tool Aggregation Error: ".$data['errmsg'], $data['code']); } return $data['result']; }
php
public function aggregate($collection, array $pipeline, $options = []) { $data = $this->dbConnection->selectCollection($collection)->aggregate($pipeline); if ($data['ok'] != 1) { throw new Exception("Tool Aggregation Error: ".$data['errmsg'], $data['code']); } return $data['result']; }
[ "public", "function", "aggregate", "(", "$", "collection", ",", "array", "$", "pipeline", ",", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "$", "this", "->", "dbConnection", "->", "selectCollection", "(", "$", "collection", ")", "->", "aggregate", "(", "$", "pipeline", ")", ";", "if", "(", "$", "data", "[", "'ok'", "]", "!=", "1", ")", "{", "throw", "new", "Exception", "(", "\"Tool Aggregation Error: \"", ".", "$", "data", "[", "'errmsg'", "]", ",", "$", "data", "[", "'code'", "]", ")", ";", "}", "return", "$", "data", "[", "'result'", "]", ";", "}" ]
Run Aggregation through the Aggregation Pipeline @param string $collection @param array $pipeline @param array $options @return mixed @throws Exception
[ "Run", "Aggregation", "through", "the", "Aggregation", "Pipeline" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L137-L145
ppetermann/king23
src/Mongo/MongoService.php
MongoService.findOne
public function findOne($collection, array $criteria, array $fields = []) { return $this->dbConnection->selectCollection($collection)->findOne($criteria, $fields); }
php
public function findOne($collection, array $criteria, array $fields = []) { return $this->dbConnection->selectCollection($collection)->findOne($criteria, $fields); }
[ "public", "function", "findOne", "(", "$", "collection", ",", "array", "$", "criteria", ",", "array", "$", "fields", "=", "[", "]", ")", "{", "return", "$", "this", "->", "dbConnection", "->", "selectCollection", "(", "$", "collection", ")", "->", "findOne", "(", "$", "criteria", ",", "$", "fields", ")", ";", "}" ]
returns the first found matching document @param string $collection @param array $criteria @param array $fields @return array @throws \Exception
[ "returns", "the", "first", "found", "matching", "document" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L168-L171
ppetermann/king23
src/Mongo/MongoService.php
MongoService.newObject
public function newObject($collection) { /** @var MongoObject $obj */ $obj =$this->container->get($this->classMap->getClassForResult($collection, [])); $obj->setCollection($collection); return $obj; }
php
public function newObject($collection) { /** @var MongoObject $obj */ $obj =$this->container->get($this->classMap->getClassForResult($collection, [])); $obj->setCollection($collection); return $obj; }
[ "public", "function", "newObject", "(", "$", "collection", ")", "{", "/** @var MongoObject $obj */", "$", "obj", "=", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "classMap", "->", "getClassForResult", "(", "$", "collection", ",", "[", "]", ")", ")", ";", "$", "obj", "->", "setCollection", "(", "$", "collection", ")", ";", "return", "$", "obj", ";", "}" ]
conveniant method to create new instances @param string $collection @return MongoObject @throws \MongoException
[ "conveniant", "method", "to", "create", "new", "instances" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/Mongo/MongoService.php#L179-L186
ruvents/ruwork-upload-bundle
Source/Handler/StringSourceHandler.php
StringSourceHandler.write
public function write($source, string $target): void { $this->filesystem->copy($source, $target, true); }
php
public function write($source, string $target): void { $this->filesystem->copy($source, $target, true); }
[ "public", "function", "write", "(", "$", "source", ",", "string", "$", "target", ")", ":", "void", "{", "$", "this", "->", "filesystem", "->", "copy", "(", "$", "source", ",", "$", "target", ",", "true", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Source/Handler/StringSourceHandler.php#L29-L32
aedart/laravel-helpers
src/Traits/Logging/LogTrait.php
LogTrait.getLog
public function getLog(): ?Log { if (!$this->hasLog()) { $this->setLog($this->getDefaultLog()); } return $this->log; }
php
public function getLog(): ?Log { if (!$this->hasLog()) { $this->setLog($this->getDefaultLog()); } return $this->log; }
[ "public", "function", "getLog", "(", ")", ":", "?", "Log", "{", "if", "(", "!", "$", "this", "->", "hasLog", "(", ")", ")", "{", "$", "this", "->", "setLog", "(", "$", "this", "->", "getDefaultLog", "(", ")", ")", ";", "}", "return", "$", "this", "->", "log", ";", "}" ]
Get log If no log has been set, this method will set and return a default log, if any such value is available @see getDefaultLog() @return Log|null log or null if none log has been set
[ "Get", "log" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Logging/LogTrait.php#L53-L59
shinjin/freezer
src/Storage/ChainStorage.php
ChainStorage.doStore
protected function doStore(array $frozenObject) { $result = null; foreach ($this->storageChain as $storage) { if (!$storage instanceof \Freezer\Storage) { throw new \InvalidArgumentException( 'Storage chain contains invalid storage type' ); } $result = $storage->doStore($frozenObject); } return $result; }
php
protected function doStore(array $frozenObject) { $result = null; foreach ($this->storageChain as $storage) { if (!$storage instanceof \Freezer\Storage) { throw new \InvalidArgumentException( 'Storage chain contains invalid storage type' ); } $result = $storage->doStore($frozenObject); } return $result; }
[ "protected", "function", "doStore", "(", "array", "$", "frozenObject", ")", "{", "$", "result", "=", "null", ";", "foreach", "(", "$", "this", "->", "storageChain", "as", "$", "storage", ")", "{", "if", "(", "!", "$", "storage", "instanceof", "\\", "Freezer", "\\", "Storage", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Storage chain contains invalid storage type'", ")", ";", "}", "$", "result", "=", "$", "storage", "->", "doStore", "(", "$", "frozenObject", ")", ";", "}", "return", "$", "result", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Storage/ChainStorage.php#L35-L50
shinjin/freezer
src/Storage/ChainStorage.php
ChainStorage.doFetch
protected function doFetch($id, array &$objects = array()) { foreach ($this->storageChain as $key => $storage) { $frozenObject = $storage->doFetch($id, $objects); if ($frozenObject !== false) { $isDirty = &$frozenObject['objects'][$id]['isDirty']; $isDirty = true; for ($subKey = $key - 1; $subKey >= 0; $subKey--) { $this->storageChain[$subKey]->doStore($frozenObject); } $isDirty = false; return $frozenObject; } } return false; }
php
protected function doFetch($id, array &$objects = array()) { foreach ($this->storageChain as $key => $storage) { $frozenObject = $storage->doFetch($id, $objects); if ($frozenObject !== false) { $isDirty = &$frozenObject['objects'][$id]['isDirty']; $isDirty = true; for ($subKey = $key - 1; $subKey >= 0; $subKey--) { $this->storageChain[$subKey]->doStore($frozenObject); } $isDirty = false; return $frozenObject; } } return false; }
[ "protected", "function", "doFetch", "(", "$", "id", ",", "array", "&", "$", "objects", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "storageChain", "as", "$", "key", "=>", "$", "storage", ")", "{", "$", "frozenObject", "=", "$", "storage", "->", "doFetch", "(", "$", "id", ",", "$", "objects", ")", ";", "if", "(", "$", "frozenObject", "!==", "false", ")", "{", "$", "isDirty", "=", "&", "$", "frozenObject", "[", "'objects'", "]", "[", "$", "id", "]", "[", "'isDirty'", "]", ";", "$", "isDirty", "=", "true", ";", "for", "(", "$", "subKey", "=", "$", "key", "-", "1", ";", "$", "subKey", ">=", "0", ";", "$", "subKey", "--", ")", "{", "$", "this", "->", "storageChain", "[", "$", "subKey", "]", "->", "doStore", "(", "$", "frozenObject", ")", ";", "}", "$", "isDirty", "=", "false", ";", "return", "$", "frozenObject", ";", "}", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Storage/ChainStorage.php#L55-L74
yuncms/framework
src/models/Task.php
Task.crontabValidate
public function crontabValidate() { if (!CronParseHelper::check($this->crontab_str)) { $message = Yii::t('yuncms', 'Format verification failed.'); $this->addError('crontab_str', $message); } }
php
public function crontabValidate() { if (!CronParseHelper::check($this->crontab_str)) { $message = Yii::t('yuncms', 'Format verification failed.'); $this->addError('crontab_str', $message); } }
[ "public", "function", "crontabValidate", "(", ")", "{", "if", "(", "!", "CronParseHelper", "::", "check", "(", "$", "this", "->", "crontab_str", ")", ")", "{", "$", "message", "=", "Yii", "::", "t", "(", "'yuncms'", ",", "'Format verification failed.'", ")", ";", "$", "this", "->", "addError", "(", "'crontab_str'", ",", "$", "message", ")", ";", "}", "}" ]
Validate balance
[ "Validate", "balance" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/models/Task.php#L86-L92
teneleven/GeolocatorBundle
Extractor/AddressPropertyExtractor.php
AddressPropertyExtractor.extractAddress
public function extractAddress($object) { $accessor = $this->getPropertyAccessor(); $address = array(); try { foreach ($this->addressProperties as $property) { $address[] = trim($accessor->getValue($object, $property)); } } catch (\Exception $e) { throw new AddressExtractionFailedException(sprintf('Could not extract address (%s)', $e->getMessage())); } return implode(', ', $address); }
php
public function extractAddress($object) { $accessor = $this->getPropertyAccessor(); $address = array(); try { foreach ($this->addressProperties as $property) { $address[] = trim($accessor->getValue($object, $property)); } } catch (\Exception $e) { throw new AddressExtractionFailedException(sprintf('Could not extract address (%s)', $e->getMessage())); } return implode(', ', $address); }
[ "public", "function", "extractAddress", "(", "$", "object", ")", "{", "$", "accessor", "=", "$", "this", "->", "getPropertyAccessor", "(", ")", ";", "$", "address", "=", "array", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "addressProperties", "as", "$", "property", ")", "{", "$", "address", "[", "]", "=", "trim", "(", "$", "accessor", "->", "getValue", "(", "$", "object", ",", "$", "property", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "AddressExtractionFailedException", "(", "sprintf", "(", "'Could not extract address (%s)'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "return", "implode", "(", "', '", ",", "$", "address", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Extractor/AddressPropertyExtractor.php#L62-L76
fyuze/framework
src/Fyuze/Http/Response.php
Response.send
public function send() { foreach ($this->headers as $key => $value) { header("$key: " . implode(',', $value)); } if($this->hasHeader('Content-Type') === false) { header(vsprintf( 'Content-Type: %s', $this->hasHeader('Content-Type') ? $this->getHeader('Content-Type') : [$this->contentType] )); } http_response_code($this->getStatusCode()); if ($this->stream !== null) { if ($this->compression) { ob_start('ob_gzhandler'); } echo (string)$this->getBody(); } ob_end_flush(); }
php
public function send() { foreach ($this->headers as $key => $value) { header("$key: " . implode(',', $value)); } if($this->hasHeader('Content-Type') === false) { header(vsprintf( 'Content-Type: %s', $this->hasHeader('Content-Type') ? $this->getHeader('Content-Type') : [$this->contentType] )); } http_response_code($this->getStatusCode()); if ($this->stream !== null) { if ($this->compression) { ob_start('ob_gzhandler'); } echo (string)$this->getBody(); } ob_end_flush(); }
[ "public", "function", "send", "(", ")", "{", "foreach", "(", "$", "this", "->", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "header", "(", "\"$key: \"", ".", "implode", "(", "','", ",", "$", "value", ")", ")", ";", "}", "if", "(", "$", "this", "->", "hasHeader", "(", "'Content-Type'", ")", "===", "false", ")", "{", "header", "(", "vsprintf", "(", "'Content-Type: %s'", ",", "$", "this", "->", "hasHeader", "(", "'Content-Type'", ")", "?", "$", "this", "->", "getHeader", "(", "'Content-Type'", ")", ":", "[", "$", "this", "->", "contentType", "]", ")", ")", ";", "}", "http_response_code", "(", "$", "this", "->", "getStatusCode", "(", ")", ")", ";", "if", "(", "$", "this", "->", "stream", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "compression", ")", "{", "ob_start", "(", "'ob_gzhandler'", ")", ";", "}", "echo", "(", "string", ")", "$", "this", "->", "getBody", "(", ")", ";", "}", "ob_end_flush", "(", ")", ";", "}" ]
Sends the response
[ "Sends", "the", "response" ]
train
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Response.php#L73-L96
OwlyCode/StreamingBird
src/Location/Collection.php
Collection.getBoundingBox
public function getBoundingBox() { $box = []; foreach ($this->locations as $location) { $box = array_merge($box, $location->getBoundingBox()); } return $box; }
php
public function getBoundingBox() { $box = []; foreach ($this->locations as $location) { $box = array_merge($box, $location->getBoundingBox()); } return $box; }
[ "public", "function", "getBoundingBox", "(", ")", "{", "$", "box", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "locations", "as", "$", "location", ")", "{", "$", "box", "=", "array_merge", "(", "$", "box", ",", "$", "location", "->", "getBoundingBox", "(", ")", ")", ";", "}", "return", "$", "box", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/OwlyCode/StreamingBird/blob/177fc8a9dc8f911865a5abd9ac8d4ef85cef4003/src/Location/Collection.php#L23-L32
webforge-labs/psc-cms
lib/Psc/Net/HTTP/Header.php
Header.parseField
protected function parseField($name, $value) { switch ($name) { case 'Content-Disposition': $this->assertNotEmpty($value, $name); // @TODO das ist ganz schön stümperhaft aber geht erstmal if (Preg::match($value, '/^(.*?);\s+filename="(.*)"$/', $match)) { $value = (object) array('type'=>$match[1],'filename'=>$match[2]); } else { throw new HeaderFieldParsingException('Content-Disposition: "'.$value.'" kann nicht geparsed werden'); } break; case 'Cache-Control': case 'Pragma': $value = preg_split('/\s*,\s*/',$value); break; } return $value; }
php
protected function parseField($name, $value) { switch ($name) { case 'Content-Disposition': $this->assertNotEmpty($value, $name); // @TODO das ist ganz schön stümperhaft aber geht erstmal if (Preg::match($value, '/^(.*?);\s+filename="(.*)"$/', $match)) { $value = (object) array('type'=>$match[1],'filename'=>$match[2]); } else { throw new HeaderFieldParsingException('Content-Disposition: "'.$value.'" kann nicht geparsed werden'); } break; case 'Cache-Control': case 'Pragma': $value = preg_split('/\s*,\s*/',$value); break; } return $value; }
[ "protected", "function", "parseField", "(", "$", "name", ",", "$", "value", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'Content-Disposition'", ":", "$", "this", "->", "assertNotEmpty", "(", "$", "value", ",", "$", "name", ")", ";", "// @TODO das ist ganz schön stümperhaft aber geht erstmal", "if", "(", "Preg", "::", "match", "(", "$", "value", ",", "'/^(.*?);\\s+filename=\"(.*)\"$/'", ",", "$", "match", ")", ")", "{", "$", "value", "=", "(", "object", ")", "array", "(", "'type'", "=>", "$", "match", "[", "1", "]", ",", "'filename'", "=>", "$", "match", "[", "2", "]", ")", ";", "}", "else", "{", "throw", "new", "HeaderFieldParsingException", "(", "'Content-Disposition: \"'", ".", "$", "value", ".", "'\" kann nicht geparsed werden'", ")", ";", "}", "break", ";", "case", "'Cache-Control'", ":", "case", "'Pragma'", ":", "$", "value", "=", "preg_split", "(", "'/\\s*,\\s*/'", ",", "$", "value", ")", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
/* Parsing Funktionen um einen Header aus einem String zu erstellen
[ "/", "*", "Parsing", "Funktionen", "um", "einen", "Header", "aus", "einem", "String", "zu", "erstellen" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/Header.php#L125-L144
nexusnetsoftgmbh/nexuscli
src/Nexus/CustomCommand/Business/Model/Hydrator/CommandHydrator.php
CommandHydrator.hydrateCommands
public function hydrateCommands(array $commands): array { if ($this->commandFinder->isDir()) { $commands = array_merge($commands, $this->getCommandsFromFinder()); } return $commands; }
php
public function hydrateCommands(array $commands): array { if ($this->commandFinder->isDir()) { $commands = array_merge($commands, $this->getCommandsFromFinder()); } return $commands; }
[ "public", "function", "hydrateCommands", "(", "array", "$", "commands", ")", ":", "array", "{", "if", "(", "$", "this", "->", "commandFinder", "->", "isDir", "(", ")", ")", "{", "$", "commands", "=", "array_merge", "(", "$", "commands", ",", "$", "this", "->", "getCommandsFromFinder", "(", ")", ")", ";", "}", "return", "$", "commands", ";", "}" ]
@param array $commands @return array
[ "@param", "array", "$commands" ]
train
https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/CustomCommand/Business/Model/Hydrator/CommandHydrator.php#L31-L38
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.imgAreaSelect
public function imgAreaSelect() { $this->jquery(); $this->Html->script('libs/img-area-select.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_LIB ])); return $this; }
php
public function imgAreaSelect() { $this->jquery(); $this->Html->script('libs/img-area-select.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_LIB ])); return $this; }
[ "public", "function", "imgAreaSelect", "(", ")", "{", "$", "this", "->", "jquery", "(", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "'libs/img-area-select.min.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "__FUNCTION__", ",", "'weight'", "=>", "self", "::", "WEIGHT_LIB", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Include jQuery imgAreaSelect plugin. See https://github.com/odyniec/imgareaselect @return $this
[ "Include", "jQuery", "imgAreaSelect", "plugin", ".", "See", "https", ":", "//", "github", ".", "com", "/", "odyniec", "/", "imgareaselect" ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L136-L146
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.jquery
public function jquery() { $this->Html->script('libs/jquery.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_CORE ])); return $this; }
php
public function jquery() { $this->Html->script('libs/jquery.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_CORE ])); return $this; }
[ "public", "function", "jquery", "(", ")", "{", "$", "this", "->", "Html", "->", "script", "(", "'libs/jquery.min.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "__FUNCTION__", ",", "'weight'", "=>", "self", "::", "WEIGHT_CORE", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Include jquery lib. @return $this
[ "Include", "jquery", "lib", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L153-L161
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.jqueryFactory
public function jqueryFactory() { $this->jquery(); $this->Html->script('libs/utils.min.js', $this->_setOptions([ 'alias' => 'jquery-utils', 'weight' => self::WEIGHT_LIB ])); $this->Html->script('libs/jquery-factory.min.js', $this->_setOptions([ 'weight' => self::WEIGHT_LIB, 'alias' => 'jquery-factory' ])); return $this; }
php
public function jqueryFactory() { $this->jquery(); $this->Html->script('libs/utils.min.js', $this->_setOptions([ 'alias' => 'jquery-utils', 'weight' => self::WEIGHT_LIB ])); $this->Html->script('libs/jquery-factory.min.js', $this->_setOptions([ 'weight' => self::WEIGHT_LIB, 'alias' => 'jquery-factory' ])); return $this; }
[ "public", "function", "jqueryFactory", "(", ")", "{", "$", "this", "->", "jquery", "(", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "'libs/utils.min.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "'jquery-utils'", ",", "'weight'", "=>", "self", "::", "WEIGHT_LIB", "]", ")", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "'libs/jquery-factory.min.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'weight'", "=>", "self", "::", "WEIGHT_LIB", ",", "'alias'", "=>", "'jquery-factory'", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Include jquery factory. @return $this
[ "Include", "jquery", "factory", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L168-L183
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.loadPluginAssets
public function loadPluginAssets() { $plugin = (string) $this->request->getParam('plugin'); $prefix = ($this->request->getParam('prefix')) ? $this->request->getParam('prefix') . '/' : null; $action = (string) $this->request->getParam('action'); $controller = (string) $this->request->getParam('controller'); $widgetName = Str::slug($controller . '-' . $action) . '.js'; $cssOptions = ['block' => 'css_bottom', 'fullBase' => true, 'force' => Configure::read('debug')]; $this->Html->css($plugin . '.' . $prefix . 'styles.css', $cssOptions); $this->Html->less($plugin . '.' . $prefix . 'styles.less', $cssOptions); $this->Html->script([ $plugin . '.' . $prefix . 'widget/' . $widgetName, $plugin . '.' . $prefix . 'script.js' ], ['block' => 'script_bottom', 'fullBase' => true]); }
php
public function loadPluginAssets() { $plugin = (string) $this->request->getParam('plugin'); $prefix = ($this->request->getParam('prefix')) ? $this->request->getParam('prefix') . '/' : null; $action = (string) $this->request->getParam('action'); $controller = (string) $this->request->getParam('controller'); $widgetName = Str::slug($controller . '-' . $action) . '.js'; $cssOptions = ['block' => 'css_bottom', 'fullBase' => true, 'force' => Configure::read('debug')]; $this->Html->css($plugin . '.' . $prefix . 'styles.css', $cssOptions); $this->Html->less($plugin . '.' . $prefix . 'styles.less', $cssOptions); $this->Html->script([ $plugin . '.' . $prefix . 'widget/' . $widgetName, $plugin . '.' . $prefix . 'script.js' ], ['block' => 'script_bottom', 'fullBase' => true]); }
[ "public", "function", "loadPluginAssets", "(", ")", "{", "$", "plugin", "=", "(", "string", ")", "$", "this", "->", "request", "->", "getParam", "(", "'plugin'", ")", ";", "$", "prefix", "=", "(", "$", "this", "->", "request", "->", "getParam", "(", "'prefix'", ")", ")", "?", "$", "this", "->", "request", "->", "getParam", "(", "'prefix'", ")", ".", "'/'", ":", "null", ";", "$", "action", "=", "(", "string", ")", "$", "this", "->", "request", "->", "getParam", "(", "'action'", ")", ";", "$", "controller", "=", "(", "string", ")", "$", "this", "->", "request", "->", "getParam", "(", "'controller'", ")", ";", "$", "widgetName", "=", "Str", "::", "slug", "(", "$", "controller", ".", "'-'", ".", "$", "action", ")", ".", "'.js'", ";", "$", "cssOptions", "=", "[", "'block'", "=>", "'css_bottom'", ",", "'fullBase'", "=>", "true", ",", "'force'", "=>", "Configure", "::", "read", "(", "'debug'", ")", "]", ";", "$", "this", "->", "Html", "->", "css", "(", "$", "plugin", ".", "'.'", ".", "$", "prefix", ".", "'styles.css'", ",", "$", "cssOptions", ")", ";", "$", "this", "->", "Html", "->", "less", "(", "$", "plugin", ".", "'.'", ".", "$", "prefix", ".", "'styles.less'", ",", "$", "cssOptions", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "[", "$", "plugin", ".", "'.'", ".", "$", "prefix", ".", "'widget/'", ".", "$", "widgetName", ",", "$", "plugin", ".", "'.'", ".", "$", "prefix", ".", "'script.js'", "]", ",", "[", "'block'", "=>", "'script_bottom'", ",", "'fullBase'", "=>", "true", "]", ")", ";", "}" ]
Autoload plugin assets. @return void @throws \JBZoo\Less\Exception
[ "Autoload", "plugin", "assets", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L192-L208
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.materialize
public function materialize() { $this->jquery(); $this->Html->script('libs/materialize.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_LIB ])); $this->Html->css('libs/materialize.min.css', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_CORE ])); return $this; }
php
public function materialize() { $this->jquery(); $this->Html->script('libs/materialize.min.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_LIB ])); $this->Html->css('libs/materialize.min.css', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_CORE ])); return $this; }
[ "public", "function", "materialize", "(", ")", "{", "$", "this", "->", "jquery", "(", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "'libs/materialize.min.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "__FUNCTION__", ",", "'weight'", "=>", "self", "::", "WEIGHT_LIB", "]", ")", ")", ";", "$", "this", "->", "Html", "->", "css", "(", "'libs/materialize.min.css'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "__FUNCTION__", ",", "'weight'", "=>", "self", "::", "WEIGHT_CORE", "]", ")", ")", ";", "return", "$", "this", ";", "}" ]
Include materialize design. @return $this
[ "Include", "materialize", "design", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L215-L230
CakeCMS/Core
src/View/Helper/AssetsHelper.php
AssetsHelper.toggleField
public function toggleField($selector = '.jsToggleField', $widget = 'JBZoo.FieldToggle', array $options = []) { $this->jqueryFactory(); $this->Html->script('Core.admin/widget/field-toggle.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_WIDGET ])); $options = Hash::merge(['token' => $this->request->getCookie('csrfToken')], $options); $this->Js->widget($selector, $widget, $options); return $this; }
php
public function toggleField($selector = '.jsToggleField', $widget = 'JBZoo.FieldToggle', array $options = []) { $this->jqueryFactory(); $this->Html->script('Core.admin/widget/field-toggle.js', $this->_setOptions([ 'alias' => __FUNCTION__, 'weight' => self::WEIGHT_WIDGET ])); $options = Hash::merge(['token' => $this->request->getCookie('csrfToken')], $options); $this->Js->widget($selector, $widget, $options); return $this; }
[ "public", "function", "toggleField", "(", "$", "selector", "=", "'.jsToggleField'", ",", "$", "widget", "=", "'JBZoo.FieldToggle'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "jqueryFactory", "(", ")", ";", "$", "this", "->", "Html", "->", "script", "(", "'Core.admin/widget/field-toggle.js'", ",", "$", "this", "->", "_setOptions", "(", "[", "'alias'", "=>", "__FUNCTION__", ",", "'weight'", "=>", "self", "::", "WEIGHT_WIDGET", "]", ")", ")", ";", "$", "options", "=", "Hash", "::", "merge", "(", "[", "'token'", "=>", "$", "this", "->", "request", "->", "getCookie", "(", "'csrfToken'", ")", "]", ",", "$", "options", ")", ";", "$", "this", "->", "Js", "->", "widget", "(", "$", "selector", ",", "$", "widget", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Include toggle field js widget. @param string $selector @param string $widget @param array $options @return $this
[ "Include", "toggle", "field", "js", "widget", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/AssetsHelper.php#L296-L309
restruct/silverstripe-namedlinkfield
src/NamedLinkField.php
NamedLinkField.exists
public function exists() { return ($this->page_id > 0 || $this->file_id > 0 || $this->custom_url !== null || $this->shortcode !== null && $this->title !== null); }
php
public function exists() { return ($this->page_id > 0 || $this->file_id > 0 || $this->custom_url !== null || $this->shortcode !== null && $this->title !== null); }
[ "public", "function", "exists", "(", ")", "{", "return", "(", "$", "this", "->", "page_id", ">", "0", "||", "$", "this", "->", "file_id", ">", "0", "||", "$", "this", "->", "custom_url", "!==", "null", "||", "$", "this", "->", "shortcode", "!==", "null", "&&", "$", "this", "->", "title", "!==", "null", ")", ";", "}" ]
Determines if any of the properties in this field have a value, meaning at least one of them is not NULL. @return boolean
[ "Determines", "if", "any", "of", "the", "properties", "in", "this", "field", "have", "a", "value", "meaning", "at", "least", "one", "of", "them", "is", "not", "NULL", "." ]
train
https://github.com/restruct/silverstripe-namedlinkfield/blob/567c49fdc1b24c219dec2e989fc2013b1c7951af/src/NamedLinkField.php#L321-L325
restruct/silverstripe-namedlinkfield
src/NamedLinkField.php
NamedLinkField.Page
public function Page() { if ($this->getPageID() && $page = DataObject::get_by_id('Page', $this->getPageID())) { return $page; } return null; }
php
public function Page() { if ($this->getPageID() && $page = DataObject::get_by_id('Page', $this->getPageID())) { return $page; } return null; }
[ "public", "function", "Page", "(", ")", "{", "if", "(", "$", "this", "->", "getPageID", "(", ")", "&&", "$", "page", "=", "DataObject", "::", "get_by_id", "(", "'Page'", ",", "$", "this", "->", "getPageID", "(", ")", ")", ")", "{", "return", "$", "page", ";", "}", "return", "null", ";", "}" ]
}
[ "}" ]
train
https://github.com/restruct/silverstripe-namedlinkfield/blob/567c49fdc1b24c219dec2e989fc2013b1c7951af/src/NamedLinkField.php#L396-L402
webforge-labs/psc-cms
lib/Psc/JS/jQuery.php
jQuery.getIdSelector
public static function getIdSelector(\Psc\HTML\Tag $tag) { if ($tag->getAttribute('id') == NULL) $tag->generateId(); return "jQuery('#".$tag->getAttribute('id')."')"; }
php
public static function getIdSelector(\Psc\HTML\Tag $tag) { if ($tag->getAttribute('id') == NULL) $tag->generateId(); return "jQuery('#".$tag->getAttribute('id')."')"; }
[ "public", "static", "function", "getIdSelector", "(", "\\", "Psc", "\\", "HTML", "\\", "Tag", "$", "tag", ")", "{", "if", "(", "$", "tag", "->", "getAttribute", "(", "'id'", ")", "==", "NULL", ")", "$", "tag", "->", "generateId", "(", ")", ";", "return", "\"jQuery('#\"", ".", "$", "tag", "->", "getAttribute", "(", "'id'", ")", ".", "\"')\"", ";", "}" ]
/* Statische Funktionen (Helpers)
[ "/", "*", "Statische", "Funktionen", "(", "Helpers", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/jQuery.php#L23-L27
webforge-labs/psc-cms
lib/Psc/JS/jQuery.php
jQuery.chain
public static function chain(\Psc\HTML\Tag $tag, Expression $code) { if (isset($tag->templateContent->jQueryChain)) { // append to previous created chain $tag->templateContent->jQueryChain .= sprintf("\n .%s", $code->JS()); } else { /* * make something like: * * require([...], function () { * require([...], function (jQuery) { * jQuery('selector for element')%jQueryChain% * }); * }); */ $tag->templateAppend( "\n".Helper::embedWithJQuery( new jsCode( ' '.self::getClassSelector($tag).'%jQueryChain%' // this is of course not valid js code, but it will be replaced to one ) ) ); $tag->templateContent->jQueryChain = sprintf("\n .%s", $code->JS()); } return $tag; }
php
public static function chain(\Psc\HTML\Tag $tag, Expression $code) { if (isset($tag->templateContent->jQueryChain)) { // append to previous created chain $tag->templateContent->jQueryChain .= sprintf("\n .%s", $code->JS()); } else { /* * make something like: * * require([...], function () { * require([...], function (jQuery) { * jQuery('selector for element')%jQueryChain% * }); * }); */ $tag->templateAppend( "\n".Helper::embedWithJQuery( new jsCode( ' '.self::getClassSelector($tag).'%jQueryChain%' // this is of course not valid js code, but it will be replaced to one ) ) ); $tag->templateContent->jQueryChain = sprintf("\n .%s", $code->JS()); } return $tag; }
[ "public", "static", "function", "chain", "(", "\\", "Psc", "\\", "HTML", "\\", "Tag", "$", "tag", ",", "Expression", "$", "code", ")", "{", "if", "(", "isset", "(", "$", "tag", "->", "templateContent", "->", "jQueryChain", ")", ")", "{", "// append to previous created chain", "$", "tag", "->", "templateContent", "->", "jQueryChain", ".=", "sprintf", "(", "\"\\n .%s\"", ",", "$", "code", "->", "JS", "(", ")", ")", ";", "}", "else", "{", "/*\n * make something like:\n *\n * require([...], function () {\n * require([...], function (jQuery) {\n * jQuery('selector for element')%jQueryChain%\n * });\n * });\n */", "$", "tag", "->", "templateAppend", "(", "\"\\n\"", ".", "Helper", "::", "embedWithJQuery", "(", "new", "jsCode", "(", "' '", ".", "self", "::", "getClassSelector", "(", "$", "tag", ")", ".", "'%jQueryChain%'", "// this is of course not valid js code, but it will be replaced to one", ")", ")", ")", ";", "$", "tag", "->", "templateContent", "->", "jQueryChain", "=", "sprintf", "(", "\"\\n .%s\"", ",", "$", "code", "->", "JS", "(", ")", ")", ";", "}", "return", "$", "tag", ";", "}" ]
Fügt dem JavaScript des Tags eine weitere Funktion hinzu z. B. so: <span id="element"></span> <script type="text/javascript">$('#element').click({..})</script> @param Expression $code wird mit einem . an das Javascript des Selectors angehängt $code darf also am Anfang keinen . haben
[ "Fügt", "dem", "JavaScript", "des", "Tags", "eine", "weitere", "Funktion", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/jQuery.php#L51-L81
zircote/AMQP
library/AMQP/Wire/BufferedInput.php
BufferedInput.read
public function read($n) { if ($this->offset >= strlen($this->buffer)) { if (!($rv = $this->populateBuffer())) { return $rv; } } return $this->readBuffer($n); }
php
public function read($n) { if ($this->offset >= strlen($this->buffer)) { if (!($rv = $this->populateBuffer())) { return $rv; } } return $this->readBuffer($n); }
[ "public", "function", "read", "(", "$", "n", ")", "{", "if", "(", "$", "this", "->", "offset", ">=", "strlen", "(", "$", "this", "->", "buffer", ")", ")", "{", "if", "(", "!", "(", "$", "rv", "=", "$", "this", "->", "populateBuffer", "(", ")", ")", ")", "{", "return", "$", "rv", ";", "}", "}", "return", "$", "this", "->", "readBuffer", "(", "$", "n", ")", ";", "}" ]
@param $n @return bool|string
[ "@param", "$n" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/BufferedInput.php#L54-L62
zircote/AMQP
library/AMQP/Wire/BufferedInput.php
BufferedInput.readBuffer
protected function readBuffer($n) { $n = min($n, strlen($this->buffer) - $this->offset); if ($n === 0) { // substr('', 0, 0) => false, which screws up read loops that are // expecting non-blocking reads to return ''. This avoids that edge // case when the buffer is empty/used up. return ''; } $block = substr($this->buffer, $this->offset, $n); $this->offset += $n; return $block; }
php
protected function readBuffer($n) { $n = min($n, strlen($this->buffer) - $this->offset); if ($n === 0) { // substr('', 0, 0) => false, which screws up read loops that are // expecting non-blocking reads to return ''. This avoids that edge // case when the buffer is empty/used up. return ''; } $block = substr($this->buffer, $this->offset, $n); $this->offset += $n; return $block; }
[ "protected", "function", "readBuffer", "(", "$", "n", ")", "{", "$", "n", "=", "min", "(", "$", "n", ",", "strlen", "(", "$", "this", "->", "buffer", ")", "-", "$", "this", "->", "offset", ")", ";", "if", "(", "$", "n", "===", "0", ")", "{", "// substr('', 0, 0) => false, which screws up read loops that are", "// expecting non-blocking reads to return ''. This avoids that edge", "// case when the buffer is empty/used up.", "return", "''", ";", "}", "$", "block", "=", "substr", "(", "$", "this", "->", "buffer", ",", "$", "this", "->", "offset", ",", "$", "n", ")", ";", "$", "this", "->", "offset", "+=", "$", "n", ";", "return", "$", "block", ";", "}" ]
@param $n @return string
[ "@param", "$n" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/BufferedInput.php#L78-L90
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.syntaxError
public function syntaxError($expected = '', $token = null) { if ($token === null) { $token = $this->lexer->lookahead; } $tokenPos = (isset($token['position'])) ? $token['position'] : '-1'; $message = "line 0, col {$tokenPos}: Error: "; $message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected '; $message .= ($this->lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'"; throw ExpressionException::syntaxError($message, ExpressionException::expressionError($this->expression)); }
php
public function syntaxError($expected = '', $token = null) { if ($token === null) { $token = $this->lexer->lookahead; } $tokenPos = (isset($token['position'])) ? $token['position'] : '-1'; $message = "line 0, col {$tokenPos}: Error: "; $message .= ($expected !== '') ? "Expected {$expected}, got " : 'Unexpected '; $message .= ($this->lexer->lookahead === null) ? 'end of string.' : "'{$token['value']}'"; throw ExpressionException::syntaxError($message, ExpressionException::expressionError($this->expression)); }
[ "public", "function", "syntaxError", "(", "$", "expected", "=", "''", ",", "$", "token", "=", "null", ")", "{", "if", "(", "$", "token", "===", "null", ")", "{", "$", "token", "=", "$", "this", "->", "lexer", "->", "lookahead", ";", "}", "$", "tokenPos", "=", "(", "isset", "(", "$", "token", "[", "'position'", "]", ")", ")", "?", "$", "token", "[", "'position'", "]", ":", "'-1'", ";", "$", "message", "=", "\"line 0, col {$tokenPos}: Error: \"", ";", "$", "message", ".=", "(", "$", "expected", "!==", "''", ")", "?", "\"Expected {$expected}, got \"", ":", "'Unexpected '", ";", "$", "message", ".=", "(", "$", "this", "->", "lexer", "->", "lookahead", "===", "null", ")", "?", "'end of string.'", ":", "\"'{$token['value']}'\"", ";", "throw", "ExpressionException", "::", "syntaxError", "(", "$", "message", ",", "ExpressionException", "::", "expressionError", "(", "$", "this", "->", "expression", ")", ")", ";", "}" ]
Generates a new syntax error. @param string $expected Expected string. @param array|null $token Got token. @return void @throws ExpressionException
[ "Generates", "a", "new", "syntax", "error", "." ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L112-L125
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.semanticalError
public function semanticalError($message = '', $token = null) { if ($token === null) { $token = $this->lexer->lookahead; } // Minimum exposed chars ahead of token $distance = 12; // Find a position of a final word to display in error string $expression = $this->expression; $length = strlen($expression); $pos = $token['position'] + $distance; $pos = strpos($expression, ' ', ($length > $pos) ? $pos : $length); $length = ($pos !== false) ? $pos - $token['position'] : $distance; $tokenPos = (isset($token['position']) && $token['position'] > 0) ? $token['position'] : '-1'; $tokenStr = substr($expression, $token['position'], $length); // Building informative message $message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message; throw ExpressionException::semanticalError($message, ExpressionException::expressionError($this->expression)); }
php
public function semanticalError($message = '', $token = null) { if ($token === null) { $token = $this->lexer->lookahead; } // Minimum exposed chars ahead of token $distance = 12; // Find a position of a final word to display in error string $expression = $this->expression; $length = strlen($expression); $pos = $token['position'] + $distance; $pos = strpos($expression, ' ', ($length > $pos) ? $pos : $length); $length = ($pos !== false) ? $pos - $token['position'] : $distance; $tokenPos = (isset($token['position']) && $token['position'] > 0) ? $token['position'] : '-1'; $tokenStr = substr($expression, $token['position'], $length); // Building informative message $message = 'line 0, col ' . $tokenPos . " near '" . $tokenStr . "': Error: " . $message; throw ExpressionException::semanticalError($message, ExpressionException::expressionError($this->expression)); }
[ "public", "function", "semanticalError", "(", "$", "message", "=", "''", ",", "$", "token", "=", "null", ")", "{", "if", "(", "$", "token", "===", "null", ")", "{", "$", "token", "=", "$", "this", "->", "lexer", "->", "lookahead", ";", "}", "// Minimum exposed chars ahead of token", "$", "distance", "=", "12", ";", "// Find a position of a final word to display in error string", "$", "expression", "=", "$", "this", "->", "expression", ";", "$", "length", "=", "strlen", "(", "$", "expression", ")", ";", "$", "pos", "=", "$", "token", "[", "'position'", "]", "+", "$", "distance", ";", "$", "pos", "=", "strpos", "(", "$", "expression", ",", "' '", ",", "(", "$", "length", ">", "$", "pos", ")", "?", "$", "pos", ":", "$", "length", ")", ";", "$", "length", "=", "(", "$", "pos", "!==", "false", ")", "?", "$", "pos", "-", "$", "token", "[", "'position'", "]", ":", "$", "distance", ";", "$", "tokenPos", "=", "(", "isset", "(", "$", "token", "[", "'position'", "]", ")", "&&", "$", "token", "[", "'position'", "]", ">", "0", ")", "?", "$", "token", "[", "'position'", "]", ":", "'-1'", ";", "$", "tokenStr", "=", "substr", "(", "$", "expression", ",", "$", "token", "[", "'position'", "]", ",", "$", "length", ")", ";", "// Building informative message", "$", "message", "=", "'line 0, col '", ".", "$", "tokenPos", ".", "\" near '\"", ".", "$", "tokenStr", ".", "\"': Error: \"", ".", "$", "message", ";", "throw", "ExpressionException", "::", "semanticalError", "(", "$", "message", ",", "ExpressionException", "::", "expressionError", "(", "$", "this", "->", "expression", ")", ")", ";", "}" ]
Generates a new semantical error. @param string $message Optional message. @param array|null $token Optional token. @return void @throws ExpressionException
[ "Generates", "a", "new", "semantical", "error", "." ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L137-L160
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.filterLanguage
public function filterLanguage() { $this->lexer->moveNext(); $node = $this->filterNode(); // Check for end of string if ($this->lexer->lookahead !== null) { $this->syntaxError('end of string'); } return $node; }
php
public function filterLanguage() { $this->lexer->moveNext(); $node = $this->filterNode(); // Check for end of string if ($this->lexer->lookahead !== null) { $this->syntaxError('end of string'); } return $node; }
[ "public", "function", "filterLanguage", "(", ")", "{", "$", "this", "->", "lexer", "->", "moveNext", "(", ")", ";", "$", "node", "=", "$", "this", "->", "filterNode", "(", ")", ";", "// Check for end of string", "if", "(", "$", "this", "->", "lexer", "->", "lookahead", "!==", "null", ")", "{", "$", "this", "->", "syntaxError", "(", "'end of string'", ")", ";", "}", "return", "$", "node", ";", "}" ]
filterLanguage ::= filterNode @return FilterNode
[ "filterLanguage", "::", "=", "filterNode" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L203-L215
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.conditionalExpression
public function conditionalExpression() { $conditionalTerms = array(); $conditionalTerms[] = $this->conditionalTerm(); while ($this->lexer->isNextToken(Lexer::T_OR)) { $this->match(Lexer::T_OR); $conditionalTerms[] = $this->conditionalTerm(); } // Phase 1 AST optimization: Prevent AST\ConditionalExpression // if only one AST\ConditionalTerm is defined if (count($conditionalTerms) == 1) { return $conditionalTerms[0]; } return new ConditionalExpressionNode($conditionalTerms); }
php
public function conditionalExpression() { $conditionalTerms = array(); $conditionalTerms[] = $this->conditionalTerm(); while ($this->lexer->isNextToken(Lexer::T_OR)) { $this->match(Lexer::T_OR); $conditionalTerms[] = $this->conditionalTerm(); } // Phase 1 AST optimization: Prevent AST\ConditionalExpression // if only one AST\ConditionalTerm is defined if (count($conditionalTerms) == 1) { return $conditionalTerms[0]; } return new ConditionalExpressionNode($conditionalTerms); }
[ "public", "function", "conditionalExpression", "(", ")", "{", "$", "conditionalTerms", "=", "array", "(", ")", ";", "$", "conditionalTerms", "[", "]", "=", "$", "this", "->", "conditionalTerm", "(", ")", ";", "while", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_OR", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_OR", ")", ";", "$", "conditionalTerms", "[", "]", "=", "$", "this", "->", "conditionalTerm", "(", ")", ";", "}", "// Phase 1 AST optimization: Prevent AST\\ConditionalExpression", "// if only one AST\\ConditionalTerm is defined", "if", "(", "count", "(", "$", "conditionalTerms", ")", "==", "1", ")", "{", "return", "$", "conditionalTerms", "[", "0", "]", ";", "}", "return", "new", "ConditionalExpressionNode", "(", "$", "conditionalTerms", ")", ";", "}" ]
conditionalExpression ::= conditionalTerm {"OR" conditionalTerm}* @return ConditionalExpressionNode
[ "conditionalExpression", "::", "=", "conditionalTerm", "{", "OR", "conditionalTerm", "}", "*" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L234-L252
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.conditionalTerm
public function conditionalTerm() { $conditionalFactors = array(); $conditionalFactors[] = $this->conditionalFactor(); while ($this->lexer->isNextToken(Lexer::T_AND)) { $this->match(Lexer::T_AND); $conditionalFactors[] = $this->conditionalFactor(); } // Phase 1 AST optimization: Prevent AST\ConditionalTerm // if only one AST\ConditionalFactor is defined if (count($conditionalFactors) == 1) { return $conditionalFactors[0]; } return new ConditionalTermNode($conditionalFactors); }
php
public function conditionalTerm() { $conditionalFactors = array(); $conditionalFactors[] = $this->conditionalFactor(); while ($this->lexer->isNextToken(Lexer::T_AND)) { $this->match(Lexer::T_AND); $conditionalFactors[] = $this->conditionalFactor(); } // Phase 1 AST optimization: Prevent AST\ConditionalTerm // if only one AST\ConditionalFactor is defined if (count($conditionalFactors) == 1) { return $conditionalFactors[0]; } return new ConditionalTermNode($conditionalFactors); }
[ "public", "function", "conditionalTerm", "(", ")", "{", "$", "conditionalFactors", "=", "array", "(", ")", ";", "$", "conditionalFactors", "[", "]", "=", "$", "this", "->", "conditionalFactor", "(", ")", ";", "while", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_AND", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_AND", ")", ";", "$", "conditionalFactors", "[", "]", "=", "$", "this", "->", "conditionalFactor", "(", ")", ";", "}", "// Phase 1 AST optimization: Prevent AST\\ConditionalTerm", "// if only one AST\\ConditionalFactor is defined", "if", "(", "count", "(", "$", "conditionalFactors", ")", "==", "1", ")", "{", "return", "$", "conditionalFactors", "[", "0", "]", ";", "}", "return", "new", "ConditionalTermNode", "(", "$", "conditionalFactors", ")", ";", "}" ]
conditionalTerm ::= conditionalFactor {"AND" conditionalFactor}* @return ConditionalTermNode
[ "conditionalTerm", "::", "=", "conditionalFactor", "{", "AND", "conditionalFactor", "}", "*" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L259-L277
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.conditionalFactor
public function conditionalFactor() { $not = false; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $conditionalPrimary = $this->conditionalPrimary(); // Phase 1 AST optimization: Prevent AST\ConditionalFactor // if only one AST\ConditionalPrimary is defined if ( ! $not) { return $conditionalPrimary; } $conditionalFactor = new ConditionalFactorNode($conditionalPrimary); $conditionalFactor->setNot($not); return $conditionalFactor; }
php
public function conditionalFactor() { $not = false; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $conditionalPrimary = $this->conditionalPrimary(); // Phase 1 AST optimization: Prevent AST\ConditionalFactor // if only one AST\ConditionalPrimary is defined if ( ! $not) { return $conditionalPrimary; } $conditionalFactor = new ConditionalFactorNode($conditionalPrimary); $conditionalFactor->setNot($not); return $conditionalFactor; }
[ "public", "function", "conditionalFactor", "(", ")", "{", "$", "not", "=", "false", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_NOT", ")", ";", "$", "not", "=", "true", ";", "}", "$", "conditionalPrimary", "=", "$", "this", "->", "conditionalPrimary", "(", ")", ";", "// Phase 1 AST optimization: Prevent AST\\ConditionalFactor", "// if only one AST\\ConditionalPrimary is defined", "if", "(", "!", "$", "not", ")", "{", "return", "$", "conditionalPrimary", ";", "}", "$", "conditionalFactor", "=", "new", "ConditionalFactorNode", "(", "$", "conditionalPrimary", ")", ";", "$", "conditionalFactor", "->", "setNot", "(", "$", "not", ")", ";", "return", "$", "conditionalFactor", ";", "}" ]
conditionalFactor ::= ["NOT"] conditionalPrimary @return ConditionalFactorNode
[ "conditionalFactor", "::", "=", "[", "NOT", "]", "conditionalPrimary" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L284-L306
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.conditionalPrimary
public function conditionalPrimary() { $condPrimary = new ConditionalPrimaryNode(); if ( ! $this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $condPrimary->setSimpleConditionalExpression($this->simpleConditionalExpression()); return $condPrimary; } // Peek beyond the matching closing parenthesis ')' $peek = $this->peekBeyondClosingParenthesis(); if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) || in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS))) { $condPrimary->setSimpleConditionalExpression($this->simpleConditionalExpression()); return $condPrimary; } $this->match(Lexer::T_OPEN_PARENTHESIS); $condPrimary->setConditionalExpression($this->conditionalExpression()); $this->match(Lexer::T_CLOSE_PARENTHESIS); return $condPrimary; }
php
public function conditionalPrimary() { $condPrimary = new ConditionalPrimaryNode(); if ( ! $this->lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $condPrimary->setSimpleConditionalExpression($this->simpleConditionalExpression()); return $condPrimary; } // Peek beyond the matching closing parenthesis ')' $peek = $this->peekBeyondClosingParenthesis(); if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) || in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS))) { $condPrimary->setSimpleConditionalExpression($this->simpleConditionalExpression()); return $condPrimary; } $this->match(Lexer::T_OPEN_PARENTHESIS); $condPrimary->setConditionalExpression($this->conditionalExpression()); $this->match(Lexer::T_CLOSE_PARENTHESIS); return $condPrimary; }
[ "public", "function", "conditionalPrimary", "(", ")", "{", "$", "condPrimary", "=", "new", "ConditionalPrimaryNode", "(", ")", ";", "if", "(", "!", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_OPEN_PARENTHESIS", ")", ")", "{", "$", "condPrimary", "->", "setSimpleConditionalExpression", "(", "$", "this", "->", "simpleConditionalExpression", "(", ")", ")", ";", "return", "$", "condPrimary", ";", "}", "// Peek beyond the matching closing parenthesis ')'", "$", "peek", "=", "$", "this", "->", "peekBeyondClosingParenthesis", "(", ")", ";", "if", "(", "in_array", "(", "$", "peek", "[", "'value'", "]", ",", "array", "(", "\"=\"", ",", "\"<\"", ",", "\"<=\"", ",", "\"<>\"", ",", "\">\"", ",", "\">=\"", ",", "\"!=\"", ")", ")", "||", "in_array", "(", "$", "peek", "[", "'type'", "]", ",", "array", "(", "Lexer", "::", "T_NOT", ",", "Lexer", "::", "T_BETWEEN", ",", "Lexer", "::", "T_LIKE", ",", "Lexer", "::", "T_IN", ",", "Lexer", "::", "T_IS", ")", ")", ")", "{", "$", "condPrimary", "->", "setSimpleConditionalExpression", "(", "$", "this", "->", "simpleConditionalExpression", "(", ")", ")", ";", "return", "$", "condPrimary", ";", "}", "$", "this", "->", "match", "(", "Lexer", "::", "T_OPEN_PARENTHESIS", ")", ";", "$", "condPrimary", "->", "setConditionalExpression", "(", "$", "this", "->", "conditionalExpression", "(", ")", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_CLOSE_PARENTHESIS", ")", ";", "return", "$", "condPrimary", ";", "}" ]
conditionalPrimary ::= simpleConditionalExpression | "(" conditionalExpression ")" @return ConditionalPrimaryNode
[ "conditionalPrimary", "::", "=", "simpleConditionalExpression", "|", "(", "conditionalExpression", ")" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L313-L338
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.simpleConditionalExpression
public function simpleConditionalExpression() { $token = $this->lexer->lookahead; $lookahead = $token; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $token = $this->lexer->glimpse(); } if ($token['type'] === Lexer::T_IDENTIFIER) { // Peek beyond the matching closing parenthesis. $beyond = $this->lexer->peek(); // Peek beyond the PathExpression or InputParameter. $token = $beyond; while ($token['value'] === '.') { $this->lexer->peek(); $token = $this->lexer->peek(); } // Also peek beyond a NOT if there is one. if ($token['type'] === Lexer::T_NOT) { $token = $this->lexer->peek(); } // We need to go even further in case of IS (differentiate between NULL and EMPTY) $lookahead = $this->lexer->peek(); // Also peek beyond a NOT if there is one. if ($lookahead['type'] === Lexer::T_NOT) { $lookahead = $this->lexer->peek(); } $this->lexer->resetPeek(); } if ($token['type'] === Lexer::T_BETWEEN) { return $this->betweenExpression(); } if ($token['type'] === Lexer::T_LIKE) { return $this->likeExpression(); } if ($token['type'] === Lexer::T_IN) { return $this->inExpression(); } if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_NULL) { return $this->nullComparisonExpression(); } return $this->comparisonExpression(); }
php
public function simpleConditionalExpression() { $token = $this->lexer->lookahead; $lookahead = $token; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $token = $this->lexer->glimpse(); } if ($token['type'] === Lexer::T_IDENTIFIER) { // Peek beyond the matching closing parenthesis. $beyond = $this->lexer->peek(); // Peek beyond the PathExpression or InputParameter. $token = $beyond; while ($token['value'] === '.') { $this->lexer->peek(); $token = $this->lexer->peek(); } // Also peek beyond a NOT if there is one. if ($token['type'] === Lexer::T_NOT) { $token = $this->lexer->peek(); } // We need to go even further in case of IS (differentiate between NULL and EMPTY) $lookahead = $this->lexer->peek(); // Also peek beyond a NOT if there is one. if ($lookahead['type'] === Lexer::T_NOT) { $lookahead = $this->lexer->peek(); } $this->lexer->resetPeek(); } if ($token['type'] === Lexer::T_BETWEEN) { return $this->betweenExpression(); } if ($token['type'] === Lexer::T_LIKE) { return $this->likeExpression(); } if ($token['type'] === Lexer::T_IN) { return $this->inExpression(); } if ($token['type'] === Lexer::T_IS && $lookahead['type'] === Lexer::T_NULL) { return $this->nullComparisonExpression(); } return $this->comparisonExpression(); }
[ "public", "function", "simpleConditionalExpression", "(", ")", "{", "$", "token", "=", "$", "this", "->", "lexer", "->", "lookahead", ";", "$", "lookahead", "=", "$", "token", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "token", "=", "$", "this", "->", "lexer", "->", "glimpse", "(", ")", ";", "}", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_IDENTIFIER", ")", "{", "// Peek beyond the matching closing parenthesis.", "$", "beyond", "=", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "// Peek beyond the PathExpression or InputParameter.", "$", "token", "=", "$", "beyond", ";", "while", "(", "$", "token", "[", "'value'", "]", "===", "'.'", ")", "{", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "$", "token", "=", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "}", "// Also peek beyond a NOT if there is one.", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_NOT", ")", "{", "$", "token", "=", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "}", "// We need to go even further in case of IS (differentiate between NULL and EMPTY)", "$", "lookahead", "=", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "// Also peek beyond a NOT if there is one.", "if", "(", "$", "lookahead", "[", "'type'", "]", "===", "Lexer", "::", "T_NOT", ")", "{", "$", "lookahead", "=", "$", "this", "->", "lexer", "->", "peek", "(", ")", ";", "}", "$", "this", "->", "lexer", "->", "resetPeek", "(", ")", ";", "}", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_BETWEEN", ")", "{", "return", "$", "this", "->", "betweenExpression", "(", ")", ";", "}", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_LIKE", ")", "{", "return", "$", "this", "->", "likeExpression", "(", ")", ";", "}", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_IN", ")", "{", "return", "$", "this", "->", "inExpression", "(", ")", ";", "}", "if", "(", "$", "token", "[", "'type'", "]", "===", "Lexer", "::", "T_IS", "&&", "$", "lookahead", "[", "'type'", "]", "===", "Lexer", "::", "T_NULL", ")", "{", "return", "$", "this", "->", "nullComparisonExpression", "(", ")", ";", "}", "return", "$", "this", "->", "comparisonExpression", "(", ")", ";", "}" ]
simpleConditionalExpression ::= comparisonExpression | betweenExpression | likeExpression | inExpression | nullComparisonExpression @return BetweenExpressionNode|LikeExpressionNode|InExpressionNode|NullComparisonExpressionNode|ComparisonExpressionNode|Node
[ "simpleConditionalExpression", "::", "=", "comparisonExpression", "|", "betweenExpression", "|", "likeExpression", "|", "inExpression", "|", "nullComparisonExpression" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L347-L402
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.betweenExpression
public function betweenExpression() { $not = false; $arithExpr1 = $this->identificationVariable(); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $this->match(Lexer::T_BETWEEN); $arithExpr2 = $this->arithmeticPrimary(); $this->match(Lexer::T_AND); $arithExpr3 = $this->arithmeticPrimary(); $betweenExpr = new BetweenExpressionNode($arithExpr1, $arithExpr2, $arithExpr3); $betweenExpr->setNot($not); return $betweenExpr; }
php
public function betweenExpression() { $not = false; $arithExpr1 = $this->identificationVariable(); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $this->match(Lexer::T_BETWEEN); $arithExpr2 = $this->arithmeticPrimary(); $this->match(Lexer::T_AND); $arithExpr3 = $this->arithmeticPrimary(); $betweenExpr = new BetweenExpressionNode($arithExpr1, $arithExpr2, $arithExpr3); $betweenExpr->setNot($not); return $betweenExpr; }
[ "public", "function", "betweenExpression", "(", ")", "{", "$", "not", "=", "false", ";", "$", "arithExpr1", "=", "$", "this", "->", "identificationVariable", "(", ")", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_NOT", ")", ";", "$", "not", "=", "true", ";", "}", "$", "this", "->", "match", "(", "Lexer", "::", "T_BETWEEN", ")", ";", "$", "arithExpr2", "=", "$", "this", "->", "arithmeticPrimary", "(", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_AND", ")", ";", "$", "arithExpr3", "=", "$", "this", "->", "arithmeticPrimary", "(", ")", ";", "$", "betweenExpr", "=", "new", "BetweenExpressionNode", "(", "$", "arithExpr1", ",", "$", "arithExpr2", ",", "$", "arithExpr3", ")", ";", "$", "betweenExpr", "->", "setNot", "(", "$", "not", ")", ";", "return", "$", "betweenExpr", ";", "}" ]
betweenExpression ::= identificationVariable ["NOT"] "BETWEEN" arithmeticPrimary "AND" arithmeticPrimary @return BetweenExpressionNode
[ "betweenExpression", "::", "=", "identificationVariable", "[", "NOT", "]", "BETWEEN", "arithmeticPrimary", "AND", "arithmeticPrimary" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L409-L428
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.comparisonExpression
public function comparisonExpression() { $this->lexer->glimpse(); $leftExpr = $this->arithmeticPrimary(); $operator = $this->comparisonOperator(); $rightExpr = $this->arithmeticPrimary(); return new ComparisonExpressionNode($leftExpr, $operator, $rightExpr); }
php
public function comparisonExpression() { $this->lexer->glimpse(); $leftExpr = $this->arithmeticPrimary(); $operator = $this->comparisonOperator(); $rightExpr = $this->arithmeticPrimary(); return new ComparisonExpressionNode($leftExpr, $operator, $rightExpr); }
[ "public", "function", "comparisonExpression", "(", ")", "{", "$", "this", "->", "lexer", "->", "glimpse", "(", ")", ";", "$", "leftExpr", "=", "$", "this", "->", "arithmeticPrimary", "(", ")", ";", "$", "operator", "=", "$", "this", "->", "comparisonOperator", "(", ")", ";", "$", "rightExpr", "=", "$", "this", "->", "arithmeticPrimary", "(", ")", ";", "return", "new", "ComparisonExpressionNode", "(", "$", "leftExpr", ",", "$", "operator", ",", "$", "rightExpr", ")", ";", "}" ]
comparisonExpression ::= arithmeticPrimary comparisonOperator arithmeticPrimary @return ComparisonExpressionNode
[ "comparisonExpression", "::", "=", "arithmeticPrimary", "comparisonOperator", "arithmeticPrimary" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L435-L444
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.inExpression
public function inExpression() { $inExpression = new InExpressionNode($this->identificationVariable()); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $inExpression->setNot(true); } $this->match(Lexer::T_IN); $this->match(Lexer::T_OPEN_PARENTHESIS); $literals = array(); $literals[] = $this->inParameter(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $literals[] = $this->inParameter(); } $inExpression->setLiterals($literals); $this->match(Lexer::T_CLOSE_PARENTHESIS); return $inExpression; }
php
public function inExpression() { $inExpression = new InExpressionNode($this->identificationVariable()); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $inExpression->setNot(true); } $this->match(Lexer::T_IN); $this->match(Lexer::T_OPEN_PARENTHESIS); $literals = array(); $literals[] = $this->inParameter(); while ($this->lexer->isNextToken(Lexer::T_COMMA)) { $this->match(Lexer::T_COMMA); $literals[] = $this->inParameter(); } $inExpression->setLiterals($literals); $this->match(Lexer::T_CLOSE_PARENTHESIS); return $inExpression; }
[ "public", "function", "inExpression", "(", ")", "{", "$", "inExpression", "=", "new", "InExpressionNode", "(", "$", "this", "->", "identificationVariable", "(", ")", ")", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_NOT", ")", ";", "$", "inExpression", "->", "setNot", "(", "true", ")", ";", "}", "$", "this", "->", "match", "(", "Lexer", "::", "T_IN", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_OPEN_PARENTHESIS", ")", ";", "$", "literals", "=", "array", "(", ")", ";", "$", "literals", "[", "]", "=", "$", "this", "->", "inParameter", "(", ")", ";", "while", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_COMMA", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_COMMA", ")", ";", "$", "literals", "[", "]", "=", "$", "this", "->", "inParameter", "(", ")", ";", "}", "$", "inExpression", "->", "setLiterals", "(", "$", "literals", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_CLOSE_PARENTHESIS", ")", ";", "return", "$", "inExpression", ";", "}" ]
inExpression ::= identificationVariable ["NOT"] "IN" "(" inParameter {"," inParameter}* ")" @return InExpressionNode
[ "inExpression", "::", "=", "identificationVariable", "[", "NOT", "]", "IN", "(", "inParameter", "{", "inParameter", "}", "*", ")" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L451-L476
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.likeExpression
public function likeExpression() { $stringExpr = $this->identificationVariable(); $not = false; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $this->match(Lexer::T_LIKE); $stringPattern = $this->stringExpression(); $likeExpr = new LikeExpressionNode($stringExpr, $stringPattern); $likeExpr->setNot($not); return $likeExpr; }
php
public function likeExpression() { $stringExpr = $this->identificationVariable(); $not = false; if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $not = true; } $this->match(Lexer::T_LIKE); $stringPattern = $this->stringExpression(); $likeExpr = new LikeExpressionNode($stringExpr, $stringPattern); $likeExpr->setNot($not); return $likeExpr; }
[ "public", "function", "likeExpression", "(", ")", "{", "$", "stringExpr", "=", "$", "this", "->", "identificationVariable", "(", ")", ";", "$", "not", "=", "false", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_NOT", ")", ";", "$", "not", "=", "true", ";", "}", "$", "this", "->", "match", "(", "Lexer", "::", "T_LIKE", ")", ";", "$", "stringPattern", "=", "$", "this", "->", "stringExpression", "(", ")", ";", "$", "likeExpr", "=", "new", "LikeExpressionNode", "(", "$", "stringExpr", ",", "$", "stringPattern", ")", ";", "$", "likeExpr", "->", "setNot", "(", "$", "not", ")", ";", "return", "$", "likeExpr", ";", "}" ]
likeExpression ::= identificationVariable ["NOT"] "LIKE" stringExpression @return LikeExpressionNode
[ "likeExpression", "::", "=", "identificationVariable", "[", "NOT", "]", "LIKE", "stringExpression" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L493-L511
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.nullComparisonExpression
public function nullComparisonExpression() { $expr = $this->identificationVariable(); $nullCompExpr = new NullComparisonExpressionNode($expr); $this->match(Lexer::T_IS); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $nullCompExpr->setNot(true); } $this->match(Lexer::T_NULL); return $nullCompExpr; }
php
public function nullComparisonExpression() { $expr = $this->identificationVariable(); $nullCompExpr = new NullComparisonExpressionNode($expr); $this->match(Lexer::T_IS); if ($this->lexer->isNextToken(Lexer::T_NOT)) { $this->match(Lexer::T_NOT); $nullCompExpr->setNot(true); } $this->match(Lexer::T_NULL); return $nullCompExpr; }
[ "public", "function", "nullComparisonExpression", "(", ")", "{", "$", "expr", "=", "$", "this", "->", "identificationVariable", "(", ")", ";", "$", "nullCompExpr", "=", "new", "NullComparisonExpressionNode", "(", "$", "expr", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_IS", ")", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_NOT", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_NOT", ")", ";", "$", "nullCompExpr", "->", "setNot", "(", "true", ")", ";", "}", "$", "this", "->", "match", "(", "Lexer", "::", "T_NULL", ")", ";", "return", "$", "nullCompExpr", ";", "}" ]
nullComparisonExpression ::= identificationVariable "IS" ["NOT"] "NULL" @return NullComparisonExpressionNode
[ "nullComparisonExpression", "::", "=", "identificationVariable", "IS", "[", "NOT", "]", "NULL" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L518-L535
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.comparisonOperator
public function comparisonOperator() { switch ($this->lexer->lookahead['value']) { case '=': $this->match(Lexer::T_EQUALS); return '='; case '<': $this->match(Lexer::T_LOWER_THAN); $operator = '<'; if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; } else if ($this->lexer->isNextToken(Lexer::T_GREATER_THAN)) { $this->match(Lexer::T_GREATER_THAN); $operator .= '>'; } return $operator; case '>': $this->match(Lexer::T_GREATER_THAN); $operator = '>'; if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; } return $operator; case '!': $this->match(Lexer::T_NEGATE); $this->match(Lexer::T_EQUALS); return '<>'; default: $this->syntaxError('=, <, <=, <>, >, >=, !='); } return null; }
php
public function comparisonOperator() { switch ($this->lexer->lookahead['value']) { case '=': $this->match(Lexer::T_EQUALS); return '='; case '<': $this->match(Lexer::T_LOWER_THAN); $operator = '<'; if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; } else if ($this->lexer->isNextToken(Lexer::T_GREATER_THAN)) { $this->match(Lexer::T_GREATER_THAN); $operator .= '>'; } return $operator; case '>': $this->match(Lexer::T_GREATER_THAN); $operator = '>'; if ($this->lexer->isNextToken(Lexer::T_EQUALS)) { $this->match(Lexer::T_EQUALS); $operator .= '='; } return $operator; case '!': $this->match(Lexer::T_NEGATE); $this->match(Lexer::T_EQUALS); return '<>'; default: $this->syntaxError('=, <, <=, <>, >, >=, !='); } return null; }
[ "public", "function", "comparisonOperator", "(", ")", "{", "switch", "(", "$", "this", "->", "lexer", "->", "lookahead", "[", "'value'", "]", ")", "{", "case", "'='", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_EQUALS", ")", ";", "return", "'='", ";", "case", "'<'", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_LOWER_THAN", ")", ";", "$", "operator", "=", "'<'", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_EQUALS", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_EQUALS", ")", ";", "$", "operator", ".=", "'='", ";", "}", "else", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_GREATER_THAN", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_GREATER_THAN", ")", ";", "$", "operator", ".=", "'>'", ";", "}", "return", "$", "operator", ";", "case", "'>'", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_GREATER_THAN", ")", ";", "$", "operator", "=", "'>'", ";", "if", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_EQUALS", ")", ")", "{", "$", "this", "->", "match", "(", "Lexer", "::", "T_EQUALS", ")", ";", "$", "operator", ".=", "'='", ";", "}", "return", "$", "operator", ";", "case", "'!'", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_NEGATE", ")", ";", "$", "this", "->", "match", "(", "Lexer", "::", "T_EQUALS", ")", ";", "return", "'<>'", ";", "default", ":", "$", "this", "->", "syntaxError", "(", "'=, <, <=, <>, >, >=, !='", ")", ";", "}", "return", "null", ";", "}" ]
comparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!=" @return string
[ "comparisonOperator", "::", "=", "=", "|", "<", "|", "<", "=", "|", "<", ">", "|", ">", "|", ">", "=", "|", "!", "=" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L542-L585
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.arithmeticPrimary
public function arithmeticPrimary() { switch ($this->lexer->lookahead['type']) { case Lexer::T_IDENTIFIER: return $this->identificationVariable(); default: return $this->literal(); } }
php
public function arithmeticPrimary() { switch ($this->lexer->lookahead['type']) { case Lexer::T_IDENTIFIER: return $this->identificationVariable(); default: return $this->literal(); } }
[ "public", "function", "arithmeticPrimary", "(", ")", "{", "switch", "(", "$", "this", "->", "lexer", "->", "lookahead", "[", "'type'", "]", ")", "{", "case", "Lexer", "::", "T_IDENTIFIER", ":", "return", "$", "this", "->", "identificationVariable", "(", ")", ";", "default", ":", "return", "$", "this", "->", "literal", "(", ")", ";", "}", "}" ]
arithmeticPrimary ::= literal | identificationVariable
[ "arithmeticPrimary", "::", "=", "literal", "|", "identificationVariable" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L590-L598
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.literal
public function literal() { switch ($this->lexer->lookahead['type']) { case Lexer::T_STRING: $this->match(Lexer::T_STRING); return new LiteralNode(LiteralNode::STRING, $this->lexer->token['value']); case Lexer::T_INTEGER: case Lexer::T_FLOAT: $this->match( $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT ); return new LiteralNode(LiteralNode::NUMERIC, $this->lexer->token['value']); case Lexer::T_TRUE: case Lexer::T_FALSE: $this->match( $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE ); return new LiteralNode(LiteralNode::BOOLEAN, $this->lexer->token['value']); default: $this->syntaxError('Literal'); } return null; }
php
public function literal() { switch ($this->lexer->lookahead['type']) { case Lexer::T_STRING: $this->match(Lexer::T_STRING); return new LiteralNode(LiteralNode::STRING, $this->lexer->token['value']); case Lexer::T_INTEGER: case Lexer::T_FLOAT: $this->match( $this->lexer->isNextToken(Lexer::T_INTEGER) ? Lexer::T_INTEGER : Lexer::T_FLOAT ); return new LiteralNode(LiteralNode::NUMERIC, $this->lexer->token['value']); case Lexer::T_TRUE: case Lexer::T_FALSE: $this->match( $this->lexer->isNextToken(Lexer::T_TRUE) ? Lexer::T_TRUE : Lexer::T_FALSE ); return new LiteralNode(LiteralNode::BOOLEAN, $this->lexer->token['value']); default: $this->syntaxError('Literal'); } return null; }
[ "public", "function", "literal", "(", ")", "{", "switch", "(", "$", "this", "->", "lexer", "->", "lookahead", "[", "'type'", "]", ")", "{", "case", "Lexer", "::", "T_STRING", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_STRING", ")", ";", "return", "new", "LiteralNode", "(", "LiteralNode", "::", "STRING", ",", "$", "this", "->", "lexer", "->", "token", "[", "'value'", "]", ")", ";", "case", "Lexer", "::", "T_INTEGER", ":", "case", "Lexer", "::", "T_FLOAT", ":", "$", "this", "->", "match", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_INTEGER", ")", "?", "Lexer", "::", "T_INTEGER", ":", "Lexer", "::", "T_FLOAT", ")", ";", "return", "new", "LiteralNode", "(", "LiteralNode", "::", "NUMERIC", ",", "$", "this", "->", "lexer", "->", "token", "[", "'value'", "]", ")", ";", "case", "Lexer", "::", "T_TRUE", ":", "case", "Lexer", "::", "T_FALSE", ":", "$", "this", "->", "match", "(", "$", "this", "->", "lexer", "->", "isNextToken", "(", "Lexer", "::", "T_TRUE", ")", "?", "Lexer", "::", "T_TRUE", ":", "Lexer", "::", "T_FALSE", ")", ";", "return", "new", "LiteralNode", "(", "LiteralNode", "::", "BOOLEAN", ",", "$", "this", "->", "lexer", "->", "token", "[", "'value'", "]", ")", ";", "default", ":", "$", "this", "->", "syntaxError", "(", "'Literal'", ")", ";", "}", "return", "null", ";", "}" ]
Literal ::= string | char | integer | float | boolean @return LiteralNode
[ "Literal", "::", "=", "string", "|", "char", "|", "integer", "|", "float", "|", "boolean" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L605-L631
Swop/FilterExpressionParser
src/Parser/Parser.php
Parser.stringExpression
public function stringExpression() { $lookaheadType = $this->lexer->lookahead['type']; switch ($lookaheadType) { case Lexer::T_IDENTIFIER: return $this->identificationVariable(); case Lexer::T_STRING: $this->match(Lexer::T_STRING); return new LiteralNode(LiteralNode::STRING, $this->lexer->token['value']); } $this->syntaxError( 'StateFieldPathExpression | string' ); return null; }
php
public function stringExpression() { $lookaheadType = $this->lexer->lookahead['type']; switch ($lookaheadType) { case Lexer::T_IDENTIFIER: return $this->identificationVariable(); case Lexer::T_STRING: $this->match(Lexer::T_STRING); return new LiteralNode(LiteralNode::STRING, $this->lexer->token['value']); } $this->syntaxError( 'StateFieldPathExpression | string' ); return null; }
[ "public", "function", "stringExpression", "(", ")", "{", "$", "lookaheadType", "=", "$", "this", "->", "lexer", "->", "lookahead", "[", "'type'", "]", ";", "switch", "(", "$", "lookaheadType", ")", "{", "case", "Lexer", "::", "T_IDENTIFIER", ":", "return", "$", "this", "->", "identificationVariable", "(", ")", ";", "case", "Lexer", "::", "T_STRING", ":", "$", "this", "->", "match", "(", "Lexer", "::", "T_STRING", ")", ";", "return", "new", "LiteralNode", "(", "LiteralNode", "::", "STRING", ",", "$", "this", "->", "lexer", "->", "token", "[", "'value'", "]", ")", ";", "}", "$", "this", "->", "syntaxError", "(", "'StateFieldPathExpression | string'", ")", ";", "return", "null", ";", "}" ]
stringExpression ::= identificationVariable | string @return IdentificationVariableNode|LiteralNode
[ "stringExpression", "::", "=", "identificationVariable", "|", "string" ]
train
https://github.com/Swop/FilterExpressionParser/blob/adcb4bec3588cba48a6928a329aba5b31f837b8c/src/Parser/Parser.php#L650-L668
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.addGroupKeyToPostbox
public function addGroupKeyToPostbox($post) { if ($post->post_type !== 'acf-field-group') { return; } // Check if aldready added global $acfExportManagerHasGroupIdInSidebar; if ($acfExportManagerHasGroupIdInSidebar) { return; } $acfExportManagerHasGroupIdInSidebar = true; $fieldgroup = acf_get_field_group($post->ID); echo '<div class="misc-pub-section"><span style="color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;">#</span>' . $fieldgroup['key'] . '</div>'; }
php
public function addGroupKeyToPostbox($post) { if ($post->post_type !== 'acf-field-group') { return; } // Check if aldready added global $acfExportManagerHasGroupIdInSidebar; if ($acfExportManagerHasGroupIdInSidebar) { return; } $acfExportManagerHasGroupIdInSidebar = true; $fieldgroup = acf_get_field_group($post->ID); echo '<div class="misc-pub-section"><span style="color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;">#</span>' . $fieldgroup['key'] . '</div>'; }
[ "public", "function", "addGroupKeyToPostbox", "(", "$", "post", ")", "{", "if", "(", "$", "post", "->", "post_type", "!==", "'acf-field-group'", ")", "{", "return", ";", "}", "// Check if aldready added", "global", "$", "acfExportManagerHasGroupIdInSidebar", ";", "if", "(", "$", "acfExportManagerHasGroupIdInSidebar", ")", "{", "return", ";", "}", "$", "acfExportManagerHasGroupIdInSidebar", "=", "true", ";", "$", "fieldgroup", "=", "acf_get_field_group", "(", "$", "post", "->", "ID", ")", ";", "echo", "'<div class=\"misc-pub-section\"><span style=\"color:#82878c;font-size:20px;display:inline-block;width:18px;vertical-align:middle;position:relative;top:-1px;text-align:center;margin-right:8px;\">#</span>'", ".", "$", "fieldgroup", "[", "'key'", "]", ".", "'</div>'", ";", "}" ]
Displays the fieldgroup key in misc publishing actions @param WP_Post $post
[ "Displays", "the", "fieldgroup", "key", "in", "misc", "publishing", "actions" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L31-L48
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.import
public function import() : bool { $files = glob($this->exportFolder . 'php/' . '*.php'); if (empty($files)) { return false; } foreach ($files as $file) { $this->imported[] = $file; require_once $file; } return true; }
php
public function import() : bool { $files = glob($this->exportFolder . 'php/' . '*.php'); if (empty($files)) { return false; } foreach ($files as $file) { $this->imported[] = $file; require_once $file; } return true; }
[ "public", "function", "import", "(", ")", ":", "bool", "{", "$", "files", "=", "glob", "(", "$", "this", "->", "exportFolder", ".", "'php/'", ".", "'*.php'", ")", ";", "if", "(", "empty", "(", "$", "files", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "this", "->", "imported", "[", "]", "=", "$", "file", ";", "require_once", "$", "file", ";", "}", "return", "true", ";", "}" ]
Import (require) acf export files @return boolean
[ "Import", "(", "require", ")", "acf", "export", "files" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L54-L68
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.deleteExport
public function deleteExport(array $fieldgroup) : bool { $filename = $this->getExportFilename($fieldgroup); $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']); $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']); return true; }
php
public function deleteExport(array $fieldgroup) : bool { $filename = $this->getExportFilename($fieldgroup); $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']); $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']); return true; }
[ "public", "function", "deleteExport", "(", "array", "$", "fieldgroup", ")", ":", "bool", "{", "$", "filename", "=", "$", "this", "->", "getExportFilename", "(", "$", "fieldgroup", ")", ";", "$", "this", "->", "maybeUnlink", "(", "$", "this", "->", "exportFolder", ".", "'php/'", ".", "$", "filename", "[", "'php'", "]", ")", ";", "$", "this", "->", "maybeUnlink", "(", "$", "this", "->", "exportFolder", ".", "'json/'", ".", "$", "filename", "[", "'json'", "]", ")", ";", "return", "true", ";", "}" ]
Deletes export file for deleted fieldgroup @param array $fieldgroup @return boolean
[ "Deletes", "export", "file", "for", "deleted", "fieldgroup" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L75-L83
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.export
public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array { global $locale; $locale = "en_US"; // Bail if the fieldgroup shouldn't be exported if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) { return array(); } $this->maybeCreateExportFolders(); if ($this->textdomain) { acf_update_setting('l10n', true); acf_update_setting('l10n_textdomain', $this->textdomain); acf_update_setting('l10n_var_export', true); } $filename = $this->getExportFilename($fieldgroup); // Export php file $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']); $code = $this->generatePhp($fieldgroup['ID'], $translate); $phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w'); fwrite($phpFile, $code); fclose($phpFile); // Export json file $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']); $jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w'); $json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false)); fwrite($jsonFile, $json); fclose($jsonFile); return array( 'php' => $this->exportFolder . 'php/' . $filename['php'], 'json' => $this->exportFolder . 'json/' . $filename['json'] ); }
php
public function export(array $fieldgroup, bool $restrictToExportPosts = true, bool $translate = true) : array { global $locale; $locale = "en_US"; // Bail if the fieldgroup shouldn't be exported if ($restrictToExportPosts && !in_array($fieldgroup['key'], $this->exportPosts)) { return array(); } $this->maybeCreateExportFolders(); if ($this->textdomain) { acf_update_setting('l10n', true); acf_update_setting('l10n_textdomain', $this->textdomain); acf_update_setting('l10n_var_export', true); } $filename = $this->getExportFilename($fieldgroup); // Export php file $this->maybeUnlink($this->exportFolder . 'php/' . $filename['php']); $code = $this->generatePhp($fieldgroup['ID'], $translate); $phpFile = fopen($this->exportFolder . 'php/' . $filename['php'], 'w'); fwrite($phpFile, $code); fclose($phpFile); // Export json file $this->maybeUnlink($this->exportFolder . 'json/' . $filename['json']); $jsonFile = fopen($this->exportFolder . 'json/' . $filename['json'], 'w'); $json = $this->getJson($this->getFieldgroupParams($fieldgroup['ID'], false)); fwrite($jsonFile, $json); fclose($jsonFile); return array( 'php' => $this->exportFolder . 'php/' . $filename['php'], 'json' => $this->exportFolder . 'json/' . $filename['json'] ); }
[ "public", "function", "export", "(", "array", "$", "fieldgroup", ",", "bool", "$", "restrictToExportPosts", "=", "true", ",", "bool", "$", "translate", "=", "true", ")", ":", "array", "{", "global", "$", "locale", ";", "$", "locale", "=", "\"en_US\"", ";", "// Bail if the fieldgroup shouldn't be exported", "if", "(", "$", "restrictToExportPosts", "&&", "!", "in_array", "(", "$", "fieldgroup", "[", "'key'", "]", ",", "$", "this", "->", "exportPosts", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "this", "->", "maybeCreateExportFolders", "(", ")", ";", "if", "(", "$", "this", "->", "textdomain", ")", "{", "acf_update_setting", "(", "'l10n'", ",", "true", ")", ";", "acf_update_setting", "(", "'l10n_textdomain'", ",", "$", "this", "->", "textdomain", ")", ";", "acf_update_setting", "(", "'l10n_var_export'", ",", "true", ")", ";", "}", "$", "filename", "=", "$", "this", "->", "getExportFilename", "(", "$", "fieldgroup", ")", ";", "// Export php file", "$", "this", "->", "maybeUnlink", "(", "$", "this", "->", "exportFolder", ".", "'php/'", ".", "$", "filename", "[", "'php'", "]", ")", ";", "$", "code", "=", "$", "this", "->", "generatePhp", "(", "$", "fieldgroup", "[", "'ID'", "]", ",", "$", "translate", ")", ";", "$", "phpFile", "=", "fopen", "(", "$", "this", "->", "exportFolder", ".", "'php/'", ".", "$", "filename", "[", "'php'", "]", ",", "'w'", ")", ";", "fwrite", "(", "$", "phpFile", ",", "$", "code", ")", ";", "fclose", "(", "$", "phpFile", ")", ";", "// Export json file", "$", "this", "->", "maybeUnlink", "(", "$", "this", "->", "exportFolder", ".", "'json/'", ".", "$", "filename", "[", "'json'", "]", ")", ";", "$", "jsonFile", "=", "fopen", "(", "$", "this", "->", "exportFolder", ".", "'json/'", ".", "$", "filename", "[", "'json'", "]", ",", "'w'", ")", ";", "$", "json", "=", "$", "this", "->", "getJson", "(", "$", "this", "->", "getFieldgroupParams", "(", "$", "fieldgroup", "[", "'ID'", "]", ",", "false", ")", ")", ";", "fwrite", "(", "$", "jsonFile", ",", "$", "json", ")", ";", "fclose", "(", "$", "jsonFile", ")", ";", "return", "array", "(", "'php'", "=>", "$", "this", "->", "exportFolder", ".", "'php/'", ".", "$", "filename", "[", "'php'", "]", ",", "'json'", "=>", "$", "this", "->", "exportFolder", ".", "'json/'", ".", "$", "filename", "[", "'json'", "]", ")", ";", "}" ]
Does the actual export of the php fields @param array $fieldgroup Fieldgroup data @return array Paths to exported files
[ "Does", "the", "actual", "export", "of", "the", "php", "fields" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L101-L139
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.getJson
public function getJson(array $fieldgroup) : string { $json = json_encode($fieldgroup, JSON_PRETTY_PRINT); // Remove translation stuff from json $json = str_replace('!!__(!!\'', '', $json); $json = str_replace("!!', !!'" . $this->textdomain . "!!')!!", '', $json); return '[' . $json . "]\n\r"; }
php
public function getJson(array $fieldgroup) : string { $json = json_encode($fieldgroup, JSON_PRETTY_PRINT); // Remove translation stuff from json $json = str_replace('!!__(!!\'', '', $json); $json = str_replace("!!', !!'" . $this->textdomain . "!!')!!", '', $json); return '[' . $json . "]\n\r"; }
[ "public", "function", "getJson", "(", "array", "$", "fieldgroup", ")", ":", "string", "{", "$", "json", "=", "json_encode", "(", "$", "fieldgroup", ",", "JSON_PRETTY_PRINT", ")", ";", "// Remove translation stuff from json", "$", "json", "=", "str_replace", "(", "'!!__(!!\\''", ",", "''", ",", "$", "json", ")", ";", "$", "json", "=", "str_replace", "(", "\"!!', !!'\"", ".", "$", "this", "->", "textdomain", ".", "\"!!')!!\"", ",", "''", ",", "$", "json", ")", ";", "return", "'['", ".", "$", "json", ".", "\"]\\n\\r\"", ";", "}" ]
Get fieldgroup as json @param array $fieldgroup @return string
[ "Get", "fieldgroup", "as", "json" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L146-L155
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.maybeCreateExportFolders
public function maybeCreateExportFolders() { if (!is_writable($this->exportFolder)) { trigger_error('The export folder (' . $this->exportFolder .') is not writable. Exports will not be saved.', E_USER_ERROR); } if (!file_exists($this->exportFolder . 'json')) { mkdir($this->exportFolder . 'json'); chmod($this->exportFolder . 'json', 0777); } if (!file_exists($this->exportFolder . 'php')) { mkdir($this->exportFolder . 'php'); chmod($this->exportFolder . 'php', 0777); } }
php
public function maybeCreateExportFolders() { if (!is_writable($this->exportFolder)) { trigger_error('The export folder (' . $this->exportFolder .') is not writable. Exports will not be saved.', E_USER_ERROR); } if (!file_exists($this->exportFolder . 'json')) { mkdir($this->exportFolder . 'json'); chmod($this->exportFolder . 'json', 0777); } if (!file_exists($this->exportFolder . 'php')) { mkdir($this->exportFolder . 'php'); chmod($this->exportFolder . 'php', 0777); } }
[ "public", "function", "maybeCreateExportFolders", "(", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "exportFolder", ")", ")", "{", "trigger_error", "(", "'The export folder ('", ".", "$", "this", "->", "exportFolder", ".", "') is not writable. Exports will not be saved.'", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "this", "->", "exportFolder", ".", "'json'", ")", ")", "{", "mkdir", "(", "$", "this", "->", "exportFolder", ".", "'json'", ")", ";", "chmod", "(", "$", "this", "->", "exportFolder", ".", "'json'", ",", "0777", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "this", "->", "exportFolder", ".", "'php'", ")", ")", "{", "mkdir", "(", "$", "this", "->", "exportFolder", ".", "'php'", ")", ";", "chmod", "(", "$", "this", "->", "exportFolder", ".", "'php'", ",", "0777", ")", ";", "}", "}" ]
Creates export folders if needed @return void
[ "Creates", "export", "folders", "if", "needed" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L161-L176
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.getExportFilename
public function getExportFilename(array $fieldgroup) : array { if ($key = array_search($fieldgroup['key'], $this->exportPosts)) { return array( 'php' => $key . '.php', 'json' => $key . '.json' ); } return array( 'php' => sanitize_title($fieldgroup['title']) . '.php', 'json' => sanitize_title($fieldgroup['title']) . '.json' ); }
php
public function getExportFilename(array $fieldgroup) : array { if ($key = array_search($fieldgroup['key'], $this->exportPosts)) { return array( 'php' => $key . '.php', 'json' => $key . '.json' ); } return array( 'php' => sanitize_title($fieldgroup['title']) . '.php', 'json' => sanitize_title($fieldgroup['title']) . '.json' ); }
[ "public", "function", "getExportFilename", "(", "array", "$", "fieldgroup", ")", ":", "array", "{", "if", "(", "$", "key", "=", "array_search", "(", "$", "fieldgroup", "[", "'key'", "]", ",", "$", "this", "->", "exportPosts", ")", ")", "{", "return", "array", "(", "'php'", "=>", "$", "key", ".", "'.php'", ",", "'json'", "=>", "$", "key", ".", "'.json'", ")", ";", "}", "return", "array", "(", "'php'", "=>", "sanitize_title", "(", "$", "fieldgroup", "[", "'title'", "]", ")", ".", "'.php'", ",", "'json'", "=>", "sanitize_title", "(", "$", "fieldgroup", "[", "'title'", "]", ")", ".", "'.json'", ")", ";", "}" ]
Get filename for the export file @param array $fieldgroup Fieldgroup data @return array
[ "Get", "filename", "for", "the", "export", "file" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L192-L205
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.generatePhp
protected function generatePhp(int $fieldgroupId, bool $translate = true) : string { $strReplace = array( " " => " ", "!!\'" => "'", "'!!" => "", "!!'" => "", "array (" => "array(", " => \n" => " => " ); $pregReplace = array( '/([\t\r\n]+?)array/' => 'array', '/[0-9]+ => array/' => 'array', '/=>(\s+)array\(/' => '=> array(' ); $fieldgroup = $this->getFieldgroupParams($fieldgroupId, $translate); $code = var_export($fieldgroup, true); $code = str_replace(array_keys($strReplace), array_values($strReplace), $code); $code = preg_replace(array_keys($pregReplace), array_values($pregReplace), $code); $export = "<?php \n\r\n\rif (function_exists('acf_add_local_field_group')) {\n\r"; $export .= " acf_add_local_field_group({$code});"; $export .= "\n\r}"; acf_update_setting('l10n_var_export', false); return $export; }
php
protected function generatePhp(int $fieldgroupId, bool $translate = true) : string { $strReplace = array( " " => " ", "!!\'" => "'", "'!!" => "", "!!'" => "", "array (" => "array(", " => \n" => " => " ); $pregReplace = array( '/([\t\r\n]+?)array/' => 'array', '/[0-9]+ => array/' => 'array', '/=>(\s+)array\(/' => '=> array(' ); $fieldgroup = $this->getFieldgroupParams($fieldgroupId, $translate); $code = var_export($fieldgroup, true); $code = str_replace(array_keys($strReplace), array_values($strReplace), $code); $code = preg_replace(array_keys($pregReplace), array_values($pregReplace), $code); $export = "<?php \n\r\n\rif (function_exists('acf_add_local_field_group')) {\n\r"; $export .= " acf_add_local_field_group({$code});"; $export .= "\n\r}"; acf_update_setting('l10n_var_export', false); return $export; }
[ "protected", "function", "generatePhp", "(", "int", "$", "fieldgroupId", ",", "bool", "$", "translate", "=", "true", ")", ":", "string", "{", "$", "strReplace", "=", "array", "(", "\" \"", "=>", "\" \"", ",", "\"!!\\'\"", "=>", "\"'\"", ",", "\"'!!\"", "=>", "\"\"", ",", "\"!!'\"", "=>", "\"\"", ",", "\"array (\"", "=>", "\"array(\"", ",", "\" => \\n\"", "=>", "\" => \"", ")", ";", "$", "pregReplace", "=", "array", "(", "'/([\\t\\r\\n]+?)array/'", "=>", "'array'", ",", "'/[0-9]+ => array/'", "=>", "'array'", ",", "'/=>(\\s+)array\\(/'", "=>", "'=> array('", ")", ";", "$", "fieldgroup", "=", "$", "this", "->", "getFieldgroupParams", "(", "$", "fieldgroupId", ",", "$", "translate", ")", ";", "$", "code", "=", "var_export", "(", "$", "fieldgroup", ",", "true", ")", ";", "$", "code", "=", "str_replace", "(", "array_keys", "(", "$", "strReplace", ")", ",", "array_values", "(", "$", "strReplace", ")", ",", "$", "code", ")", ";", "$", "code", "=", "preg_replace", "(", "array_keys", "(", "$", "pregReplace", ")", ",", "array_values", "(", "$", "pregReplace", ")", ",", "$", "code", ")", ";", "$", "export", "=", "\"<?php \\n\\r\\n\\rif (function_exists('acf_add_local_field_group')) {\\n\\r\"", ";", "$", "export", ".=", "\" acf_add_local_field_group({$code});\"", ";", "$", "export", ".=", "\"\\n\\r}\"", ";", "acf_update_setting", "(", "'l10n_var_export'", ",", "false", ")", ";", "return", "$", "export", ";", "}" ]
Generates PHP exportcode for a fieldgroup @param int $fieldgroupId @return string
[ "Generates", "PHP", "exportcode", "for", "a", "fieldgroup" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L212-L242
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.getFieldgroupParams
public function getFieldgroupParams(int $fieldgroupId, bool $translate = true) : array { // Get the fieldgroup $fieldgroup = acf_get_field_group($fieldgroupId); // Bail if fieldgroup is empty if (empty($fieldgroup)) { trigger_error('The fieldgroup with id "' . $fieldgroupId . '" is empty.', E_USER_WARNING); return array(); } // Get the fields in the fieldgroup $fieldgroup['fields'] = acf_get_fields($fieldgroup); // Translate if ($translate) { $fieldgroup = $this->translate($fieldgroup); } // Preapre for export return acf_prepare_field_group_for_export($fieldgroup); }
php
public function getFieldgroupParams(int $fieldgroupId, bool $translate = true) : array { // Get the fieldgroup $fieldgroup = acf_get_field_group($fieldgroupId); // Bail if fieldgroup is empty if (empty($fieldgroup)) { trigger_error('The fieldgroup with id "' . $fieldgroupId . '" is empty.', E_USER_WARNING); return array(); } // Get the fields in the fieldgroup $fieldgroup['fields'] = acf_get_fields($fieldgroup); // Translate if ($translate) { $fieldgroup = $this->translate($fieldgroup); } // Preapre for export return acf_prepare_field_group_for_export($fieldgroup); }
[ "public", "function", "getFieldgroupParams", "(", "int", "$", "fieldgroupId", ",", "bool", "$", "translate", "=", "true", ")", ":", "array", "{", "// Get the fieldgroup", "$", "fieldgroup", "=", "acf_get_field_group", "(", "$", "fieldgroupId", ")", ";", "// Bail if fieldgroup is empty", "if", "(", "empty", "(", "$", "fieldgroup", ")", ")", "{", "trigger_error", "(", "'The fieldgroup with id \"'", ".", "$", "fieldgroupId", ".", "'\" is empty.'", ",", "E_USER_WARNING", ")", ";", "return", "array", "(", ")", ";", "}", "// Get the fields in the fieldgroup", "$", "fieldgroup", "[", "'fields'", "]", "=", "acf_get_fields", "(", "$", "fieldgroup", ")", ";", "// Translate", "if", "(", "$", "translate", ")", "{", "$", "fieldgroup", "=", "$", "this", "->", "translate", "(", "$", "fieldgroup", ")", ";", "}", "// Preapre for export", "return", "acf_prepare_field_group_for_export", "(", "$", "fieldgroup", ")", ";", "}" ]
Get exportable fieldgroup params @param int $fieldgroupId @return array
[ "Get", "exportable", "fieldgroup", "params" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L249-L270
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.translate
public function translate(array $fieldgroup) : array { foreach ($fieldgroup['fields'] as &$field) { if (function_exists('\acf_translate_field')) { $field = \acf_translate_field($field); } } return $fieldgroup; }
php
public function translate(array $fieldgroup) : array { foreach ($fieldgroup['fields'] as &$field) { if (function_exists('\acf_translate_field')) { $field = \acf_translate_field($field); } } return $fieldgroup; }
[ "public", "function", "translate", "(", "array", "$", "fieldgroup", ")", ":", "array", "{", "foreach", "(", "$", "fieldgroup", "[", "'fields'", "]", "as", "&", "$", "field", ")", "{", "if", "(", "function_exists", "(", "'\\acf_translate_field'", ")", ")", "{", "$", "field", "=", "\\", "acf_translate_field", "(", "$", "field", ")", ";", "}", "}", "return", "$", "fieldgroup", ";", "}" ]
Translate fieldgroup @param array $fieldgroup @return array
[ "Translate", "fieldgroup" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L277-L287
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.translateFieldParams
public function translateFieldParams(array $field) : array { $keys = array('prepend', 'append', 'placeholder', 'default_value'); foreach ($keys as $key) { if (!isset($field[$key])) { continue; } $field[$key] = acf_translate($field[$key]); } if (isset($field['sub_fields']) && is_array($field['sub_fields'])) { foreach ($field['sub_fields'] as &$subfield) { if (function_exists('\acf_translate_field')) { $subfield = \acf_translate_field($subfield); } } } return $field; }
php
public function translateFieldParams(array $field) : array { $keys = array('prepend', 'append', 'placeholder', 'default_value'); foreach ($keys as $key) { if (!isset($field[$key])) { continue; } $field[$key] = acf_translate($field[$key]); } if (isset($field['sub_fields']) && is_array($field['sub_fields'])) { foreach ($field['sub_fields'] as &$subfield) { if (function_exists('\acf_translate_field')) { $subfield = \acf_translate_field($subfield); } } } return $field; }
[ "public", "function", "translateFieldParams", "(", "array", "$", "field", ")", ":", "array", "{", "$", "keys", "=", "array", "(", "'prepend'", ",", "'append'", ",", "'placeholder'", ",", "'default_value'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "field", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "field", "[", "$", "key", "]", "=", "acf_translate", "(", "$", "field", "[", "$", "key", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "field", "[", "'sub_fields'", "]", ")", "&&", "is_array", "(", "$", "field", "[", "'sub_fields'", "]", ")", ")", "{", "foreach", "(", "$", "field", "[", "'sub_fields'", "]", "as", "&", "$", "subfield", ")", "{", "if", "(", "function_exists", "(", "'\\acf_translate_field'", ")", ")", "{", "$", "subfield", "=", "\\", "acf_translate_field", "(", "$", "subfield", ")", ";", "}", "}", "}", "return", "$", "field", ";", "}" ]
Translate field params @param array $field ACF Field params @return array Translated ACF field params
[ "Translate", "field", "params" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L294-L316
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.setExportFolder
public function setExportFolder(string $folder) { $folder = trailingslashit($folder); if (!file_exists($folder)) { if (!mkdir($folder)) { trigger_error('The export folder (' . $folder .') can not be found. Exports will not be saved.', E_USER_WARNING); } else { chmod($folder, 0777); } } $this->exportFolder = $folder; }
php
public function setExportFolder(string $folder) { $folder = trailingslashit($folder); if (!file_exists($folder)) { if (!mkdir($folder)) { trigger_error('The export folder (' . $folder .') can not be found. Exports will not be saved.', E_USER_WARNING); } else { chmod($folder, 0777); } } $this->exportFolder = $folder; }
[ "public", "function", "setExportFolder", "(", "string", "$", "folder", ")", "{", "$", "folder", "=", "trailingslashit", "(", "$", "folder", ")", ";", "if", "(", "!", "file_exists", "(", "$", "folder", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "folder", ")", ")", "{", "trigger_error", "(", "'The export folder ('", ".", "$", "folder", ".", "') can not be found. Exports will not be saved.'", ",", "E_USER_WARNING", ")", ";", "}", "else", "{", "chmod", "(", "$", "folder", ",", "0777", ")", ";", "}", "}", "$", "this", "->", "exportFolder", "=", "$", "folder", ";", "}" ]
Set exports folder @param string $folder Path to exports folder @return void
[ "Set", "exports", "folder" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L323-L336
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.autoExport
public function autoExport(array $ids) { $this->exportPosts = array_replace($this->exportPosts, $ids); $this->exportPosts = array_unique($this->exportPosts); }
php
public function autoExport(array $ids) { $this->exportPosts = array_replace($this->exportPosts, $ids); $this->exportPosts = array_unique($this->exportPosts); }
[ "public", "function", "autoExport", "(", "array", "$", "ids", ")", "{", "$", "this", "->", "exportPosts", "=", "array_replace", "(", "$", "this", "->", "exportPosts", ",", "$", "ids", ")", ";", "$", "this", "->", "exportPosts", "=", "array_unique", "(", "$", "this", "->", "exportPosts", ")", ";", "}" ]
Sets which acf-fieldgroups postids to autoexport @param array $ids @return void
[ "Sets", "which", "acf", "-", "fieldgroups", "postids", "to", "autoexport" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L343-L347
helsingborg-stad/acf-export-manager
src/AcfExportManager.php
AcfExportManager.handleBulkExport
public function handleBulkExport($redirectTo, $doaction, $postIds) { if ($doaction !== 'acfExportManager-export') { return $redirectTo; } foreach ($postIds as $postId) { $fieldgroup = acf_get_field_group($postId); if (!in_array($fieldgroup['key'], $this->exportPosts)) { continue; } $this->export($fieldgroup, false, false); } $redirectTo = add_query_arg('bulkExportedFieldgroups', count($postIds), $redirectTo); return $redirectTo; }
php
public function handleBulkExport($redirectTo, $doaction, $postIds) { if ($doaction !== 'acfExportManager-export') { return $redirectTo; } foreach ($postIds as $postId) { $fieldgroup = acf_get_field_group($postId); if (!in_array($fieldgroup['key'], $this->exportPosts)) { continue; } $this->export($fieldgroup, false, false); } $redirectTo = add_query_arg('bulkExportedFieldgroups', count($postIds), $redirectTo); return $redirectTo; }
[ "public", "function", "handleBulkExport", "(", "$", "redirectTo", ",", "$", "doaction", ",", "$", "postIds", ")", "{", "if", "(", "$", "doaction", "!==", "'acfExportManager-export'", ")", "{", "return", "$", "redirectTo", ";", "}", "foreach", "(", "$", "postIds", "as", "$", "postId", ")", "{", "$", "fieldgroup", "=", "acf_get_field_group", "(", "$", "postId", ")", ";", "if", "(", "!", "in_array", "(", "$", "fieldgroup", "[", "'key'", "]", ",", "$", "this", "->", "exportPosts", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "export", "(", "$", "fieldgroup", ",", "false", ",", "false", ")", ";", "}", "$", "redirectTo", "=", "add_query_arg", "(", "'bulkExportedFieldgroups'", ",", "count", "(", "$", "postIds", ")", ",", "$", "redirectTo", ")", ";", "return", "$", "redirectTo", ";", "}" ]
Handles bulk exporting @param string $redirectTo Redirect @param string $doaction The bulk action to do @param array $postIds Selected posts @return string The redirect
[ "Handles", "bulk", "exporting" ]
train
https://github.com/helsingborg-stad/acf-export-manager/blob/27e904a24eb013cac5c8f3d3c30e88b5b9b7859b/src/AcfExportManager.php#L375-L394
phpmob/changmin
src/PhpMob/MediaBundle/EventListener/UploadFileListener.php
UploadFileListener.postRemove
public function postRemove(LifecycleEventArgs $args) { $object = $args->getObject(); if (!$object instanceof FileInterface) { return; } $this->removeFile($object->getPath()); }
php
public function postRemove(LifecycleEventArgs $args) { $object = $args->getObject(); if (!$object instanceof FileInterface) { return; } $this->removeFile($object->getPath()); }
[ "public", "function", "postRemove", "(", "LifecycleEventArgs", "$", "args", ")", "{", "$", "object", "=", "$", "args", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "object", "instanceof", "FileInterface", ")", "{", "return", ";", "}", "$", "this", "->", "removeFile", "(", "$", "object", "->", "getPath", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/EventListener/UploadFileListener.php#L61-L70
controlabs/routify
src/Routify/RouteCollection.php
RouteCollection.add
public function add(Route $route) { // $this->routes[$route->method()][$route->uri()] = $route; $this->routes[$route->method().$route->route()] = $route; return $route; }
php
public function add(Route $route) { // $this->routes[$route->method()][$route->uri()] = $route; $this->routes[$route->method().$route->route()] = $route; return $route; }
[ "public", "function", "add", "(", "Route", "$", "route", ")", "{", "// $this->routes[$route->method()][$route->uri()] = $route;", "$", "this", "->", "routes", "[", "$", "route", "->", "method", "(", ")", ".", "$", "route", "->", "route", "(", ")", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Add a Route instance to the collection. @param \Controlabs\Routify\Route $route @return \Controlabs\Routify\Route
[ "Add", "a", "Route", "instance", "to", "the", "collection", "." ]
train
https://github.com/controlabs/routify/blob/a4e92000fc61ddc7f297984ef9924b6d9df508a4/src/Routify/RouteCollection.php#L25-L30
forkiss/pharest
src/Pharest/ExceptionHandler.php
ExceptionHandler.hasCustomHandler
public function hasCustomHandler() { if (!class_exists(\App\Exception\Handler::class)) { return false; } if (!in_array(\Pharest\Exception\ExceptionHandler::class, class_implements(\App\Exception\Handler::class))) { return false; } return true; }
php
public function hasCustomHandler() { if (!class_exists(\App\Exception\Handler::class)) { return false; } if (!in_array(\Pharest\Exception\ExceptionHandler::class, class_implements(\App\Exception\Handler::class))) { return false; } return true; }
[ "public", "function", "hasCustomHandler", "(", ")", "{", "if", "(", "!", "class_exists", "(", "\\", "App", "\\", "Exception", "\\", "Handler", "::", "class", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "in_array", "(", "\\", "Pharest", "\\", "Exception", "\\", "ExceptionHandler", "::", "class", ",", "class_implements", "(", "\\", "App", "\\", "Exception", "\\", "Handler", "::", "class", ")", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determine if the app has custom exception handler @return bool
[ "Determine", "if", "the", "app", "has", "custom", "exception", "handler" ]
train
https://github.com/forkiss/pharest/blob/f8b444f9bba446bf7994d98f27585529aefed565/src/Pharest/ExceptionHandler.php#L34-L45
ClanCats/Core
src/bundles/Session/Manager/Cookie.php
Manager_Cookie.read
public function read( $id ) { if ( $this->has( $id ) ) { return json_decode( \CCCrypter::decode( \CCCookie::get( $id.$this->cookie_suffix ), $this->crypt_salt ), true ); } return array(); }
php
public function read( $id ) { if ( $this->has( $id ) ) { return json_decode( \CCCrypter::decode( \CCCookie::get( $id.$this->cookie_suffix ), $this->crypt_salt ), true ); } return array(); }
[ "public", "function", "read", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "id", ")", ")", "{", "return", "json_decode", "(", "\\", "CCCrypter", "::", "decode", "(", "\\", "CCCookie", "::", "get", "(", "$", "id", ".", "$", "this", "->", "cookie_suffix", ")", ",", "$", "this", "->", "crypt_salt", ")", ",", "true", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Read data from the session dirver @param string $id The session id key. @return array
[ "Read", "data", "from", "the", "session", "dirver" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager/Cookie.php#L43-L51
ClanCats/Core
src/bundles/Session/Manager/Cookie.php
Manager_Cookie.write
public function write( $id, $data ) { \CCCookie::set( $id.$this->cookie_suffix, \CCCrypter::encode( json_encode( $data ), $this->crypt_salt ) ); }
php
public function write( $id, $data ) { \CCCookie::set( $id.$this->cookie_suffix, \CCCrypter::encode( json_encode( $data ), $this->crypt_salt ) ); }
[ "public", "function", "write", "(", "$", "id", ",", "$", "data", ")", "{", "\\", "CCCookie", "::", "set", "(", "$", "id", ".", "$", "this", "->", "cookie_suffix", ",", "\\", "CCCrypter", "::", "encode", "(", "json_encode", "(", "$", "data", ")", ",", "$", "this", "->", "crypt_salt", ")", ")", ";", "}" ]
Check if a session with the given key already exists @param string $id The session id key. @param array $data @return bool
[ "Check", "if", "a", "session", "with", "the", "given", "key", "already", "exists" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager/Cookie.php#L71-L74
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/ContentManager.php
ContentManager.find
public function find(ValueObject $object) { try { if ($object->getProperty('remote_id')) { $content = $this->contentService->loadContentByRemoteId($object->getProperty('remote_id')); } } catch (NotFoundException $notFoundException) { // We'll throw our own exception later instead. } if (!isset($content)) { throw new ObjectNotFoundException(Content::class, array('remote_id')); } return $content; }
php
public function find(ValueObject $object) { try { if ($object->getProperty('remote_id')) { $content = $this->contentService->loadContentByRemoteId($object->getProperty('remote_id')); } } catch (NotFoundException $notFoundException) { // We'll throw our own exception later instead. } if (!isset($content)) { throw new ObjectNotFoundException(Content::class, array('remote_id')); } return $content; }
[ "public", "function", "find", "(", "ValueObject", "$", "object", ")", "{", "try", "{", "if", "(", "$", "object", "->", "getProperty", "(", "'remote_id'", ")", ")", "{", "$", "content", "=", "$", "this", "->", "contentService", "->", "loadContentByRemoteId", "(", "$", "object", "->", "getProperty", "(", "'remote_id'", ")", ")", ";", "}", "}", "catch", "(", "NotFoundException", "$", "notFoundException", ")", "{", "// We'll throw our own exception later instead.", "}", "if", "(", "!", "isset", "(", "$", "content", ")", ")", "{", "throw", "new", "ObjectNotFoundException", "(", "Content", "::", "class", ",", "array", "(", "'remote_id'", ")", ")", ";", "}", "return", "$", "content", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/ContentManager.php#L93-L108
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/ContentManager.php
ContentManager.create
public function create(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } $this->ensureDefaults($object); $createStruct = $this->contentService->newContentCreateStruct( $this->contentTypeService->loadContentTypeByIdentifier($object->getProperty('content_type_identifier')), $object->getProperty('main_language_code') ); $object->getMapper()->mapObjectToCreateStruct($createStruct); /** @var LocationObject[] $locationObjects */ $locationObjects = $object->getProperty('parent_locations'); $locationCreateStructs = []; if (is_array($locationObjects) && count($locationObjects) > 0) { foreach ($locationObjects as $locationObject) { $locationCreateStruct = $this->locationService->newLocationCreateStruct($locationObject->data['parent_location_id']); $locationObject->getMapper()->mapObjectToCreateStruct($locationCreateStruct); $locationCreateStructs[] = $locationCreateStruct; } } $content = $this->contentService->createContent($createStruct, $locationCreateStructs); $content = $this->contentService->publishVersion($content->versionInfo); if ($this->logger) { $this->logger->info(sprintf('Published new version of %s', $object->getProperty('name')), array('ContentManager::create')); } $object->setProperty('id', $content->contentInfo->id); $object->setProperty('version_info', $content->versionInfo); $object->setProperty('content_info', $content->contentInfo); return $object; }
php
public function create(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } $this->ensureDefaults($object); $createStruct = $this->contentService->newContentCreateStruct( $this->contentTypeService->loadContentTypeByIdentifier($object->getProperty('content_type_identifier')), $object->getProperty('main_language_code') ); $object->getMapper()->mapObjectToCreateStruct($createStruct); /** @var LocationObject[] $locationObjects */ $locationObjects = $object->getProperty('parent_locations'); $locationCreateStructs = []; if (is_array($locationObjects) && count($locationObjects) > 0) { foreach ($locationObjects as $locationObject) { $locationCreateStruct = $this->locationService->newLocationCreateStruct($locationObject->data['parent_location_id']); $locationObject->getMapper()->mapObjectToCreateStruct($locationCreateStruct); $locationCreateStructs[] = $locationCreateStruct; } } $content = $this->contentService->createContent($createStruct, $locationCreateStructs); $content = $this->contentService->publishVersion($content->versionInfo); if ($this->logger) { $this->logger->info(sprintf('Published new version of %s', $object->getProperty('name')), array('ContentManager::create')); } $object->setProperty('id', $content->contentInfo->id); $object->setProperty('version_info', $content->versionInfo); $object->setProperty('content_info', $content->contentInfo); return $object; }
[ "public", "function", "create", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "ContentObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "ContentObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "ensureDefaults", "(", "$", "object", ")", ";", "$", "createStruct", "=", "$", "this", "->", "contentService", "->", "newContentCreateStruct", "(", "$", "this", "->", "contentTypeService", "->", "loadContentTypeByIdentifier", "(", "$", "object", "->", "getProperty", "(", "'content_type_identifier'", ")", ")", ",", "$", "object", "->", "getProperty", "(", "'main_language_code'", ")", ")", ";", "$", "object", "->", "getMapper", "(", ")", "->", "mapObjectToCreateStruct", "(", "$", "createStruct", ")", ";", "/** @var LocationObject[] $locationObjects */", "$", "locationObjects", "=", "$", "object", "->", "getProperty", "(", "'parent_locations'", ")", ";", "$", "locationCreateStructs", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "locationObjects", ")", "&&", "count", "(", "$", "locationObjects", ")", ">", "0", ")", "{", "foreach", "(", "$", "locationObjects", "as", "$", "locationObject", ")", "{", "$", "locationCreateStruct", "=", "$", "this", "->", "locationService", "->", "newLocationCreateStruct", "(", "$", "locationObject", "->", "data", "[", "'parent_location_id'", "]", ")", ";", "$", "locationObject", "->", "getMapper", "(", ")", "->", "mapObjectToCreateStruct", "(", "$", "locationCreateStruct", ")", ";", "$", "locationCreateStructs", "[", "]", "=", "$", "locationCreateStruct", ";", "}", "}", "$", "content", "=", "$", "this", "->", "contentService", "->", "createContent", "(", "$", "createStruct", ",", "$", "locationCreateStructs", ")", ";", "$", "content", "=", "$", "this", "->", "contentService", "->", "publishVersion", "(", "$", "content", "->", "versionInfo", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Published new version of %s'", ",", "$", "object", "->", "getProperty", "(", "'name'", ")", ")", ",", "array", "(", "'ContentManager::create'", ")", ")", ";", "}", "$", "object", "->", "setProperty", "(", "'id'", ",", "$", "content", "->", "contentInfo", "->", "id", ")", ";", "$", "object", "->", "setProperty", "(", "'version_info'", ",", "$", "content", "->", "versionInfo", ")", ";", "$", "object", "->", "setProperty", "(", "'content_info'", ",", "$", "content", "->", "contentInfo", ")", ";", "return", "$", "object", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/ContentManager.php#L113-L151
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/ContentManager.php
ContentManager.update
public function update(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } $this->ensureDefaults($object); $existingContent = $this->find($object); if (null === $object->getProperty('content_info')) { $object->setProperty('content_info', $existingContent->contentInfo); } $contentDraft = $this->contentService->createContentDraft($object->getProperty('content_info')); $contentUpdateStruct = $this->contentService->newContentUpdateStruct(); $object->getMapper()->mapObjectToUpdateStruct($contentUpdateStruct); $contentDraft = $this->contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct); $content = $this->contentService->publishVersion($contentDraft->versionInfo); if ($this->logger) { $this->logger->info(sprintf('Published new version of %s', $object->getProperty('name')), array('ContentManager::update')); } $object->setProperty('id', $content->contentInfo->id); $object->setProperty('version_info', $content->versionInfo); $object->setProperty('content_info', $content->contentInfo); // Add/Update/Delete parent locations $this->locationManager->syncronizeLocationsFromContentObject($object); return $object; }
php
public function update(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } $this->ensureDefaults($object); $existingContent = $this->find($object); if (null === $object->getProperty('content_info')) { $object->setProperty('content_info', $existingContent->contentInfo); } $contentDraft = $this->contentService->createContentDraft($object->getProperty('content_info')); $contentUpdateStruct = $this->contentService->newContentUpdateStruct(); $object->getMapper()->mapObjectToUpdateStruct($contentUpdateStruct); $contentDraft = $this->contentService->updateContent($contentDraft->versionInfo, $contentUpdateStruct); $content = $this->contentService->publishVersion($contentDraft->versionInfo); if ($this->logger) { $this->logger->info(sprintf('Published new version of %s', $object->getProperty('name')), array('ContentManager::update')); } $object->setProperty('id', $content->contentInfo->id); $object->setProperty('version_info', $content->versionInfo); $object->setProperty('content_info', $content->contentInfo); // Add/Update/Delete parent locations $this->locationManager->syncronizeLocationsFromContentObject($object); return $object; }
[ "public", "function", "update", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "ContentObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "ContentObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "ensureDefaults", "(", "$", "object", ")", ";", "$", "existingContent", "=", "$", "this", "->", "find", "(", "$", "object", ")", ";", "if", "(", "null", "===", "$", "object", "->", "getProperty", "(", "'content_info'", ")", ")", "{", "$", "object", "->", "setProperty", "(", "'content_info'", ",", "$", "existingContent", "->", "contentInfo", ")", ";", "}", "$", "contentDraft", "=", "$", "this", "->", "contentService", "->", "createContentDraft", "(", "$", "object", "->", "getProperty", "(", "'content_info'", ")", ")", ";", "$", "contentUpdateStruct", "=", "$", "this", "->", "contentService", "->", "newContentUpdateStruct", "(", ")", ";", "$", "object", "->", "getMapper", "(", ")", "->", "mapObjectToUpdateStruct", "(", "$", "contentUpdateStruct", ")", ";", "$", "contentDraft", "=", "$", "this", "->", "contentService", "->", "updateContent", "(", "$", "contentDraft", "->", "versionInfo", ",", "$", "contentUpdateStruct", ")", ";", "$", "content", "=", "$", "this", "->", "contentService", "->", "publishVersion", "(", "$", "contentDraft", "->", "versionInfo", ")", ";", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'Published new version of %s'", ",", "$", "object", "->", "getProperty", "(", "'name'", ")", ")", ",", "array", "(", "'ContentManager::update'", ")", ")", ";", "}", "$", "object", "->", "setProperty", "(", "'id'", ",", "$", "content", "->", "contentInfo", "->", "id", ")", ";", "$", "object", "->", "setProperty", "(", "'version_info'", ",", "$", "content", "->", "versionInfo", ")", ";", "$", "object", "->", "setProperty", "(", "'content_info'", ",", "$", "content", "->", "contentInfo", ")", ";", "// Add/Update/Delete parent locations", "$", "this", "->", "locationManager", "->", "syncronizeLocationsFromContentObject", "(", "$", "object", ")", ";", "return", "$", "object", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/ContentManager.php#L156-L189
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/ContentManager.php
ContentManager.remove
public function remove(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } try { $content = $this->find($object); $this->contentService->deleteContent($content->contentInfo); return true; } catch (NotFoundException $notFound) { return false; } }
php
public function remove(ObjectInterface $object) { if (!$object instanceof ContentObject) { throw new UnsupportedObjectOperationException(ContentObject::class, get_class($object)); } try { $content = $this->find($object); $this->contentService->deleteContent($content->contentInfo); return true; } catch (NotFoundException $notFound) { return false; } }
[ "public", "function", "remove", "(", "ObjectInterface", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "ContentObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "ContentObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "try", "{", "$", "content", "=", "$", "this", "->", "find", "(", "$", "object", ")", ";", "$", "this", "->", "contentService", "->", "deleteContent", "(", "$", "content", "->", "contentInfo", ")", ";", "return", "true", ";", "}", "catch", "(", "NotFoundException", "$", "notFound", ")", "{", "return", "false", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/ContentManager.php#L212-L226
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/ContentManager.php
ContentManager.ensureDefaults
private function ensureDefaults(ContentObject $object) { $defaultProperties = ['main_language_code']; foreach ($defaultProperties as $defaultOption) { if (!$object->getProperty($defaultOption)) { $object->setProperty($defaultOption, $this->options[$defaultOption]); } } }
php
private function ensureDefaults(ContentObject $object) { $defaultProperties = ['main_language_code']; foreach ($defaultProperties as $defaultOption) { if (!$object->getProperty($defaultOption)) { $object->setProperty($defaultOption, $this->options[$defaultOption]); } } }
[ "private", "function", "ensureDefaults", "(", "ContentObject", "$", "object", ")", "{", "$", "defaultProperties", "=", "[", "'main_language_code'", "]", ";", "foreach", "(", "$", "defaultProperties", "as", "$", "defaultOption", ")", "{", "if", "(", "!", "$", "object", "->", "getProperty", "(", "$", "defaultOption", ")", ")", "{", "$", "object", "->", "setProperty", "(", "$", "defaultOption", ",", "$", "this", "->", "options", "[", "$", "defaultOption", "]", ")", ";", "}", "}", "}" ]
@param ContentObject $object @return ContentObject
[ "@param", "ContentObject", "$object" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/ContentManager.php#L233-L242
ClanCats/Core
src/classes/CCDate.php
CCDate.relative
public static function relative($ts) { if(!ctype_digit($ts)) $ts = strtotime($ts); $diff = time() - $ts; if($diff == 0) return __('Core::common.date.now'); elseif($diff > 0) { $day_diff = floor($diff / 86400); if($day_diff == 0) { if($diff < 60) return __('Core::common.date.just_now'); if($diff < 120) return __('Core::common.date.minute_ago'); if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) ); if($diff < 7200) return __('Core::common.date.hour_ago'); if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) ); } if($day_diff == 1) return __('Core::common.date.yesterday'); if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) ); if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) ); if($day_diff < 60) return __('Core::common.date.last_month'); return date('F Y', $ts); } else { $diff = abs($diff); $day_diff = floor($diff / 86400); if($day_diff == 0) { if($diff < 120) return __('Core::common.date.in_minute'); if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) ); if($diff < 7200) return __('Core::common.date.in_hour'); if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) ); } if($day_diff == 1) return __('Core::common.date.tomorrow'); if($day_diff < 4) return date('l', $ts); if($day_diff < 7 + (7 - date('w'))) return 'next week'; if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks'; if(date('n', $ts) == date('n') + 1) return 'next month'; return date('F Y', $ts); } }
php
public static function relative($ts) { if(!ctype_digit($ts)) $ts = strtotime($ts); $diff = time() - $ts; if($diff == 0) return __('Core::common.date.now'); elseif($diff > 0) { $day_diff = floor($diff / 86400); if($day_diff == 0) { if($diff < 60) return __('Core::common.date.just_now'); if($diff < 120) return __('Core::common.date.minute_ago'); if($diff < 3600) return __('Core::common.date.minutes_ago', array( 'num' => floor($diff / 60) ) ); if($diff < 7200) return __('Core::common.date.hour_ago'); if($diff < 86400) return __('Core::common.date.hours_ago', array( 'num' => floor($diff / 3600) ) ); } if($day_diff == 1) return __('Core::common.date.yesterday'); if($day_diff < 7) return __('Core::common.date.days_ago', array( 'num' => $day_diff ) ); if($day_diff < 31) return __('Core::common.date.weeks_ago', array( 'num' => ceil($day_diff / 7) ) ); if($day_diff < 60) return __('Core::common.date.last_month'); return date('F Y', $ts); } else { $diff = abs($diff); $day_diff = floor($diff / 86400); if($day_diff == 0) { if($diff < 120) return __('Core::common.date.in_minute'); if($diff < 3600) return __('Core::common.date.in_minutes', array( 'num' => floor($diff / 60) ) ); if($diff < 7200) return __('Core::common.date.in_hour'); if($diff < 86400) return __('Core::common.date.in_hours', array( 'num' => floor($diff / 3600) ) ); } if($day_diff == 1) return __('Core::common.date.tomorrow'); if($day_diff < 4) return date('l', $ts); if($day_diff < 7 + (7 - date('w'))) return 'next week'; if(ceil($day_diff / 7) < 4) return 'in ' . ceil($day_diff / 7) . ' weeks'; if(date('n', $ts) == date('n') + 1) return 'next month'; return date('F Y', $ts); } }
[ "public", "static", "function", "relative", "(", "$", "ts", ")", "{", "if", "(", "!", "ctype_digit", "(", "$", "ts", ")", ")", "$", "ts", "=", "strtotime", "(", "$", "ts", ")", ";", "$", "diff", "=", "time", "(", ")", "-", "$", "ts", ";", "if", "(", "$", "diff", "==", "0", ")", "return", "__", "(", "'Core::common.date.now'", ")", ";", "elseif", "(", "$", "diff", ">", "0", ")", "{", "$", "day_diff", "=", "floor", "(", "$", "diff", "/", "86400", ")", ";", "if", "(", "$", "day_diff", "==", "0", ")", "{", "if", "(", "$", "diff", "<", "60", ")", "return", "__", "(", "'Core::common.date.just_now'", ")", ";", "if", "(", "$", "diff", "<", "120", ")", "return", "__", "(", "'Core::common.date.minute_ago'", ")", ";", "if", "(", "$", "diff", "<", "3600", ")", "return", "__", "(", "'Core::common.date.minutes_ago'", ",", "array", "(", "'num'", "=>", "floor", "(", "$", "diff", "/", "60", ")", ")", ")", ";", "if", "(", "$", "diff", "<", "7200", ")", "return", "__", "(", "'Core::common.date.hour_ago'", ")", ";", "if", "(", "$", "diff", "<", "86400", ")", "return", "__", "(", "'Core::common.date.hours_ago'", ",", "array", "(", "'num'", "=>", "floor", "(", "$", "diff", "/", "3600", ")", ")", ")", ";", "}", "if", "(", "$", "day_diff", "==", "1", ")", "return", "__", "(", "'Core::common.date.yesterday'", ")", ";", "if", "(", "$", "day_diff", "<", "7", ")", "return", "__", "(", "'Core::common.date.days_ago'", ",", "array", "(", "'num'", "=>", "$", "day_diff", ")", ")", ";", "if", "(", "$", "day_diff", "<", "31", ")", "return", "__", "(", "'Core::common.date.weeks_ago'", ",", "array", "(", "'num'", "=>", "ceil", "(", "$", "day_diff", "/", "7", ")", ")", ")", ";", "if", "(", "$", "day_diff", "<", "60", ")", "return", "__", "(", "'Core::common.date.last_month'", ")", ";", "return", "date", "(", "'F Y'", ",", "$", "ts", ")", ";", "}", "else", "{", "$", "diff", "=", "abs", "(", "$", "diff", ")", ";", "$", "day_diff", "=", "floor", "(", "$", "diff", "/", "86400", ")", ";", "if", "(", "$", "day_diff", "==", "0", ")", "{", "if", "(", "$", "diff", "<", "120", ")", "return", "__", "(", "'Core::common.date.in_minute'", ")", ";", "if", "(", "$", "diff", "<", "3600", ")", "return", "__", "(", "'Core::common.date.in_minutes'", ",", "array", "(", "'num'", "=>", "floor", "(", "$", "diff", "/", "60", ")", ")", ")", ";", "if", "(", "$", "diff", "<", "7200", ")", "return", "__", "(", "'Core::common.date.in_hour'", ")", ";", "if", "(", "$", "diff", "<", "86400", ")", "return", "__", "(", "'Core::common.date.in_hours'", ",", "array", "(", "'num'", "=>", "floor", "(", "$", "diff", "/", "3600", ")", ")", ")", ";", "}", "if", "(", "$", "day_diff", "==", "1", ")", "return", "__", "(", "'Core::common.date.tomorrow'", ")", ";", "if", "(", "$", "day_diff", "<", "4", ")", "return", "date", "(", "'l'", ",", "$", "ts", ")", ";", "if", "(", "$", "day_diff", "<", "7", "+", "(", "7", "-", "date", "(", "'w'", ")", ")", ")", "return", "'next week'", ";", "if", "(", "ceil", "(", "$", "day_diff", "/", "7", ")", "<", "4", ")", "return", "'in '", ".", "ceil", "(", "$", "day_diff", "/", "7", ")", ".", "' weeks'", ";", "if", "(", "date", "(", "'n'", ",", "$", "ts", ")", "==", "date", "(", "'n'", ")", "+", "1", ")", "return", "'next month'", ";", "return", "date", "(", "'F Y'", ",", "$", "ts", ")", ";", "}", "}" ]
to string relative string @param int $ts @return string
[ "to", "string", "relative", "string" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCDate.php#L100-L143
ppetermann/king23
src/TwigIntegration/TwigController.php
TwigController.render
protected function render($template, $context = []) { $context = array_merge($this->_context, $context); $body = $this->twig->render($template, $context); return $body; }
php
protected function render($template, $context = []) { $context = array_merge($this->_context, $context); $body = $this->twig->render($template, $context); return $body; }
[ "protected", "function", "render", "(", "$", "template", ",", "$", "context", "=", "[", "]", ")", "{", "$", "context", "=", "array_merge", "(", "$", "this", "->", "_context", ",", "$", "context", ")", ";", "$", "body", "=", "$", "this", "->", "twig", "->", "render", "(", "$", "template", ",", "$", "context", ")", ";", "return", "$", "body", ";", "}" ]
render template with context, will merge context with allready known context @param string $template @param array $context @return string
[ "render", "template", "with", "context", "will", "merge", "context", "with", "allready", "known", "context" ]
train
https://github.com/ppetermann/king23/blob/603896083ec89f5ac4d744abd3b1b4db3e914c95/src/TwigIntegration/TwigController.php#L95-L100
iocaste/microservice-foundation
src/Seeder/Seeder.php
Seeder.truncateTables
public function truncateTables() { $dbName = env('DB_DATABASE'); // Get all tables list, except migrations table $tables = DB::select('SHOW TABLES WHERE `Tables_in_'.$dbName.'` != ?', ['migrations']); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); foreach ($tables as $table) { DB::table($table->{'Tables_in_' . $dbName})->truncate(); } DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }
php
public function truncateTables() { $dbName = env('DB_DATABASE'); // Get all tables list, except migrations table $tables = DB::select('SHOW TABLES WHERE `Tables_in_'.$dbName.'` != ?', ['migrations']); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); foreach ($tables as $table) { DB::table($table->{'Tables_in_' . $dbName})->truncate(); } DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }
[ "public", "function", "truncateTables", "(", ")", "{", "$", "dbName", "=", "env", "(", "'DB_DATABASE'", ")", ";", "// Get all tables list, except migrations table", "$", "tables", "=", "DB", "::", "select", "(", "'SHOW TABLES WHERE `Tables_in_'", ".", "$", "dbName", ".", "'` != ?'", ",", "[", "'migrations'", "]", ")", ";", "DB", "::", "statement", "(", "'SET FOREIGN_KEY_CHECKS=0;'", ")", ";", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "DB", "::", "table", "(", "$", "table", "->", "{", "'Tables_in_'", ".", "$", "dbName", "}", ")", "->", "truncate", "(", ")", ";", "}", "DB", "::", "statement", "(", "'SET FOREIGN_KEY_CHECKS=1;'", ")", ";", "}" ]
Truncates all tables except migrations.
[ "Truncates", "all", "tables", "except", "migrations", "." ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Seeder/Seeder.php#L16-L28
joomlatools/joomlatools-platform-legacy
code/form/field/componentlayout.php
JFormFieldComponentlayout.getInput
protected function getInput() { // Get the client id. $clientId = $this->element['client_id']; if (is_null($clientId) && $this->form instanceof JForm) { $clientId = $this->form->getValue('client_id'); } $clientId = (int) $clientId; $client = JApplicationHelper::getClientInfo($clientId); // Get the extension. $extension = (string) $this->element['extension']; if (empty($extension) && ($this->form instanceof JForm)) { $extension = $this->form->getValue('extension'); } $extension = preg_replace('#\W#', '', $extension); $template = (string) $this->element['template']; $template = preg_replace('#\W#', '', $template); $template_style_id = ''; if ($this->form instanceof JForm) { $template_style_id = $this->form->getValue('template_style_id'); $template_style_id = preg_replace('#\W#', '', $template_style_id); } $view = (string) $this->element['view']; $view = preg_replace('#\W#', '', $view); // If a template, extension and view are present build the options. if ($extension && $view && $client) { // Load language file $lang = JFactory::getLanguage(); $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extension, null, false, true); // Get the database object and a new query object. $db = JFactory::getDbo(); $query = $db->getQuery(true); // Build the query. $query->select('e.element, e.name') ->from('#__extensions as e') ->where('e.client_id = ' . (int) $clientId) ->where('e.type = ' . $db->quote('template')) ->where('e.enabled = 1'); if ($template) { $query->where('e.element = ' . $db->quote($template)); } if ($template_style_id) { $query->join('LEFT', '#__templates as s on s.template=e.element') ->where('s.id=' . (int) $template_style_id); } // Set the query and load the templates. $db->setQuery($query); $templates = $db->loadObjectList('element'); // Build the search paths for component layouts. $component_path = JPath::clean($client->path . '/components/' . $extension . '/views/' . $view . '/tmpl'); // Prepare array of component layouts $component_layouts = array(); // Prepare the grouped list $groups = array(); // Add a Use Global option if useglobal="true" in XML file if ($this->element['useglobal'] == 'true') { $groups[JText::_('JOPTION_FROM_STANDARD')]['items'][] = JHtml::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL')); } // Add the layout options from the component path. if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\.xml$', false, true))) { // Create the group for the component $groups['_'] = array(); $groups['_']['id'] = $this->id . '__'; $groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT'); $groups['_']['items'] = array(); foreach ($component_layouts as $i => $file) { // Attempt to load the XML file. if (!$xml = simplexml_load_file($file)) { unset($component_layouts[$i]); continue; } // Get the help data from the XML file if present. if (!$menu = $xml->xpath('layout[1]')) { unset($component_layouts[$i]); continue; } $menu = $menu[0]; // Add an option to the component group $value = basename($file, '.xml'); $component_layouts[$i] = $value; $text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value); $groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text); } } // Loop on all templates if ($templates) { foreach ($templates as $template) { // Load language file $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true); $template_path = JPath::clean( $client->path . '/templates/' . $template->element . '/html/' . $extension . '/' . $view ); // Add the layout options from the template path. if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\.php$', false, true))) { // Files with corresponding XML files are alternate menu items, not alternate layout files // so we need to exclude these files from the list. $xml_files = JFolder::files($template_path, '^[^_]*\.xml$', false, true); for ($j = 0, $count = count($xml_files); $j < $count; $j++) { $xml_files[$j] = basename($xml_files[$j], '.xml'); } foreach ($files as $i => $file) { // Remove layout files that exist in the component folder or that have XML files if ((in_array(basename($file, '.php'), $component_layouts)) || (in_array(basename($file, '.php'), $xml_files))) { unset($files[$i]); } } if (count($files)) { // Create the group for the template $groups[$template->name] = array(); $groups[$template->name]['id'] = $this->id . '_' . $template->element; $groups[$template->name]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name); $groups[$template->name]['items'] = array(); foreach ($files as $file) { // Add an option to the template group $value = basename($file, '.php'); $text = $lang ->hasKey( $key = strtoupper( 'TPL_' . $template->name . '_' . $extension . '_' . $view . '_LAYOUT_' . $value ) ) ? JText::_($key) : $value; $groups[$template->name]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text); } } } } } // Compute attributes for the grouped list $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // Prepare HTML code $html = array(); // Compute the current selected values $selected = array($this->value); // Add a grouped list $html[] = JHtml::_( 'select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected) ); return implode($html); } else { return ''; } }
php
protected function getInput() { // Get the client id. $clientId = $this->element['client_id']; if (is_null($clientId) && $this->form instanceof JForm) { $clientId = $this->form->getValue('client_id'); } $clientId = (int) $clientId; $client = JApplicationHelper::getClientInfo($clientId); // Get the extension. $extension = (string) $this->element['extension']; if (empty($extension) && ($this->form instanceof JForm)) { $extension = $this->form->getValue('extension'); } $extension = preg_replace('#\W#', '', $extension); $template = (string) $this->element['template']; $template = preg_replace('#\W#', '', $template); $template_style_id = ''; if ($this->form instanceof JForm) { $template_style_id = $this->form->getValue('template_style_id'); $template_style_id = preg_replace('#\W#', '', $template_style_id); } $view = (string) $this->element['view']; $view = preg_replace('#\W#', '', $view); // If a template, extension and view are present build the options. if ($extension && $view && $client) { // Load language file $lang = JFactory::getLanguage(); $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR . '/components/' . $extension, null, false, true); // Get the database object and a new query object. $db = JFactory::getDbo(); $query = $db->getQuery(true); // Build the query. $query->select('e.element, e.name') ->from('#__extensions as e') ->where('e.client_id = ' . (int) $clientId) ->where('e.type = ' . $db->quote('template')) ->where('e.enabled = 1'); if ($template) { $query->where('e.element = ' . $db->quote($template)); } if ($template_style_id) { $query->join('LEFT', '#__templates as s on s.template=e.element') ->where('s.id=' . (int) $template_style_id); } // Set the query and load the templates. $db->setQuery($query); $templates = $db->loadObjectList('element'); // Build the search paths for component layouts. $component_path = JPath::clean($client->path . '/components/' . $extension . '/views/' . $view . '/tmpl'); // Prepare array of component layouts $component_layouts = array(); // Prepare the grouped list $groups = array(); // Add a Use Global option if useglobal="true" in XML file if ($this->element['useglobal'] == 'true') { $groups[JText::_('JOPTION_FROM_STANDARD')]['items'][] = JHtml::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL')); } // Add the layout options from the component path. if (is_dir($component_path) && ($component_layouts = JFolder::files($component_path, '^[^_]*\.xml$', false, true))) { // Create the group for the component $groups['_'] = array(); $groups['_']['id'] = $this->id . '__'; $groups['_']['text'] = JText::sprintf('JOPTION_FROM_COMPONENT'); $groups['_']['items'] = array(); foreach ($component_layouts as $i => $file) { // Attempt to load the XML file. if (!$xml = simplexml_load_file($file)) { unset($component_layouts[$i]); continue; } // Get the help data from the XML file if present. if (!$menu = $xml->xpath('layout[1]')) { unset($component_layouts[$i]); continue; } $menu = $menu[0]; // Add an option to the component group $value = basename($file, '.xml'); $component_layouts[$i] = $value; $text = isset($menu['option']) ? JText::_($menu['option']) : (isset($menu['title']) ? JText::_($menu['title']) : $value); $groups['_']['items'][] = JHtml::_('select.option', '_:' . $value, $text); } } // Loop on all templates if ($templates) { foreach ($templates as $template) { // Load language file $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, true); $template_path = JPath::clean( $client->path . '/templates/' . $template->element . '/html/' . $extension . '/' . $view ); // Add the layout options from the template path. if (is_dir($template_path) && ($files = JFolder::files($template_path, '^[^_]*\.php$', false, true))) { // Files with corresponding XML files are alternate menu items, not alternate layout files // so we need to exclude these files from the list. $xml_files = JFolder::files($template_path, '^[^_]*\.xml$', false, true); for ($j = 0, $count = count($xml_files); $j < $count; $j++) { $xml_files[$j] = basename($xml_files[$j], '.xml'); } foreach ($files as $i => $file) { // Remove layout files that exist in the component folder or that have XML files if ((in_array(basename($file, '.php'), $component_layouts)) || (in_array(basename($file, '.php'), $xml_files))) { unset($files[$i]); } } if (count($files)) { // Create the group for the template $groups[$template->name] = array(); $groups[$template->name]['id'] = $this->id . '_' . $template->element; $groups[$template->name]['text'] = JText::sprintf('JOPTION_FROM_TEMPLATE', $template->name); $groups[$template->name]['items'] = array(); foreach ($files as $file) { // Add an option to the template group $value = basename($file, '.php'); $text = $lang ->hasKey( $key = strtoupper( 'TPL_' . $template->name . '_' . $extension . '_' . $view . '_LAYOUT_' . $value ) ) ? JText::_($key) : $value; $groups[$template->name]['items'][] = JHtml::_('select.option', $template->element . ':' . $value, $text); } } } } } // Compute attributes for the grouped list $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; // Prepare HTML code $html = array(); // Compute the current selected values $selected = array($this->value); // Add a grouped list $html[] = JHtml::_( 'select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected) ); return implode($html); } else { return ''; } }
[ "protected", "function", "getInput", "(", ")", "{", "// Get the client id.", "$", "clientId", "=", "$", "this", "->", "element", "[", "'client_id'", "]", ";", "if", "(", "is_null", "(", "$", "clientId", ")", "&&", "$", "this", "->", "form", "instanceof", "JForm", ")", "{", "$", "clientId", "=", "$", "this", "->", "form", "->", "getValue", "(", "'client_id'", ")", ";", "}", "$", "clientId", "=", "(", "int", ")", "$", "clientId", ";", "$", "client", "=", "JApplicationHelper", "::", "getClientInfo", "(", "$", "clientId", ")", ";", "// Get the extension.", "$", "extension", "=", "(", "string", ")", "$", "this", "->", "element", "[", "'extension'", "]", ";", "if", "(", "empty", "(", "$", "extension", ")", "&&", "(", "$", "this", "->", "form", "instanceof", "JForm", ")", ")", "{", "$", "extension", "=", "$", "this", "->", "form", "->", "getValue", "(", "'extension'", ")", ";", "}", "$", "extension", "=", "preg_replace", "(", "'#\\W#'", ",", "''", ",", "$", "extension", ")", ";", "$", "template", "=", "(", "string", ")", "$", "this", "->", "element", "[", "'template'", "]", ";", "$", "template", "=", "preg_replace", "(", "'#\\W#'", ",", "''", ",", "$", "template", ")", ";", "$", "template_style_id", "=", "''", ";", "if", "(", "$", "this", "->", "form", "instanceof", "JForm", ")", "{", "$", "template_style_id", "=", "$", "this", "->", "form", "->", "getValue", "(", "'template_style_id'", ")", ";", "$", "template_style_id", "=", "preg_replace", "(", "'#\\W#'", ",", "''", ",", "$", "template_style_id", ")", ";", "}", "$", "view", "=", "(", "string", ")", "$", "this", "->", "element", "[", "'view'", "]", ";", "$", "view", "=", "preg_replace", "(", "'#\\W#'", ",", "''", ",", "$", "view", ")", ";", "// If a template, extension and view are present build the options.", "if", "(", "$", "extension", "&&", "$", "view", "&&", "$", "client", ")", "{", "// Load language file", "$", "lang", "=", "JFactory", "::", "getLanguage", "(", ")", ";", "$", "lang", "->", "load", "(", "$", "extension", ".", "'.sys'", ",", "JPATH_ADMINISTRATOR", ",", "null", ",", "false", ",", "true", ")", "||", "$", "lang", "->", "load", "(", "$", "extension", ".", "'.sys'", ",", "JPATH_ADMINISTRATOR", ".", "'/components/'", ".", "$", "extension", ",", "null", ",", "false", ",", "true", ")", ";", "// Get the database object and a new query object.", "$", "db", "=", "JFactory", "::", "getDbo", "(", ")", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", ";", "// Build the query.", "$", "query", "->", "select", "(", "'e.element, e.name'", ")", "->", "from", "(", "'#__extensions as e'", ")", "->", "where", "(", "'e.client_id = '", ".", "(", "int", ")", "$", "clientId", ")", "->", "where", "(", "'e.type = '", ".", "$", "db", "->", "quote", "(", "'template'", ")", ")", "->", "where", "(", "'e.enabled = 1'", ")", ";", "if", "(", "$", "template", ")", "{", "$", "query", "->", "where", "(", "'e.element = '", ".", "$", "db", "->", "quote", "(", "$", "template", ")", ")", ";", "}", "if", "(", "$", "template_style_id", ")", "{", "$", "query", "->", "join", "(", "'LEFT'", ",", "'#__templates as s on s.template=e.element'", ")", "->", "where", "(", "'s.id='", ".", "(", "int", ")", "$", "template_style_id", ")", ";", "}", "// Set the query and load the templates.", "$", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "templates", "=", "$", "db", "->", "loadObjectList", "(", "'element'", ")", ";", "// Build the search paths for component layouts.", "$", "component_path", "=", "JPath", "::", "clean", "(", "$", "client", "->", "path", ".", "'/components/'", ".", "$", "extension", ".", "'/views/'", ".", "$", "view", ".", "'/tmpl'", ")", ";", "// Prepare array of component layouts", "$", "component_layouts", "=", "array", "(", ")", ";", "// Prepare the grouped list", "$", "groups", "=", "array", "(", ")", ";", "// Add a Use Global option if useglobal=\"true\" in XML file", "if", "(", "$", "this", "->", "element", "[", "'useglobal'", "]", "==", "'true'", ")", "{", "$", "groups", "[", "JText", "::", "_", "(", "'JOPTION_FROM_STANDARD'", ")", "]", "[", "'items'", "]", "[", "]", "=", "JHtml", "::", "_", "(", "'select.option'", ",", "''", ",", "JText", "::", "_", "(", "'JGLOBAL_USE_GLOBAL'", ")", ")", ";", "}", "// Add the layout options from the component path.", "if", "(", "is_dir", "(", "$", "component_path", ")", "&&", "(", "$", "component_layouts", "=", "JFolder", "::", "files", "(", "$", "component_path", ",", "'^[^_]*\\.xml$'", ",", "false", ",", "true", ")", ")", ")", "{", "// Create the group for the component", "$", "groups", "[", "'_'", "]", "=", "array", "(", ")", ";", "$", "groups", "[", "'_'", "]", "[", "'id'", "]", "=", "$", "this", "->", "id", ".", "'__'", ";", "$", "groups", "[", "'_'", "]", "[", "'text'", "]", "=", "JText", "::", "sprintf", "(", "'JOPTION_FROM_COMPONENT'", ")", ";", "$", "groups", "[", "'_'", "]", "[", "'items'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "component_layouts", "as", "$", "i", "=>", "$", "file", ")", "{", "// Attempt to load the XML file.", "if", "(", "!", "$", "xml", "=", "simplexml_load_file", "(", "$", "file", ")", ")", "{", "unset", "(", "$", "component_layouts", "[", "$", "i", "]", ")", ";", "continue", ";", "}", "// Get the help data from the XML file if present.", "if", "(", "!", "$", "menu", "=", "$", "xml", "->", "xpath", "(", "'layout[1]'", ")", ")", "{", "unset", "(", "$", "component_layouts", "[", "$", "i", "]", ")", ";", "continue", ";", "}", "$", "menu", "=", "$", "menu", "[", "0", "]", ";", "// Add an option to the component group", "$", "value", "=", "basename", "(", "$", "file", ",", "'.xml'", ")", ";", "$", "component_layouts", "[", "$", "i", "]", "=", "$", "value", ";", "$", "text", "=", "isset", "(", "$", "menu", "[", "'option'", "]", ")", "?", "JText", "::", "_", "(", "$", "menu", "[", "'option'", "]", ")", ":", "(", "isset", "(", "$", "menu", "[", "'title'", "]", ")", "?", "JText", "::", "_", "(", "$", "menu", "[", "'title'", "]", ")", ":", "$", "value", ")", ";", "$", "groups", "[", "'_'", "]", "[", "'items'", "]", "[", "]", "=", "JHtml", "::", "_", "(", "'select.option'", ",", "'_:'", ".", "$", "value", ",", "$", "text", ")", ";", "}", "}", "// Loop on all templates", "if", "(", "$", "templates", ")", "{", "foreach", "(", "$", "templates", "as", "$", "template", ")", "{", "// Load language file", "$", "lang", "->", "load", "(", "'tpl_'", ".", "$", "template", "->", "element", ".", "'.sys'", ",", "$", "client", "->", "path", ",", "null", ",", "false", ",", "true", ")", "||", "$", "lang", "->", "load", "(", "'tpl_'", ".", "$", "template", "->", "element", ".", "'.sys'", ",", "$", "client", "->", "path", ".", "'/templates/'", ".", "$", "template", "->", "element", ",", "null", ",", "false", ",", "true", ")", ";", "$", "template_path", "=", "JPath", "::", "clean", "(", "$", "client", "->", "path", ".", "'/templates/'", ".", "$", "template", "->", "element", ".", "'/html/'", ".", "$", "extension", ".", "'/'", ".", "$", "view", ")", ";", "// Add the layout options from the template path.", "if", "(", "is_dir", "(", "$", "template_path", ")", "&&", "(", "$", "files", "=", "JFolder", "::", "files", "(", "$", "template_path", ",", "'^[^_]*\\.php$'", ",", "false", ",", "true", ")", ")", ")", "{", "// Files with corresponding XML files are alternate menu items, not alternate layout files", "// so we need to exclude these files from the list.", "$", "xml_files", "=", "JFolder", "::", "files", "(", "$", "template_path", ",", "'^[^_]*\\.xml$'", ",", "false", ",", "true", ")", ";", "for", "(", "$", "j", "=", "0", ",", "$", "count", "=", "count", "(", "$", "xml_files", ")", ";", "$", "j", "<", "$", "count", ";", "$", "j", "++", ")", "{", "$", "xml_files", "[", "$", "j", "]", "=", "basename", "(", "$", "xml_files", "[", "$", "j", "]", ",", "'.xml'", ")", ";", "}", "foreach", "(", "$", "files", "as", "$", "i", "=>", "$", "file", ")", "{", "// Remove layout files that exist in the component folder or that have XML files", "if", "(", "(", "in_array", "(", "basename", "(", "$", "file", ",", "'.php'", ")", ",", "$", "component_layouts", ")", ")", "||", "(", "in_array", "(", "basename", "(", "$", "file", ",", "'.php'", ")", ",", "$", "xml_files", ")", ")", ")", "{", "unset", "(", "$", "files", "[", "$", "i", "]", ")", ";", "}", "}", "if", "(", "count", "(", "$", "files", ")", ")", "{", "// Create the group for the template", "$", "groups", "[", "$", "template", "->", "name", "]", "=", "array", "(", ")", ";", "$", "groups", "[", "$", "template", "->", "name", "]", "[", "'id'", "]", "=", "$", "this", "->", "id", ".", "'_'", ".", "$", "template", "->", "element", ";", "$", "groups", "[", "$", "template", "->", "name", "]", "[", "'text'", "]", "=", "JText", "::", "sprintf", "(", "'JOPTION_FROM_TEMPLATE'", ",", "$", "template", "->", "name", ")", ";", "$", "groups", "[", "$", "template", "->", "name", "]", "[", "'items'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "// Add an option to the template group", "$", "value", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "$", "text", "=", "$", "lang", "->", "hasKey", "(", "$", "key", "=", "strtoupper", "(", "'TPL_'", ".", "$", "template", "->", "name", ".", "'_'", ".", "$", "extension", ".", "'_'", ".", "$", "view", ".", "'_LAYOUT_'", ".", "$", "value", ")", ")", "?", "JText", "::", "_", "(", "$", "key", ")", ":", "$", "value", ";", "$", "groups", "[", "$", "template", "->", "name", "]", "[", "'items'", "]", "[", "]", "=", "JHtml", "::", "_", "(", "'select.option'", ",", "$", "template", "->", "element", ".", "':'", ".", "$", "value", ",", "$", "text", ")", ";", "}", "}", "}", "}", "}", "// Compute attributes for the grouped list", "$", "attr", "=", "$", "this", "->", "element", "[", "'size'", "]", "?", "' size=\"'", ".", "(", "int", ")", "$", "this", "->", "element", "[", "'size'", "]", ".", "'\"'", ":", "''", ";", "$", "attr", ".=", "$", "this", "->", "element", "[", "'class'", "]", "?", "' class=\"'", ".", "(", "string", ")", "$", "this", "->", "element", "[", "'class'", "]", ".", "'\"'", ":", "''", ";", "// Prepare HTML code", "$", "html", "=", "array", "(", ")", ";", "// Compute the current selected values", "$", "selected", "=", "array", "(", "$", "this", "->", "value", ")", ";", "// Add a grouped list", "$", "html", "[", "]", "=", "JHtml", "::", "_", "(", "'select.groupedlist'", ",", "$", "groups", ",", "$", "this", "->", "name", ",", "array", "(", "'id'", "=>", "$", "this", "->", "id", ",", "'group.id'", "=>", "'id'", ",", "'list.attr'", "=>", "$", "attr", ",", "'list.select'", "=>", "$", "selected", ")", ")", ";", "return", "implode", "(", "$", "html", ")", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Method to get the field input for a component layout field. @return string The field input. @since 11.1
[ "Method", "to", "get", "the", "field", "input", "for", "a", "component", "layout", "field", "." ]
train
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/form/field/componentlayout.php#L37-L256
PeekAndPoke/psi
src/Operation/FullSet/UserSortOperation.php
UserSortOperation.apply
public function apply(\Iterator $set) { $data = iterator_to_array($set); usort($data, $this->function); return new \ArrayIterator($data); }
php
public function apply(\Iterator $set) { $data = iterator_to_array($set); usort($data, $this->function); return new \ArrayIterator($data); }
[ "public", "function", "apply", "(", "\\", "Iterator", "$", "set", ")", "{", "$", "data", "=", "iterator_to_array", "(", "$", "set", ")", ";", "usort", "(", "$", "data", ",", "$", "this", "->", "function", ")", ";", "return", "new", "\\", "ArrayIterator", "(", "$", "data", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Operation/FullSet/UserSortOperation.php#L23-L30
CakeCMS/Core
src/View/Form/EntityContext.php
EntityContext.val
public function val($field, $options = []) { $val = parent::val($field, $options); if ($val === null) { $parts = explode('.', $field); $entity = $this->entity($parts); if ($entity instanceof Data) { $key = array_pop($parts); $val = $entity->get($key); } } return $val; }
php
public function val($field, $options = []) { $val = parent::val($field, $options); if ($val === null) { $parts = explode('.', $field); $entity = $this->entity($parts); if ($entity instanceof Data) { $key = array_pop($parts); $val = $entity->get($key); } } return $val; }
[ "public", "function", "val", "(", "$", "field", ",", "$", "options", "=", "[", "]", ")", "{", "$", "val", "=", "parent", "::", "val", "(", "$", "field", ",", "$", "options", ")", ";", "if", "(", "$", "val", "===", "null", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "$", "entity", "=", "$", "this", "->", "entity", "(", "$", "parts", ")", ";", "if", "(", "$", "entity", "instanceof", "Data", ")", "{", "$", "key", "=", "array_pop", "(", "$", "parts", ")", ";", "$", "val", "=", "$", "entity", "->", "get", "(", "$", "key", ")", ";", "}", "}", "return", "$", "val", ";", "}" ]
Get the value for a given path. @param string $field @param array $options @return mixed
[ "Get", "the", "value", "for", "a", "given", "path", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Form/EntityContext.php#L36-L50
mremi/Flowdock
src/Mremi/Flowdock/Command/SendChatMessageCommand.php
SendChatMessageCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $push = new Push($input->getArgument('flow-api-token')); $message = ChatMessage::create() ->setContent($input->getArgument('content')) ->setExternalUserName($input->getArgument('external-user-name')) ->setTags($input->getOption('tags')) ->setMessageId($input->getOption('message-id')); $options = $input->getOption('options') ? json_decode($input->getOption('options'), true) : array(); if ($push->sendChatMessage($message, $options)) { $output->writeln('<info>Success:</info> the message has been sent'); return; } $output->writeln(sprintf('<error>Failure:</error> %s', $message->getResponseMessage())); $output->writeln(var_export($message->getResponseErrors(), true)); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $push = new Push($input->getArgument('flow-api-token')); $message = ChatMessage::create() ->setContent($input->getArgument('content')) ->setExternalUserName($input->getArgument('external-user-name')) ->setTags($input->getOption('tags')) ->setMessageId($input->getOption('message-id')); $options = $input->getOption('options') ? json_decode($input->getOption('options'), true) : array(); if ($push->sendChatMessage($message, $options)) { $output->writeln('<info>Success:</info> the message has been sent'); return; } $output->writeln(sprintf('<error>Failure:</error> %s', $message->getResponseMessage())); $output->writeln(var_export($message->getResponseErrors(), true)); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "push", "=", "new", "Push", "(", "$", "input", "->", "getArgument", "(", "'flow-api-token'", ")", ")", ";", "$", "message", "=", "ChatMessage", "::", "create", "(", ")", "->", "setContent", "(", "$", "input", "->", "getArgument", "(", "'content'", ")", ")", "->", "setExternalUserName", "(", "$", "input", "->", "getArgument", "(", "'external-user-name'", ")", ")", "->", "setTags", "(", "$", "input", "->", "getOption", "(", "'tags'", ")", ")", "->", "setMessageId", "(", "$", "input", "->", "getOption", "(", "'message-id'", ")", ")", ";", "$", "options", "=", "$", "input", "->", "getOption", "(", "'options'", ")", "?", "json_decode", "(", "$", "input", "->", "getOption", "(", "'options'", ")", ",", "true", ")", ":", "array", "(", ")", ";", "if", "(", "$", "push", "->", "sendChatMessage", "(", "$", "message", ",", "$", "options", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<info>Success:</info> the message has been sent'", ")", ";", "return", ";", "}", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<error>Failure:</error> %s'", ",", "$", "message", "->", "getResponseMessage", "(", ")", ")", ")", ";", "$", "output", "->", "writeln", "(", "var_export", "(", "$", "message", "->", "getResponseErrors", "(", ")", ",", "true", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/mremi/Flowdock/blob/287bfdcef17529055f803f2316e3ad31826e79eb/src/Mremi/Flowdock/Command/SendChatMessageCommand.php#L51-L71
VincentChalnot/SidusAdminBundle
DependencyInjection/SidusAdminExtension.php
SidusAdminExtension.load
public function load(array $configs, ContainerBuilder $container): void { $this->globalConfig = $this->processConfiguration($this->createConfiguration(), $configs); $container->setParameter( 'sidus_admin.templating.fallback_template_directory', $this->globalConfig['fallback_template_directory'] ); foreach ((array) $this->globalConfig['configurations'] as $code => $adminConfiguration) { $this->createAdminServiceDefinition($code, $adminConfiguration, $container); } parent::load($configs, $container); }
php
public function load(array $configs, ContainerBuilder $container): void { $this->globalConfig = $this->processConfiguration($this->createConfiguration(), $configs); $container->setParameter( 'sidus_admin.templating.fallback_template_directory', $this->globalConfig['fallback_template_directory'] ); foreach ((array) $this->globalConfig['configurations'] as $code => $adminConfiguration) { $this->createAdminServiceDefinition($code, $adminConfiguration, $container); } parent::load($configs, $container); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", ":", "void", "{", "$", "this", "->", "globalConfig", "=", "$", "this", "->", "processConfiguration", "(", "$", "this", "->", "createConfiguration", "(", ")", ",", "$", "configs", ")", ";", "$", "container", "->", "setParameter", "(", "'sidus_admin.templating.fallback_template_directory'", ",", "$", "this", "->", "globalConfig", "[", "'fallback_template_directory'", "]", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "globalConfig", "[", "'configurations'", "]", "as", "$", "code", "=>", "$", "adminConfiguration", ")", "{", "$", "this", "->", "createAdminServiceDefinition", "(", "$", "code", ",", "$", "adminConfiguration", ",", "$", "container", ")", ";", "}", "parent", "::", "load", "(", "$", "configs", ",", "$", "container", ")", ";", "}" ]
{@inheritdoc} @throws \Exception @throws BadMethodCallException
[ "{" ]
train
https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/DependencyInjection/SidusAdminExtension.php#L36-L50