id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
1,100
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.alpha
public function alpha($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHA, 'message' => $error]); } return $this; }
php
public function alpha($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHA, 'message' => $error]); } return $this; }
[ "public", "function", "alpha", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "ALPHA", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
the field must contains only letters @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "the", "field", "must", "contains", "only", "letters" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L771-L777
1,101
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.alphaNum
public function alphaNum($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHANUM, 'message' => $error]); } return $this; }
php
public function alphaNum($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHANUM, 'message' => $error]); } return $this; }
[ "public", "function", "alphaNum", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "ALPHANUM", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
the field must contain only letters and numerics @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "the", "field", "must", "contain", "only", "letters", "and", "numerics" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L788-L794
1,102
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.alphaDash
public function alphaDash($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHADASH, 'message' => $error]); } return $this; }
php
public function alphaDash($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::ALPHADASH, 'message' => $error]); } return $this; }
[ "public", "function", "alphaDash", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "ALPHADASH", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
the field must contain only letters, numerics ans underscore @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "the", "field", "must", "contain", "only", "letters", "numerics", "ans", "underscore" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L805-L811
1,103
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.ip
public function ip($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::IP, 'message' => $error]); } return $this; }
php
public function ip($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::IP, 'message' => $error]); } return $this; }
[ "public", "function", "ip", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "IP", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
the field must be an ip @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "the", "field", "must", "be", "an", "ip" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L822-L828
1,104
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.sql
public function sql($sql, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::SQL, 'value' => $sql, 'message' => $error]); } return $this; }
php
public function sql($sql, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::SQL, 'value' => $sql, 'message' => $error]); } return $this; }
[ "public", "function", "sql", "(", "$", "sql", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "SQL", ",", "'value'", "=>", "$", "sql", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
the field must valid the query @access public @param $sql string[] query => string vars => array (:value => field value directly added to vars) constraint => (>,<,==,!=) value => string @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "the", "field", "must", "valid", "the", "query" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L844-L850
1,105
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.count
public function count($count, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNT, 'value' => $count, 'message' => $error]); } return $this; }
php
public function count($count, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNT, 'value' => $count, 'message' => $error]); } return $this; }
[ "public", "function", "count", "(", "$", "count", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "COUNT", ",", "'value'", "=>", "$", "count", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
When the field value is an array, it must contain N lines @access public @param $count integer @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "When", "the", "field", "value", "is", "an", "array", "it", "must", "contain", "N", "lines" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L862-L868
1,106
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.countMin
public function countMin($countMin, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTIN, 'value' => $countMin, 'message' => $error]); } return $this; }
php
public function countMin($countMin, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTIN, 'value' => $countMin, 'message' => $error]); } return $this; }
[ "public", "function", "countMin", "(", "$", "countMin", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "COUNTIN", ",", "'value'", "=>", "$", "countMin", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
When the field value is an array, it must contain at least N lines @access public @param $countMin integer @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "When", "the", "field", "value", "is", "an", "array", "it", "must", "contain", "at", "least", "N", "lines" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L880-L886
1,107
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.countMax
public function countMax($countMax, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTMAX, 'value' => $countMax, 'message' => $error]); } return $this; }
php
public function countMax($countMax, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTMAX, 'value' => $countMax, 'message' => $error]); } return $this; }
[ "public", "function", "countMax", "(", "$", "countMax", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "COUNTMAX", ",", "'value'", "=>", "$", "countMax", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
When the field value is an array, it must contain less than N+1 lines @access public @param $countMax integer @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "When", "the", "field", "value", "is", "an", "array", "it", "must", "contain", "less", "than", "N", "+", "1", "lines" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L898-L904
1,108
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.countIn
public function countIn($countIn, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTIN, 'value' => $countIn, 'message' => $error]); } return $this; }
php
public function countIn($countIn, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTIN, 'value' => $countIn, 'message' => $error]); } return $this; }
[ "public", "function", "countIn", "(", "$", "countIn", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "COUNTIN", ",", "'value'", "=>", "$", "countIn", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
When the field value is an array, its value must be in @access public @param $countIn integer[] @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "When", "the", "field", "value", "is", "an", "array", "its", "value", "must", "be", "in" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L916-L922
1,109
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.countBetween
public function countBetween($countBetween, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTBETWEEN, 'value' => $countBetween, 'message' => $error]); } return $this; }
php
public function countBetween($countBetween, $error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::COUNTBETWEEN, 'value' => $countBetween, 'message' => $error]); } return $this; }
[ "public", "function", "countBetween", "(", "$", "countBetween", ",", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "COUNTBETWEEN", ",", "'value'", "=>", "$", "countBetween", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
When the field value is an array, its value must be between @access public @param $countBetween integer[] @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "When", "the", "field", "value", "is", "an", "array", "its", "value", "must", "be", "between" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L934-L940
1,110
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.exist
public function exist($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::EXIST, 'message' => $error]); } return $this; }
php
public function exist($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::EXIST, 'message' => $error]); } return $this; }
[ "public", "function", "exist", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "EXIST", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
The field must exist @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "The", "field", "must", "exist" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L951-L957
1,111
fabsgc/framework
Core/Orm/Validation/Element/Element.php
Element.notExist
public function notExist($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::NOTEXIST, 'message' => $error]); } return $this; }
php
public function notExist($error) { if ($this->_exist) { array_push($this->_constraints, ['type' => self::NOTEXIST, 'message' => $error]); } return $this; }
[ "public", "function", "notExist", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "_exist", ")", "{", "array_push", "(", "$", "this", "->", "_constraints", ",", "[", "'type'", "=>", "self", "::", "NOTEXIST", ",", "'message'", "=>", "$", "error", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
The field must not exist @access public @param $error string @return \Gcs\Framework\Core\Orm\Validation\Element\Element @since 3.0 @package Gcs\Framework\Core\Form\Validation\Element
[ "The", "field", "must", "not", "exist" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Orm/Validation/Element/Element.php#L968-L974
1,112
artscorestudio/website-bundle
Controller/ConfigController.php
ConfigController.listAction
public function listAction() { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); // Set Datagrid source $source = new Entity($this->get('asf_website.config.manager')->getClassName()); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function($query) use ($tableAlias){ $query instanceof QueryBuilder; if ( count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_website_config_list'); // Columns configuration $grid->hideColumns(array('id')); $grid->getColumn('name')->setTitle($this->get('translator')->trans('Config name', array(), 'asf_website')) ->setDefaultOperator('like') ->setOperatorsVisible(false); $editAction = new RowAction('btn_edit', 'asf_website_config_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_website_config_delete', true); $deleteAction->setRouteParameters(array('id')) ->setConfirmMessage($this->get('translator')->trans('Do you want to delete this config?', array(), 'asf_website')); $grid->addRowAction($deleteAction); $grid->setNoDataMessage($this->get('translator')->trans('No config was found.', array(), 'asf_website')); return $grid->getGridResponse('ASFWebsiteBundle:Config:list.html.twig'); }
php
public function listAction() { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); // Set Datagrid source $source = new Entity($this->get('asf_website.config.manager')->getClassName()); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function($query) use ($tableAlias){ $query instanceof QueryBuilder; if ( count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_website_config_list'); // Columns configuration $grid->hideColumns(array('id')); $grid->getColumn('name')->setTitle($this->get('translator')->trans('Config name', array(), 'asf_website')) ->setDefaultOperator('like') ->setOperatorsVisible(false); $editAction = new RowAction('btn_edit', 'asf_website_config_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_website_config_delete', true); $deleteAction->setRouteParameters(array('id')) ->setConfirmMessage($this->get('translator')->trans('Do you want to delete this config?', array(), 'asf_website')); $grid->addRowAction($deleteAction); $grid->setNoDataMessage($this->get('translator')->trans('No config was found.', array(), 'asf_website')); return $grid->getGridResponse('ASFWebsiteBundle:Config:list.html.twig'); }
[ "public", "function", "listAction", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "throw", "new", "AccessDeniedException", "(", ")", ";", "// Set Datagrid source", "$", "source", "=", "new", "Entity", "(", "$", "this", "->", "get", "(", "'asf_website.config.manager'", ")", "->", "getClassName", "(", ")", ")", ";", "$", "tableAlias", "=", "$", "source", "->", "getTableAlias", "(", ")", ";", "$", "source", "->", "manipulateQuery", "(", "function", "(", "$", "query", ")", "use", "(", "$", "tableAlias", ")", "{", "$", "query", "instanceof", "QueryBuilder", ";", "if", "(", "count", "(", "$", "query", "->", "getDQLPart", "(", "'orderBy'", ")", ")", "==", "0", ")", "{", "$", "query", "->", "orderBy", "(", "$", "tableAlias", ".", "'.name'", ",", "'ASC'", ")", ";", "}", "}", ")", ";", "// Get Grid instance", "$", "grid", "=", "$", "this", "->", "get", "(", "'grid'", ")", ";", "$", "grid", "instanceof", "Grid", ";", "// Attach the source to the grid", "$", "grid", "->", "setSource", "(", "$", "source", ")", ";", "$", "grid", "->", "setId", "(", "'asf_website_config_list'", ")", ";", "// Columns configuration", "$", "grid", "->", "hideColumns", "(", "array", "(", "'id'", ")", ")", ";", "$", "grid", "->", "getColumn", "(", "'name'", ")", "->", "setTitle", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'Config name'", ",", "array", "(", ")", ",", "'asf_website'", ")", ")", "->", "setDefaultOperator", "(", "'like'", ")", "->", "setOperatorsVisible", "(", "false", ")", ";", "$", "editAction", "=", "new", "RowAction", "(", "'btn_edit'", ",", "'asf_website_config_edit'", ")", ";", "$", "editAction", "->", "setRouteParameters", "(", "array", "(", "'id'", ")", ")", ";", "$", "grid", "->", "addRowAction", "(", "$", "editAction", ")", ";", "$", "deleteAction", "=", "new", "RowAction", "(", "'btn_delete'", ",", "'asf_website_config_delete'", ",", "true", ")", ";", "$", "deleteAction", "->", "setRouteParameters", "(", "array", "(", "'id'", ")", ")", "->", "setConfirmMessage", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'Do you want to delete this config?'", ",", "array", "(", ")", ",", "'asf_website'", ")", ")", ";", "$", "grid", "->", "addRowAction", "(", "$", "deleteAction", ")", ";", "$", "grid", "->", "setNoDataMessage", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'No config was found.'", ",", "array", "(", ")", ",", "'asf_website'", ")", ")", ";", "return", "$", "grid", "->", "getGridResponse", "(", "'ASFWebsiteBundle:Config:list.html.twig'", ")", ";", "}" ]
List all website config @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) @return \Symfony\Component\HttpFoundation\Response
[ "List", "all", "website", "config" ]
016d62d7558cd8c2fe821ae2645735149c5e6ee5
https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Controller/ConfigController.php#L37-L80
1,113
artscorestudio/website-bundle
Controller/ConfigController.php
ConfigController.editAction
public function editAction(Request $request, $id = null) { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); $formFactory = $this->get('asf_website.form.factory.config'); $configManager = $this->get('asf_website.config.manager'); if ( !is_null($id) ) { $config = $configManager->getRepository()->findOneBy(array('id' => $id)); $success_message = $this->get('translator')->trans('Updated successfully', array(), 'asf_website'); } else { $config = $configManager->createInstance(); $config->setName($this->get('translator')->trans('New website config', array(), 'asf_website')); $success_message = $this->get('translator')->trans('Created successfully', array(), 'asf_website'); } if ( is_null($config) ) throw new \Exception($this->get('translator')->trans('An error occurs when generating or getting the configuration', array(), 'asf_website')); $form = $formFactory->createForm(); $form->setData($config); $formHandler = new ConfigFormHandler($form, $request, $this->container); if ( true === $formHandler->process() ) { try { if ( is_null($config->getId()) ) { $configManager->getEntityManager()->persist($config); } $configManager->getEntityManager()->flush(); $this->get('asf_layout.flash_message')->success($success_message); return $this->redirect($this->get('router')->generate('asf_website_config_edit', array('id' => $config->getId()))); } catch(\Exception $e) { $this->get('asf_layout.flash_message')->danger($e->getMessage()); } } return $this->render('ASFWebsiteBundle:Config:edit.html.twig', array( 'config' => $config, 'form' => $form->createView() )); }
php
public function editAction(Request $request, $id = null) { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); $formFactory = $this->get('asf_website.form.factory.config'); $configManager = $this->get('asf_website.config.manager'); if ( !is_null($id) ) { $config = $configManager->getRepository()->findOneBy(array('id' => $id)); $success_message = $this->get('translator')->trans('Updated successfully', array(), 'asf_website'); } else { $config = $configManager->createInstance(); $config->setName($this->get('translator')->trans('New website config', array(), 'asf_website')); $success_message = $this->get('translator')->trans('Created successfully', array(), 'asf_website'); } if ( is_null($config) ) throw new \Exception($this->get('translator')->trans('An error occurs when generating or getting the configuration', array(), 'asf_website')); $form = $formFactory->createForm(); $form->setData($config); $formHandler = new ConfigFormHandler($form, $request, $this->container); if ( true === $formHandler->process() ) { try { if ( is_null($config->getId()) ) { $configManager->getEntityManager()->persist($config); } $configManager->getEntityManager()->flush(); $this->get('asf_layout.flash_message')->success($success_message); return $this->redirect($this->get('router')->generate('asf_website_config_edit', array('id' => $config->getId()))); } catch(\Exception $e) { $this->get('asf_layout.flash_message')->danger($e->getMessage()); } } return $this->render('ASFWebsiteBundle:Config:edit.html.twig', array( 'config' => $config, 'form' => $form->createView() )); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "$", "id", "=", "null", ")", "{", "if", "(", "false", "===", "$", "this", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "throw", "new", "AccessDeniedException", "(", ")", ";", "$", "formFactory", "=", "$", "this", "->", "get", "(", "'asf_website.form.factory.config'", ")", ";", "$", "configManager", "=", "$", "this", "->", "get", "(", "'asf_website.config.manager'", ")", ";", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "config", "=", "$", "configManager", "->", "getRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "success_message", "=", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'Updated successfully'", ",", "array", "(", ")", ",", "'asf_website'", ")", ";", "}", "else", "{", "$", "config", "=", "$", "configManager", "->", "createInstance", "(", ")", ";", "$", "config", "->", "setName", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'New website config'", ",", "array", "(", ")", ",", "'asf_website'", ")", ")", ";", "$", "success_message", "=", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'Created successfully'", ",", "array", "(", ")", ",", "'asf_website'", ")", ";", "}", "if", "(", "is_null", "(", "$", "config", ")", ")", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'An error occurs when generating or getting the configuration'", ",", "array", "(", ")", ",", "'asf_website'", ")", ")", ";", "$", "form", "=", "$", "formFactory", "->", "createForm", "(", ")", ";", "$", "form", "->", "setData", "(", "$", "config", ")", ";", "$", "formHandler", "=", "new", "ConfigFormHandler", "(", "$", "form", ",", "$", "request", ",", "$", "this", "->", "container", ")", ";", "if", "(", "true", "===", "$", "formHandler", "->", "process", "(", ")", ")", "{", "try", "{", "if", "(", "is_null", "(", "$", "config", "->", "getId", "(", ")", ")", ")", "{", "$", "configManager", "->", "getEntityManager", "(", ")", "->", "persist", "(", "$", "config", ")", ";", "}", "$", "configManager", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'asf_layout.flash_message'", ")", "->", "success", "(", "$", "success_message", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'asf_website_config_edit'", ",", "array", "(", "'id'", "=>", "$", "config", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "get", "(", "'asf_layout.flash_message'", ")", "->", "danger", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'ASFWebsiteBundle:Config:edit.html.twig'", ",", "array", "(", "'config'", "=>", "$", "config", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Add or edit a website config @param Request $request @param integer $id ASFWebsiteBundle:Config Entity ID @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) @throws \Exception Error on group not found @return \Symfony\Component\HttpFoundation\Response
[ "Add", "or", "edit", "a", "website", "config" ]
016d62d7558cd8c2fe821ae2645735149c5e6ee5
https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Controller/ConfigController.php#L93-L139
1,114
artscorestudio/website-bundle
Controller/ConfigController.php
ConfigController.deleteAction
public function deleteAction($id) { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); $config = $this->get('asf_website.config.manager')->getRepository()->findOneBy(array('id' => $id)); try { $this->get('asf_website.config.manager')->getEntityManager()->remove($config); $this->get('asf_website.config.manager')->getEntityManager()->flush(); $this->get('asf_layout.flash_message')->success($this->get('translator')->trans('The website config "%name%" successfully deleted.', array('%name%' => $config->getName()), 'asf_website')); } catch (\Exception $e) { $this->get('asf_layout.flash_message')->danger($e->getMessage()); } return $this->redirect($this->get('router')->generate('asf_website_config_list')); }
php
public function deleteAction($id) { if ( false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') ) throw new AccessDeniedException(); $config = $this->get('asf_website.config.manager')->getRepository()->findOneBy(array('id' => $id)); try { $this->get('asf_website.config.manager')->getEntityManager()->remove($config); $this->get('asf_website.config.manager')->getEntityManager()->flush(); $this->get('asf_layout.flash_message')->success($this->get('translator')->trans('The website config "%name%" successfully deleted.', array('%name%' => $config->getName()), 'asf_website')); } catch (\Exception $e) { $this->get('asf_layout.flash_message')->danger($e->getMessage()); } return $this->redirect($this->get('router')->generate('asf_website_config_list')); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "if", "(", "false", "===", "$", "this", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "throw", "new", "AccessDeniedException", "(", ")", ";", "$", "config", "=", "$", "this", "->", "get", "(", "'asf_website.config.manager'", ")", "->", "getRepository", "(", ")", "->", "findOneBy", "(", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "try", "{", "$", "this", "->", "get", "(", "'asf_website.config.manager'", ")", "->", "getEntityManager", "(", ")", "->", "remove", "(", "$", "config", ")", ";", "$", "this", "->", "get", "(", "'asf_website.config.manager'", ")", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'asf_layout.flash_message'", ")", "->", "success", "(", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'The website config \"%name%\" successfully deleted.'", ",", "array", "(", "'%name%'", "=>", "$", "config", "->", "getName", "(", ")", ")", ",", "'asf_website'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "get", "(", "'asf_layout.flash_message'", ")", "->", "danger", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'asf_website_config_list'", ")", ")", ";", "}" ]
Delete a website config @param integer $id ASFWebsiteBundle:Config Entity ID @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) @throws \Exception Error on Config not found or on removing element from DB @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Delete", "a", "website", "config" ]
016d62d7558cd8c2fe821ae2645735149c5e6ee5
https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Controller/ConfigController.php#L151-L169
1,115
rofil/security
Http/Controllers/SecurityController.php
SecurityController.prosesLogin
public function prosesLogin(UserFormLoginRequest $request) { // print_r($request->all()); $users = User::where('email', $request->get('username'))->where('password',$request->get('password'))->get(); if($users->count() > 0){ Auth::login($users->first()); return redirect()->intended(); return redirect()->to('/')->with("message", ['alert'=> 'success', 'message'=> 'Welcome '.$users->first()->name.'.'. ' You successfully logged in.']); } return redirect()->back()->with("message", ['alert'=> 'danger', 'message'=> 'Combination Username and Password is not match']); }
php
public function prosesLogin(UserFormLoginRequest $request) { // print_r($request->all()); $users = User::where('email', $request->get('username'))->where('password',$request->get('password'))->get(); if($users->count() > 0){ Auth::login($users->first()); return redirect()->intended(); return redirect()->to('/')->with("message", ['alert'=> 'success', 'message'=> 'Welcome '.$users->first()->name.'.'. ' You successfully logged in.']); } return redirect()->back()->with("message", ['alert'=> 'danger', 'message'=> 'Combination Username and Password is not match']); }
[ "public", "function", "prosesLogin", "(", "UserFormLoginRequest", "$", "request", ")", "{", "// print_r($request->all());", "$", "users", "=", "User", "::", "where", "(", "'email'", ",", "$", "request", "->", "get", "(", "'username'", ")", ")", "->", "where", "(", "'password'", ",", "$", "request", "->", "get", "(", "'password'", ")", ")", "->", "get", "(", ")", ";", "if", "(", "$", "users", "->", "count", "(", ")", ">", "0", ")", "{", "Auth", "::", "login", "(", "$", "users", "->", "first", "(", ")", ")", ";", "return", "redirect", "(", ")", "->", "intended", "(", ")", ";", "return", "redirect", "(", ")", "->", "to", "(", "'/'", ")", "->", "with", "(", "\"message\"", ",", "[", "'alert'", "=>", "'success'", ",", "'message'", "=>", "'Welcome '", ".", "$", "users", "->", "first", "(", ")", "->", "name", ".", "'.'", ".", "' You successfully logged in.'", "]", ")", ";", "}", "return", "redirect", "(", ")", "->", "back", "(", ")", "->", "with", "(", "\"message\"", ",", "[", "'alert'", "=>", "'danger'", ",", "'message'", "=>", "'Combination Username and Password is not match'", "]", ")", ";", "}" ]
This method uses to check the user credential @param UserFormLoginRequest $request Request @return redirect Response
[ "This", "method", "uses", "to", "check", "the", "user", "credential" ]
57248d056592aa03c247a087b61529fd19a3c904
https://github.com/rofil/security/blob/57248d056592aa03c247a087b61529fd19a3c904/Http/Controllers/SecurityController.php#L26-L37
1,116
cundd/test-flight
src/ObjectManager.php
ObjectManager.get
public function get(string $className, ...$constructorArguments) { if (!isset($this->container[$className])) { $instance = $this->createWithArguments( $className, $constructorArguments, $implementationClassName ); $this->container[$className] = $instance; if ($implementationClassName) { $this->container[$implementationClassName] = $instance; } } return $this->container[$className]; }
php
public function get(string $className, ...$constructorArguments) { if (!isset($this->container[$className])) { $instance = $this->createWithArguments( $className, $constructorArguments, $implementationClassName ); $this->container[$className] = $instance; if ($implementationClassName) { $this->container[$implementationClassName] = $instance; } } return $this->container[$className]; }
[ "public", "function", "get", "(", "string", "$", "className", ",", "...", "$", "constructorArguments", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "container", "[", "$", "className", "]", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "createWithArguments", "(", "$", "className", ",", "$", "constructorArguments", ",", "$", "implementationClassName", ")", ";", "$", "this", "->", "container", "[", "$", "className", "]", "=", "$", "instance", ";", "if", "(", "$", "implementationClassName", ")", "{", "$", "this", "->", "container", "[", "$", "implementationClassName", "]", "=", "$", "instance", ";", "}", "}", "return", "$", "this", "->", "container", "[", "$", "className", "]", ";", "}" ]
Retrieve the class from the container or creates a new instance @param string $className @param array $constructorArguments @return object
[ "Retrieve", "the", "class", "from", "the", "container", "or", "creates", "a", "new", "instance" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/ObjectManager.php#L53-L69
1,117
cundd/test-flight
src/ObjectManager.php
ObjectManager.createWithArguments
private function createWithArguments( string $className, array $constructorArguments, &$implementationClassName = null ) { if (interface_exists($className)) { $className = $implementationClassName = $this->getClassForInterface($className); } if (!class_exists($className)) { throw ClassDoesNotExistException::exceptionWithClassName($className); } if ($constructorArguments) { $reflector = new ReflectionClass($className); return $reflector->newInstanceArgs($constructorArguments); } return new $className(); }
php
private function createWithArguments( string $className, array $constructorArguments, &$implementationClassName = null ) { if (interface_exists($className)) { $className = $implementationClassName = $this->getClassForInterface($className); } if (!class_exists($className)) { throw ClassDoesNotExistException::exceptionWithClassName($className); } if ($constructorArguments) { $reflector = new ReflectionClass($className); return $reflector->newInstanceArgs($constructorArguments); } return new $className(); }
[ "private", "function", "createWithArguments", "(", "string", "$", "className", ",", "array", "$", "constructorArguments", ",", "&", "$", "implementationClassName", "=", "null", ")", "{", "if", "(", "interface_exists", "(", "$", "className", ")", ")", "{", "$", "className", "=", "$", "implementationClassName", "=", "$", "this", "->", "getClassForInterface", "(", "$", "className", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "ClassDoesNotExistException", "::", "exceptionWithClassName", "(", "$", "className", ")", ";", "}", "if", "(", "$", "constructorArguments", ")", "{", "$", "reflector", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "return", "$", "reflector", "->", "newInstanceArgs", "(", "$", "constructorArguments", ")", ";", "}", "return", "new", "$", "className", "(", ")", ";", "}" ]
Returns a new instance of the given class @param string $className @param array $constructorArguments @param string $implementationClassName @return object
[ "Returns", "a", "new", "instance", "of", "the", "given", "class" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/ObjectManager.php#L91-L109
1,118
cundd/test-flight
src/ObjectManager.php
ObjectManager.getClassForInterface
private function getClassForInterface(string $interfaceName) { $implementationName = ''; if (strtolower(substr($interfaceName, -9)) === 'interface') { $implementationName = substr($interfaceName, 0, -9); } if (!class_exists($implementationName)) { throw NoImplementationForInterfaceException::exceptionWithInterfaceName($interfaceName); } return $implementationName; }
php
private function getClassForInterface(string $interfaceName) { $implementationName = ''; if (strtolower(substr($interfaceName, -9)) === 'interface') { $implementationName = substr($interfaceName, 0, -9); } if (!class_exists($implementationName)) { throw NoImplementationForInterfaceException::exceptionWithInterfaceName($interfaceName); } return $implementationName; }
[ "private", "function", "getClassForInterface", "(", "string", "$", "interfaceName", ")", "{", "$", "implementationName", "=", "''", ";", "if", "(", "strtolower", "(", "substr", "(", "$", "interfaceName", ",", "-", "9", ")", ")", "===", "'interface'", ")", "{", "$", "implementationName", "=", "substr", "(", "$", "interfaceName", ",", "0", ",", "-", "9", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "implementationName", ")", ")", "{", "throw", "NoImplementationForInterfaceException", "::", "exceptionWithInterfaceName", "(", "$", "interfaceName", ")", ";", "}", "return", "$", "implementationName", ";", "}" ]
Try to find the class name for the given interface @param string $interfaceName @return string
[ "Try", "to", "find", "the", "class", "name", "for", "the", "given", "interface" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/ObjectManager.php#L117-L129
1,119
vitodtagliente/pure-template
ViewScriptEngine.php
ViewScriptEngine.map
function map($view_content, $view_params = array()) { // trova tutte le regole racchiuse tra doppie graffe $rules = ViewUtility::find_rules($view_content, '{{', '}}'); foreach ($rules as $rule) { // estrapola la parte di codice racchiusa $rule_code = str_replace('{{', '', $rule); $rule_code = str_replace('}}', '', $rule_code); $rule_code = trim($rule_code); $rule_code = trim($rule_code, ';'); // memorizza qui l'esito dell'elaborazione $rule_code_value = null; // se è una sola parola // presumibilmente è una variabile // in tal caso, esegui la stampa del valore if(strpos($rule_code, '$') === 0) { // cerca tra i parametri della vista if ($rule_code_value == null) { $rule_code_variable = ltrim($rule_code, '$'); foreach ($view_params as $param_key => $param_value) { if($param_key == $rule_code_variable) { $rule_code_value = $param_value; break; } } } } else { // si tratta di una funzione presumibilmente $rule_code_value = eval("$rule_code;"); if($rule_code_value == null) { // it is a void function $rule_code_value = eval("return $rule_code;"); } } $view_content = str_replace($rule, $rule_code_value, $view_content); } return $view_content; }
php
function map($view_content, $view_params = array()) { // trova tutte le regole racchiuse tra doppie graffe $rules = ViewUtility::find_rules($view_content, '{{', '}}'); foreach ($rules as $rule) { // estrapola la parte di codice racchiusa $rule_code = str_replace('{{', '', $rule); $rule_code = str_replace('}}', '', $rule_code); $rule_code = trim($rule_code); $rule_code = trim($rule_code, ';'); // memorizza qui l'esito dell'elaborazione $rule_code_value = null; // se è una sola parola // presumibilmente è una variabile // in tal caso, esegui la stampa del valore if(strpos($rule_code, '$') === 0) { // cerca tra i parametri della vista if ($rule_code_value == null) { $rule_code_variable = ltrim($rule_code, '$'); foreach ($view_params as $param_key => $param_value) { if($param_key == $rule_code_variable) { $rule_code_value = $param_value; break; } } } } else { // si tratta di una funzione presumibilmente $rule_code_value = eval("$rule_code;"); if($rule_code_value == null) { // it is a void function $rule_code_value = eval("return $rule_code;"); } } $view_content = str_replace($rule, $rule_code_value, $view_content); } return $view_content; }
[ "function", "map", "(", "$", "view_content", ",", "$", "view_params", "=", "array", "(", ")", ")", "{", "// trova tutte le regole racchiuse tra doppie graffe", "$", "rules", "=", "ViewUtility", "::", "find_rules", "(", "$", "view_content", ",", "'{{'", ",", "'}}'", ")", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "// estrapola la parte di codice racchiusa", "$", "rule_code", "=", "str_replace", "(", "'{{'", ",", "''", ",", "$", "rule", ")", ";", "$", "rule_code", "=", "str_replace", "(", "'}}'", ",", "''", ",", "$", "rule_code", ")", ";", "$", "rule_code", "=", "trim", "(", "$", "rule_code", ")", ";", "$", "rule_code", "=", "trim", "(", "$", "rule_code", ",", "';'", ")", ";", "// memorizza qui l'esito dell'elaborazione", "$", "rule_code_value", "=", "null", ";", "// se è una sola parola", "// presumibilmente è una variabile", "// in tal caso, esegui la stampa del valore", "if", "(", "strpos", "(", "$", "rule_code", ",", "'$'", ")", "===", "0", ")", "{", "// cerca tra i parametri della vista", "if", "(", "$", "rule_code_value", "==", "null", ")", "{", "$", "rule_code_variable", "=", "ltrim", "(", "$", "rule_code", ",", "'$'", ")", ";", "foreach", "(", "$", "view_params", "as", "$", "param_key", "=>", "$", "param_value", ")", "{", "if", "(", "$", "param_key", "==", "$", "rule_code_variable", ")", "{", "$", "rule_code_value", "=", "$", "param_value", ";", "break", ";", "}", "}", "}", "}", "else", "{", "// si tratta di una funzione presumibilmente", "$", "rule_code_value", "=", "eval", "(", "\"$rule_code;\"", ")", ";", "if", "(", "$", "rule_code_value", "==", "null", ")", "{", "// it is a void function", "$", "rule_code_value", "=", "eval", "(", "\"return $rule_code;\"", ")", ";", "}", "}", "$", "view_content", "=", "str_replace", "(", "$", "rule", ",", "$", "rule_code_value", ",", "$", "view_content", ")", ";", "}", "return", "$", "view_content", ";", "}" ]
Map php functions and variables
[ "Map", "php", "functions", "and", "variables" ]
d3f3e38d7e425a5f9f6e17df405037f6001ff3e9
https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/ViewScriptEngine.php#L8-L58
1,120
vainproject/vain-cms
app/Exceptions/Handler.php
Handler.renderXmlHttpException
protected function renderXmlHttpException($e) { // handle our ajax errors $data = [ 'message' => $e->getMessage(), ]; if ($e instanceof HttpException) { return new JsonResponse($data, $e->getStatusCode()); } return new JsonResponse($data, 500); }
php
protected function renderXmlHttpException($e) { // handle our ajax errors $data = [ 'message' => $e->getMessage(), ]; if ($e instanceof HttpException) { return new JsonResponse($data, $e->getStatusCode()); } return new JsonResponse($data, 500); }
[ "protected", "function", "renderXmlHttpException", "(", "$", "e", ")", "{", "// handle our ajax errors", "$", "data", "=", "[", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "]", ";", "if", "(", "$", "e", "instanceof", "HttpException", ")", "{", "return", "new", "JsonResponse", "(", "$", "data", ",", "$", "e", "->", "getStatusCode", "(", ")", ")", ";", "}", "return", "new", "JsonResponse", "(", "$", "data", ",", "500", ")", ";", "}" ]
Renders an exception from ajax requests. @param \Exception $e @return JsonResponse
[ "Renders", "an", "exception", "from", "ajax", "requests", "." ]
17f5ab91be21ece3e8a8ba67ba5fc8d8e6805900
https://github.com/vainproject/vain-cms/blob/17f5ab91be21ece3e8a8ba67ba5fc8d8e6805900/app/Exceptions/Handler.php#L87-L99
1,121
vainproject/vain-cms
app/Exceptions/Handler.php
Handler.renderDebugXmlHttpException
protected function renderDebugXmlHttpException($e) { // handle our ajax errors $data = [ 'message' => $e->getMessage(), 'trace' => $e->getTrace(), ]; if ($e instanceof HttpException) { return new JsonResponse($data, $e->getStatusCode()); } return new JsonResponse($data, 500); }
php
protected function renderDebugXmlHttpException($e) { // handle our ajax errors $data = [ 'message' => $e->getMessage(), 'trace' => $e->getTrace(), ]; if ($e instanceof HttpException) { return new JsonResponse($data, $e->getStatusCode()); } return new JsonResponse($data, 500); }
[ "protected", "function", "renderDebugXmlHttpException", "(", "$", "e", ")", "{", "// handle our ajax errors", "$", "data", "=", "[", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'trace'", "=>", "$", "e", "->", "getTrace", "(", ")", ",", "]", ";", "if", "(", "$", "e", "instanceof", "HttpException", ")", "{", "return", "new", "JsonResponse", "(", "$", "data", ",", "$", "e", "->", "getStatusCode", "(", ")", ")", ";", "}", "return", "new", "JsonResponse", "(", "$", "data", ",", "500", ")", ";", "}" ]
Renders an exception from ajax requests Only use this in debug mode. @param \Exception $e @return JsonResponse
[ "Renders", "an", "exception", "from", "ajax", "requests", "Only", "use", "this", "in", "debug", "mode", "." ]
17f5ab91be21ece3e8a8ba67ba5fc8d8e6805900
https://github.com/vainproject/vain-cms/blob/17f5ab91be21ece3e8a8ba67ba5fc8d8e6805900/app/Exceptions/Handler.php#L109-L122
1,122
themichaelhall/bluemvc-forms
src/Base/AbstractForm.php
AbstractForm.getElementsToProcess
private function getElementsToProcess(): array { $result = []; foreach (get_object_vars($this) as $element) { if ($element instanceof FormElementInterface) { $result[] = $element; } } $result = array_merge($result, $this->extraElements); return $result; }
php
private function getElementsToProcess(): array { $result = []; foreach (get_object_vars($this) as $element) { if ($element instanceof FormElementInterface) { $result[] = $element; } } $result = array_merge($result, $this->extraElements); return $result; }
[ "private", "function", "getElementsToProcess", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "element", ")", "{", "if", "(", "$", "element", "instanceof", "FormElementInterface", ")", "{", "$", "result", "[", "]", "=", "$", "element", ";", "}", "}", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "this", "->", "extraElements", ")", ";", "return", "$", "result", ";", "}" ]
Returns the elements to process. @return FormElementInterface[] The elements to process.
[ "Returns", "the", "elements", "to", "process", "." ]
8f0e29aaf71eba70b50697384b22edaf72f2f45b
https://github.com/themichaelhall/bluemvc-forms/blob/8f0e29aaf71eba70b50697384b22edaf72f2f45b/src/Base/AbstractForm.php#L180-L193
1,123
Eresus/Gallery
src/gallery/phpthumb/ThumbBase.inc.php
ThumbBase.imports
protected function imports ($object) { // the new object to import $newImport = new $object(); // the name of the new object (class name) $importName = get_class($newImport); // the new functions to import $importFunctions = get_class_methods($newImport); // add the object to the registry array_push($this->imported, array($importName, $newImport)); // add the methods to the registry foreach ($importFunctions as $key => $functionName) { $this->importedFunctions[$functionName] = &$newImport; } }
php
protected function imports ($object) { // the new object to import $newImport = new $object(); // the name of the new object (class name) $importName = get_class($newImport); // the new functions to import $importFunctions = get_class_methods($newImport); // add the object to the registry array_push($this->imported, array($importName, $newImport)); // add the methods to the registry foreach ($importFunctions as $key => $functionName) { $this->importedFunctions[$functionName] = &$newImport; } }
[ "protected", "function", "imports", "(", "$", "object", ")", "{", "// the new object to import", "$", "newImport", "=", "new", "$", "object", "(", ")", ";", "// the name of the new object (class name)", "$", "importName", "=", "get_class", "(", "$", "newImport", ")", ";", "// the new functions to import", "$", "importFunctions", "=", "get_class_methods", "(", "$", "newImport", ")", ";", "// add the object to the registry", "array_push", "(", "$", "this", "->", "imported", ",", "array", "(", "$", "importName", ",", "$", "newImport", ")", ")", ";", "// add the methods to the registry", "foreach", "(", "$", "importFunctions", "as", "$", "key", "=>", "$", "functionName", ")", "{", "$", "this", "->", "importedFunctions", "[", "$", "functionName", "]", "=", "&", "$", "newImport", ";", "}", "}" ]
Imports a plugin This is where all the plugins magic happens! This function "loads" the plugin functions, making them available as methods on the class. @param string $object The name of the object to import / "load"
[ "Imports", "a", "plugin" ]
1088c5563597abc38c3772b335ca62de47721af8
https://github.com/Eresus/Gallery/blob/1088c5563597abc38c3772b335ca62de47721af8/src/gallery/phpthumb/ThumbBase.inc.php#L134-L151
1,124
skeeks-cms/cms-related-handler-extra
RelatedHandlerExtra.php
RelatedHandlerExtra.initValue
public function initValue($value) { try { $value = Json::decode($value); } catch (\Exception $e) { $value = []; } return $value; }
php
public function initValue($value) { try { $value = Json::decode($value); } catch (\Exception $e) { $value = []; } return $value; }
[ "public", "function", "initValue", "(", "$", "value", ")", "{", "try", "{", "$", "value", "=", "Json", "::", "decode", "(", "$", "value", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "value", "=", "[", "]", ";", "}", "return", "$", "value", ";", "}" ]
Conversion property value received from the database @return $this @throws models\InvalidParamException
[ "Conversion", "property", "value", "received", "from", "the", "database" ]
ae81d725810faa03686cabce6ed512cdd7869dd2
https://github.com/skeeks-cms/cms-related-handler-extra/blob/ae81d725810faa03686cabce6ed512cdd7869dd2/RelatedHandlerExtra.php#L74-L85
1,125
skeeks-cms/cms-related-handler-extra
RelatedHandlerExtra.php
RelatedHandlerExtra.beforeSaveValue
public function beforeSaveValue($value) { try { $value = Json::encode($value); } catch (\Exception $e) { $value = "{}"; } return $value; }
php
public function beforeSaveValue($value) { try { $value = Json::encode($value); } catch (\Exception $e) { $value = "{}"; } return $value; }
[ "public", "function", "beforeSaveValue", "(", "$", "value", ")", "{", "try", "{", "$", "value", "=", "Json", "::", "encode", "(", "$", "value", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "value", "=", "\"{}\"", ";", "}", "return", "$", "value", ";", "}" ]
Converting the property value before saving to database @return $this
[ "Converting", "the", "property", "value", "before", "saving", "to", "database" ]
ae81d725810faa03686cabce6ed512cdd7869dd2
https://github.com/skeeks-cms/cms-related-handler-extra/blob/ae81d725810faa03686cabce6ed512cdd7869dd2/RelatedHandlerExtra.php#L92-L103
1,126
mostofreddy/slim-loggy
src/LoggyMiddleware.php
LoggyMiddleware.setLoggers
protected function setLoggers() { if ($loggers = $this->hasLoggerConfig()) { foreach ($loggers as $channel => $logger) { $loggerChannel = $this->getChannelName($logger, $channel); $loggerName = $this->getLoggerIdentified($logger, $loggerChannel); $this->container[$loggerName] = Logger::get( $loggerChannel, $this->buildHandlers($logger['handlers']??[]) ); } } }
php
protected function setLoggers() { if ($loggers = $this->hasLoggerConfig()) { foreach ($loggers as $channel => $logger) { $loggerChannel = $this->getChannelName($logger, $channel); $loggerName = $this->getLoggerIdentified($logger, $loggerChannel); $this->container[$loggerName] = Logger::get( $loggerChannel, $this->buildHandlers($logger['handlers']??[]) ); } } }
[ "protected", "function", "setLoggers", "(", ")", "{", "if", "(", "$", "loggers", "=", "$", "this", "->", "hasLoggerConfig", "(", ")", ")", "{", "foreach", "(", "$", "loggers", "as", "$", "channel", "=>", "$", "logger", ")", "{", "$", "loggerChannel", "=", "$", "this", "->", "getChannelName", "(", "$", "logger", ",", "$", "channel", ")", ";", "$", "loggerName", "=", "$", "this", "->", "getLoggerIdentified", "(", "$", "logger", ",", "$", "loggerChannel", ")", ";", "$", "this", "->", "container", "[", "$", "loggerName", "]", "=", "Logger", "::", "get", "(", "$", "loggerChannel", ",", "$", "this", "->", "buildHandlers", "(", "$", "logger", "[", "'handlers'", "]", "??", "[", "]", ")", ")", ";", "}", "}", "}" ]
Crea los loggers en el container @return void
[ "Crea", "los", "loggers", "en", "el", "container" ]
2dffaec2b7bd943237f6a61e01601914deba65bc
https://github.com/mostofreddy/slim-loggy/blob/2dffaec2b7bd943237f6a61e01601914deba65bc/src/LoggyMiddleware.php#L79-L92
1,127
mostofreddy/slim-loggy
src/LoggyMiddleware.php
LoggyMiddleware.buildHandlers
protected function buildHandlers(array $config):array { $handlers = []; foreach ($config as $handler) { $level = constant('\Mostofreddy\Loggy\Logger::'. strtoupper($handler['level'])); $handlerObj = '\Mostofreddy\Loggy\Handler\\'.ucfirst($handler['handler']); $handlers[] = (new $handlerObj($level))->config($handler); } return $handlers; }
php
protected function buildHandlers(array $config):array { $handlers = []; foreach ($config as $handler) { $level = constant('\Mostofreddy\Loggy\Logger::'. strtoupper($handler['level'])); $handlerObj = '\Mostofreddy\Loggy\Handler\\'.ucfirst($handler['handler']); $handlers[] = (new $handlerObj($level))->config($handler); } return $handlers; }
[ "protected", "function", "buildHandlers", "(", "array", "$", "config", ")", ":", "array", "{", "$", "handlers", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "handler", ")", "{", "$", "level", "=", "constant", "(", "'\\Mostofreddy\\Loggy\\Logger::'", ".", "strtoupper", "(", "$", "handler", "[", "'level'", "]", ")", ")", ";", "$", "handlerObj", "=", "'\\Mostofreddy\\Loggy\\Handler\\\\'", ".", "ucfirst", "(", "$", "handler", "[", "'handler'", "]", ")", ";", "$", "handlers", "[", "]", "=", "(", "new", "$", "handlerObj", "(", "$", "level", ")", ")", "->", "config", "(", "$", "handler", ")", ";", "}", "return", "$", "handlers", ";", "}" ]
Instancia los handlers del logger @param array $config Configuracion de los handlers del logger @return array
[ "Instancia", "los", "handlers", "del", "logger" ]
2dffaec2b7bd943237f6a61e01601914deba65bc
https://github.com/mostofreddy/slim-loggy/blob/2dffaec2b7bd943237f6a61e01601914deba65bc/src/LoggyMiddleware.php#L100-L109
1,128
Puzzlout/FrameworkMvcLegacy
src/Helpers/WebIde/CreateFileHelper.php
CreateFileHelper.GetFileType
public function GetFileType($dataPost) { $templateTypeKey = "templateType"; if (!array_key_exists($templateTypeKey, $dataPost)) { throw new \Exception("The POST data doesn't contain the value $templateTypeKey. See dump" . var_dump($dataPost), 0, null); } $this->templateType = $dataPost[$templateTypeKey]; return $this; }
php
public function GetFileType($dataPost) { $templateTypeKey = "templateType"; if (!array_key_exists($templateTypeKey, $dataPost)) { throw new \Exception("The POST data doesn't contain the value $templateTypeKey. See dump" . var_dump($dataPost), 0, null); } $this->templateType = $dataPost[$templateTypeKey]; return $this; }
[ "public", "function", "GetFileType", "(", "$", "dataPost", ")", "{", "$", "templateTypeKey", "=", "\"templateType\"", ";", "if", "(", "!", "array_key_exists", "(", "$", "templateTypeKey", ",", "$", "dataPost", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"The POST data doesn't contain the value $templateTypeKey. See dump\"", ".", "var_dump", "(", "$", "dataPost", ")", ",", "0", ",", "null", ")", ";", "}", "$", "this", "->", "templateType", "=", "$", "dataPost", "[", "$", "templateTypeKey", "]", ";", "return", "$", "this", ";", "}" ]
Get the file type in the POST request. @param array $dataPost The POST data sent by the client. @throws \Exception An exception is thrown when the POST data doesn't contain the key "templateType"
[ "Get", "the", "file", "type", "in", "the", "POST", "request", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Helpers/WebIde/CreateFileHelper.php#L38-L46
1,129
harpya/ufw-base
src/ufw/Setup.php
Setup.help
public function help() { $this->showHeader(); echo "ufw - Helper to uFw framework\n\nOptions:\n"; foreach (self::HELP['options'] as $helpOption => $helpDescription) { echo "\n $helpOption \t " . ($helpDescription['summary'] ?? ""); if (array_key_exists('examples', $helpDescription)) { echo "\n \t Ex:"; foreach ($helpDescription['examples'] as $example) { echo "\n \t $example"; } echo "\n"; } } echo "\n"; }
php
public function help() { $this->showHeader(); echo "ufw - Helper to uFw framework\n\nOptions:\n"; foreach (self::HELP['options'] as $helpOption => $helpDescription) { echo "\n $helpOption \t " . ($helpDescription['summary'] ?? ""); if (array_key_exists('examples', $helpDescription)) { echo "\n \t Ex:"; foreach ($helpDescription['examples'] as $example) { echo "\n \t $example"; } echo "\n"; } } echo "\n"; }
[ "public", "function", "help", "(", ")", "{", "$", "this", "->", "showHeader", "(", ")", ";", "echo", "\"ufw - Helper to uFw framework\\n\\nOptions:\\n\"", ";", "foreach", "(", "self", "::", "HELP", "[", "'options'", "]", "as", "$", "helpOption", "=>", "$", "helpDescription", ")", "{", "echo", "\"\\n $helpOption \\t \"", ".", "(", "$", "helpDescription", "[", "'summary'", "]", "??", "\"\"", ")", ";", "if", "(", "array_key_exists", "(", "'examples'", ",", "$", "helpDescription", ")", ")", "{", "echo", "\"\\n \\t Ex:\"", ";", "foreach", "(", "$", "helpDescription", "[", "'examples'", "]", "as", "$", "example", ")", "{", "echo", "\"\\n \\t $example\"", ";", "}", "echo", "\"\\n\"", ";", "}", "}", "echo", "\"\\n\"", ";", "}" ]
Shows the help options
[ "Shows", "the", "help", "options" ]
9e2db1d9625f4b875783f98830e0410cf4fd125b
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Setup.php#L60-L74
1,130
harpya/ufw-base
src/ufw/Setup.php
Setup.run
public function run() { // Create a new project if (Console::getArg('--create')) { $this->createProject(Console::getArg('--create')); return; // Initialize the current workspace } elseif (Console::getArg('--init')) { $this->initProject(); return; // Run a command from an application } elseif (Console::getArg('--run')) { $this->runAction(Console::getArg('--run'), json_decode(Console::getArg('--data', '[]'), true)); return; } else { $this->help(); } }
php
public function run() { // Create a new project if (Console::getArg('--create')) { $this->createProject(Console::getArg('--create')); return; // Initialize the current workspace } elseif (Console::getArg('--init')) { $this->initProject(); return; // Run a command from an application } elseif (Console::getArg('--run')) { $this->runAction(Console::getArg('--run'), json_decode(Console::getArg('--data', '[]'), true)); return; } else { $this->help(); } }
[ "public", "function", "run", "(", ")", "{", "// Create a new project", "if", "(", "Console", "::", "getArg", "(", "'--create'", ")", ")", "{", "$", "this", "->", "createProject", "(", "Console", "::", "getArg", "(", "'--create'", ")", ")", ";", "return", ";", "// Initialize the current workspace ", "}", "elseif", "(", "Console", "::", "getArg", "(", "'--init'", ")", ")", "{", "$", "this", "->", "initProject", "(", ")", ";", "return", ";", "// Run a command from an application ", "}", "elseif", "(", "Console", "::", "getArg", "(", "'--run'", ")", ")", "{", "$", "this", "->", "runAction", "(", "Console", "::", "getArg", "(", "'--run'", ")", ",", "json_decode", "(", "Console", "::", "getArg", "(", "'--data'", ",", "'[]'", ")", ",", "true", ")", ")", ";", "return", ";", "}", "else", "{", "$", "this", "->", "help", "(", ")", ";", "}", "}" ]
Inspect the command line arguments and execute it. @return void
[ "Inspect", "the", "command", "line", "arguments", "and", "execute", "it", "." ]
9e2db1d9625f4b875783f98830e0410cf4fd125b
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Setup.php#L96-L115
1,131
harpya/ufw-base
src/ufw/Setup.php
Setup.initProject
protected function initProject() { $this->showHeader(); Utils::getInstance()->createDirectory(['apps', 'bootstrap', 'config', 'public', 'tmp/tpl_compile', 'plugins']); foreach (self::FILES_BASE as $pathname => $contents) { Utils::getInstance()->createFile($pathname, $contents); } chmod("tmp", 775); chmod("tmp/tpl_compile", 775); }
php
protected function initProject() { $this->showHeader(); Utils::getInstance()->createDirectory(['apps', 'bootstrap', 'config', 'public', 'tmp/tpl_compile', 'plugins']); foreach (self::FILES_BASE as $pathname => $contents) { Utils::getInstance()->createFile($pathname, $contents); } chmod("tmp", 775); chmod("tmp/tpl_compile", 775); }
[ "protected", "function", "initProject", "(", ")", "{", "$", "this", "->", "showHeader", "(", ")", ";", "Utils", "::", "getInstance", "(", ")", "->", "createDirectory", "(", "[", "'apps'", ",", "'bootstrap'", ",", "'config'", ",", "'public'", ",", "'tmp/tpl_compile'", ",", "'plugins'", "]", ")", ";", "foreach", "(", "self", "::", "FILES_BASE", "as", "$", "pathname", "=>", "$", "contents", ")", "{", "Utils", "::", "getInstance", "(", ")", "->", "createFile", "(", "$", "pathname", ",", "$", "contents", ")", ";", "}", "chmod", "(", "\"tmp\"", ",", "775", ")", ";", "chmod", "(", "\"tmp/tpl_compile\"", ",", "775", ")", ";", "}" ]
Initialize the current workspace
[ "Initialize", "the", "current", "workspace" ]
9e2db1d9625f4b875783f98830e0410cf4fd125b
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Setup.php#L121-L129
1,132
harpya/ufw-base
src/ufw/Setup.php
Setup.createProject
protected function createProject($projectName = 'myProj') { $this->showHeader(); Console::stdout("Creating $projectName \n"); Utils::getInstance()->createDirectory("./apps/" . $projectName, ['src', 'routes', 'config', 'public', 'doc', 'templates']); echo "\n"; foreach (self::FILES_APP as $pathname => $contents) { Utils::getInstance()->createFile("./apps/" . $projectName . "/" . $pathname, $contents); } echo "\n Don't forget to run 'composer update' in your root project folder (apps/" . $projectName . ") before start to use! \n"; }
php
protected function createProject($projectName = 'myProj') { $this->showHeader(); Console::stdout("Creating $projectName \n"); Utils::getInstance()->createDirectory("./apps/" . $projectName, ['src', 'routes', 'config', 'public', 'doc', 'templates']); echo "\n"; foreach (self::FILES_APP as $pathname => $contents) { Utils::getInstance()->createFile("./apps/" . $projectName . "/" . $pathname, $contents); } echo "\n Don't forget to run 'composer update' in your root project folder (apps/" . $projectName . ") before start to use! \n"; }
[ "protected", "function", "createProject", "(", "$", "projectName", "=", "'myProj'", ")", "{", "$", "this", "->", "showHeader", "(", ")", ";", "Console", "::", "stdout", "(", "\"Creating $projectName \\n\"", ")", ";", "Utils", "::", "getInstance", "(", ")", "->", "createDirectory", "(", "\"./apps/\"", ".", "$", "projectName", ",", "[", "'src'", ",", "'routes'", ",", "'config'", ",", "'public'", ",", "'doc'", ",", "'templates'", "]", ")", ";", "echo", "\"\\n\"", ";", "foreach", "(", "self", "::", "FILES_APP", "as", "$", "pathname", "=>", "$", "contents", ")", "{", "Utils", "::", "getInstance", "(", ")", "->", "createFile", "(", "\"./apps/\"", ".", "$", "projectName", ".", "\"/\"", ".", "$", "pathname", ",", "$", "contents", ")", ";", "}", "echo", "\"\\n Don't forget to run 'composer update' in your root project folder (apps/\"", ".", "$", "projectName", ".", "\") before start to use! \\n\"", ";", "}" ]
Create a new project workspace, and initialize it. @param string $projectName
[ "Create", "a", "new", "project", "workspace", "and", "initialize", "it", "." ]
9e2db1d9625f4b875783f98830e0410cf4fd125b
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Setup.php#L139-L149
1,133
harpya/ufw-base
src/ufw/Setup.php
Setup.performRunAction
protected function performRunAction() { require __DIR__ . "/../../../../../vendor/autoload.php"; $request = \harpya\ufw\Request::of(); $appFolder = __DIR__ . '/../../../../../apps/'; $appFolder = '../apps/'; $app = \harpya\ufw\ApplicationCli::getInstance([ Application::DEF_APPS_PATH => $appFolder, Application::CMP_ROUTER => new \harpya\ufw\Router(), Application::CMP_REQUEST => $request, Application::CMP_CONFIG => \harpya\ufw\Config::of(__DIR__ . '/../../../..') ]); $app->init(); $out = $app->run(); print_r($out); exit; }
php
protected function performRunAction() { require __DIR__ . "/../../../../../vendor/autoload.php"; $request = \harpya\ufw\Request::of(); $appFolder = __DIR__ . '/../../../../../apps/'; $appFolder = '../apps/'; $app = \harpya\ufw\ApplicationCli::getInstance([ Application::DEF_APPS_PATH => $appFolder, Application::CMP_ROUTER => new \harpya\ufw\Router(), Application::CMP_REQUEST => $request, Application::CMP_CONFIG => \harpya\ufw\Config::of(__DIR__ . '/../../../..') ]); $app->init(); $out = $app->run(); print_r($out); exit; }
[ "protected", "function", "performRunAction", "(", ")", "{", "require", "__DIR__", ".", "\"/../../../../../vendor/autoload.php\"", ";", "$", "request", "=", "\\", "harpya", "\\", "ufw", "\\", "Request", "::", "of", "(", ")", ";", "$", "appFolder", "=", "__DIR__", ".", "'/../../../../../apps/'", ";", "$", "appFolder", "=", "'../apps/'", ";", "$", "app", "=", "\\", "harpya", "\\", "ufw", "\\", "ApplicationCli", "::", "getInstance", "(", "[", "Application", "::", "DEF_APPS_PATH", "=>", "$", "appFolder", ",", "Application", "::", "CMP_ROUTER", "=>", "new", "\\", "harpya", "\\", "ufw", "\\", "Router", "(", ")", ",", "Application", "::", "CMP_REQUEST", "=>", "$", "request", ",", "Application", "::", "CMP_CONFIG", "=>", "\\", "harpya", "\\", "ufw", "\\", "Config", "::", "of", "(", "__DIR__", ".", "'/../../../..'", ")", "]", ")", ";", "$", "app", "->", "init", "(", ")", ";", "$", "out", "=", "$", "app", "->", "run", "(", ")", ";", "print_r", "(", "$", "out", ")", ";", "exit", ";", "}" ]
Emulate the same as what the web server do, to fulfill a request.
[ "Emulate", "the", "same", "as", "what", "the", "web", "server", "do", "to", "fulfill", "a", "request", "." ]
9e2db1d9625f4b875783f98830e0410cf4fd125b
https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/Setup.php#L189-L211
1,134
snowiow/cocurl
src/COCEntity.php
COCEntity.fill
public static function fill(array $data, COCEntity &$entity) { $vars = get_object_vars($entity); foreach ($vars as $var => $_) { if (array_key_exists($var, $data)) { $entity->{$var} = $data[$var]; } } }
php
public static function fill(array $data, COCEntity &$entity) { $vars = get_object_vars($entity); foreach ($vars as $var => $_) { if (array_key_exists($var, $data)) { $entity->{$var} = $data[$var]; } } }
[ "public", "static", "function", "fill", "(", "array", "$", "data", ",", "COCEntity", "&", "$", "entity", ")", "{", "$", "vars", "=", "get_object_vars", "(", "$", "entity", ")", ";", "foreach", "(", "$", "vars", "as", "$", "var", "=>", "$", "_", ")", "{", "if", "(", "array_key_exists", "(", "$", "var", ",", "$", "data", ")", ")", "{", "$", "entity", "->", "{", "$", "var", "}", "=", "$", "data", "[", "$", "var", "]", ";", "}", "}", "}" ]
Fills the data from an array into the given class @param array $data the data which will be filled into the class @param COCEntity $entity the cocentity child which need to be filled @return void
[ "Fills", "the", "data", "from", "an", "array", "into", "the", "given", "class" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/COCEntity.php#L19-L27
1,135
webriq/core
module/User/src/Grid/User/View/Helper/IsAllowed.php
IsAllowed.isAllowed
public function isAllowed( $resource, $privilege = null, $role = null ) { return $this->getPermissionsModel() ->isAllowed( $resource, $privilege, $role ); }
php
public function isAllowed( $resource, $privilege = null, $role = null ) { return $this->getPermissionsModel() ->isAllowed( $resource, $privilege, $role ); }
[ "public", "function", "isAllowed", "(", "$", "resource", ",", "$", "privilege", "=", "null", ",", "$", "role", "=", "null", ")", "{", "return", "$", "this", "->", "getPermissionsModel", "(", ")", "->", "isAllowed", "(", "$", "resource", ",", "$", "privilege", ",", "$", "role", ")", ";", "}" ]
Is a permission allowed or not @param string|\Zend\Permissions\Acl\Resource\ResourceInterface $resource @param string $privilege @param string|\Zend\Permissions\Acl\Role\RoleInterface $role @return bool
[ "Is", "a", "permission", "allowed", "or", "not" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/View/Helper/IsAllowed.php#L57-L61
1,136
oal/babble
src/API/ModelController.php
ModelController.getContentFromRequest
private function getContentFromRequest(Request $request): array { $data = json_decode($request->getContent(), true); foreach ($data as $key => $value) { if ($value === null || $value === '') { unset($data[$key]); } } return $data; }
php
private function getContentFromRequest(Request $request): array { $data = json_decode($request->getContent(), true); foreach ($data as $key => $value) { if ($value === null || $value === '') { unset($data[$key]); } } return $data; }
[ "private", "function", "getContentFromRequest", "(", "Request", "$", "request", ")", ":", "array", "{", "$", "data", "=", "json_decode", "(", "$", "request", "->", "getContent", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "$", "value", "===", "''", ")", "{", "unset", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Returns an array of data from the request body and omits null values. @param Request $request @return array
[ "Returns", "an", "array", "of", "data", "from", "the", "request", "body", "and", "omits", "null", "values", "." ]
5a352d12ead6341294747831b0dfce097a0215e7
https://github.com/oal/babble/blob/5a352d12ead6341294747831b0dfce097a0215e7/src/API/ModelController.php#L184-L193
1,137
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.initPaths
protected function initPaths(array $exclude_dirs = []) { $apps_dir = $this->core->config->get('Core', 'dir.apps'); $apps_url = $this->core->config->get('Core', 'url.apps'); // Set path property which can be used on including additional app files like settings, routes, config etc $dir = $this->getDir(); // Get directory path of app $scanned_directory = array_diff(scandir($dir), array( '..', '.' )); $this->paths = new Paths(); $dir = $this->getDir(); $string = new CamelCase(''); foreach ($scanned_directory as $item) { if (is_dir($dir . '/' . $item) && !in_array($item, $exclude_dirs)) { $string->setString($item); $key = $string->uncamelize(); $this->paths->add('dir.' . $key, $dir . '/' . $item); $this->paths->add('url.' . $key, $apps_url . '/' . $this->name . '/' . $item); } } // Add apps base dir and url to app config $this->paths->add('dir.app', $dir); $this->paths->add('url.app', $apps_url . '/' . $this->name); }
php
protected function initPaths(array $exclude_dirs = []) { $apps_dir = $this->core->config->get('Core', 'dir.apps'); $apps_url = $this->core->config->get('Core', 'url.apps'); // Set path property which can be used on including additional app files like settings, routes, config etc $dir = $this->getDir(); // Get directory path of app $scanned_directory = array_diff(scandir($dir), array( '..', '.' )); $this->paths = new Paths(); $dir = $this->getDir(); $string = new CamelCase(''); foreach ($scanned_directory as $item) { if (is_dir($dir . '/' . $item) && !in_array($item, $exclude_dirs)) { $string->setString($item); $key = $string->uncamelize(); $this->paths->add('dir.' . $key, $dir . '/' . $item); $this->paths->add('url.' . $key, $apps_url . '/' . $this->name . '/' . $item); } } // Add apps base dir and url to app config $this->paths->add('dir.app', $dir); $this->paths->add('url.app', $apps_url . '/' . $this->name); }
[ "protected", "function", "initPaths", "(", "array", "$", "exclude_dirs", "=", "[", "]", ")", "{", "$", "apps_dir", "=", "$", "this", "->", "core", "->", "config", "->", "get", "(", "'Core'", ",", "'dir.apps'", ")", ";", "$", "apps_url", "=", "$", "this", "->", "core", "->", "config", "->", "get", "(", "'Core'", ",", "'url.apps'", ")", ";", "// Set path property which can be used on including additional app files like settings, routes, config etc", "$", "dir", "=", "$", "this", "->", "getDir", "(", ")", ";", "// Get directory path of app", "$", "scanned_directory", "=", "array_diff", "(", "scandir", "(", "$", "dir", ")", ",", "array", "(", "'..'", ",", "'.'", ")", ")", ";", "$", "this", "->", "paths", "=", "new", "Paths", "(", ")", ";", "$", "dir", "=", "$", "this", "->", "getDir", "(", ")", ";", "$", "string", "=", "new", "CamelCase", "(", "''", ")", ";", "foreach", "(", "$", "scanned_directory", "as", "$", "item", ")", "{", "if", "(", "is_dir", "(", "$", "dir", ".", "'/'", ".", "$", "item", ")", "&&", "!", "in_array", "(", "$", "item", ",", "$", "exclude_dirs", ")", ")", "{", "$", "string", "->", "setString", "(", "$", "item", ")", ";", "$", "key", "=", "$", "string", "->", "uncamelize", "(", ")", ";", "$", "this", "->", "paths", "->", "add", "(", "'dir.'", ".", "$", "key", ",", "$", "dir", ".", "'/'", ".", "$", "item", ")", ";", "$", "this", "->", "paths", "->", "add", "(", "'url.'", ".", "$", "key", ",", "$", "apps_url", ".", "'/'", ".", "$", "this", "->", "name", ".", "'/'", ".", "$", "item", ")", ";", "}", "}", "// Add apps base dir and url to app config", "$", "this", "->", "paths", "->", "add", "(", "'dir.app'", ",", "$", "dir", ")", ";", "$", "this", "->", "paths", "->", "add", "(", "'url.app'", ",", "$", "apps_url", ".", "'/'", ".", "$", "this", "->", "name", ")", ";", "}" ]
Initializes the apps paths by creating the paths and writing them into the apps config. @param array $exclude_dirs Optional list of directories to skip
[ "Initializes", "the", "apps", "paths", "by", "creating", "the", "paths", "and", "writing", "them", "into", "the", "apps", "config", "." ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L247-L282
1,138
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.initPermissions
protected function initPermissions() { if (isset($this->settings) && $this->settings->exists('permissions') && !self::$init_stages[$this->name]['permissions']) { $permissions = [ 'admin' ]; if ($this->settings->exists('config')) { $permissions[] = 'config'; } $permissions = array_merge($permissions, $this->settings->get('permissions')); $this->permissions = new Permissions(); $this->permissions->set($permissions); // Set flat that permission init is done self::$init_stages[$this->name]['perms'] = true; } }
php
protected function initPermissions() { if (isset($this->settings) && $this->settings->exists('permissions') && !self::$init_stages[$this->name]['permissions']) { $permissions = [ 'admin' ]; if ($this->settings->exists('config')) { $permissions[] = 'config'; } $permissions = array_merge($permissions, $this->settings->get('permissions')); $this->permissions = new Permissions(); $this->permissions->set($permissions); // Set flat that permission init is done self::$init_stages[$this->name]['perms'] = true; } }
[ "protected", "function", "initPermissions", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "settings", ")", "&&", "$", "this", "->", "settings", "->", "exists", "(", "'permissions'", ")", "&&", "!", "self", "::", "$", "init_stages", "[", "$", "this", "->", "name", "]", "[", "'permissions'", "]", ")", "{", "$", "permissions", "=", "[", "'admin'", "]", ";", "if", "(", "$", "this", "->", "settings", "->", "exists", "(", "'config'", ")", ")", "{", "$", "permissions", "[", "]", "=", "'config'", ";", "}", "$", "permissions", "=", "array_merge", "(", "$", "permissions", ",", "$", "this", "->", "settings", "->", "get", "(", "'permissions'", ")", ")", ";", "$", "this", "->", "permissions", "=", "new", "Permissions", "(", ")", ";", "$", "this", "->", "permissions", "->", "set", "(", "$", "permissions", ")", ";", "// Set flat that permission init is done", "self", "::", "$", "init_stages", "[", "$", "this", "->", "name", "]", "[", "'perms'", "]", "=", "true", ";", "}", "}" ]
Inits apps permissions by addind default values for admin and for config if confix exists
[ "Inits", "apps", "permissions", "by", "addind", "default", "values", "for", "admin", "and", "for", "config", "if", "confix", "exists" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L391-L411
1,139
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.MVCFactory
private function MVCFactory(string $name, string $type, $arguments = null) { // Here we make sure that CSS and JS will correctly and only once be initiated! if (!in_array($this->name, self::$init_done)) { // Init css and js only on non ajax requests if (!$this->core->router->isAjax()) { $this->initCss(); $this->initJs(); } // Store our apps name to be initiated self::$init_done[] = $this->name; } $string = new CamelCase($name); $name = $string->camelize($name); // Create classname of component to create $class = $this->getNamespace() . '\\' . $type . '\\' . $name . $type; // By default each MVC component constructor needs at least a name and this app object as argument $args = [ $name, $this ]; // Add additional arguments if (isset($arguments)) { if (!is_array($arguments)) { $arguments = (array) $arguments; } foreach ($arguments as $arg) { $args[] = $arg; } } $classfile = new Classfile($class); if (!$classfile->exists()) { return false; } $object = $this->core->di->instance($class, $args); switch ($type) { case 'Controller': $object->model = $this->getModel($name); break; } return $object; }
php
private function MVCFactory(string $name, string $type, $arguments = null) { // Here we make sure that CSS and JS will correctly and only once be initiated! if (!in_array($this->name, self::$init_done)) { // Init css and js only on non ajax requests if (!$this->core->router->isAjax()) { $this->initCss(); $this->initJs(); } // Store our apps name to be initiated self::$init_done[] = $this->name; } $string = new CamelCase($name); $name = $string->camelize($name); // Create classname of component to create $class = $this->getNamespace() . '\\' . $type . '\\' . $name . $type; // By default each MVC component constructor needs at least a name and this app object as argument $args = [ $name, $this ]; // Add additional arguments if (isset($arguments)) { if (!is_array($arguments)) { $arguments = (array) $arguments; } foreach ($arguments as $arg) { $args[] = $arg; } } $classfile = new Classfile($class); if (!$classfile->exists()) { return false; } $object = $this->core->di->instance($class, $args); switch ($type) { case 'Controller': $object->model = $this->getModel($name); break; } return $object; }
[ "private", "function", "MVCFactory", "(", "string", "$", "name", ",", "string", "$", "type", ",", "$", "arguments", "=", "null", ")", "{", "// Here we make sure that CSS and JS will correctly and only once be initiated!", "if", "(", "!", "in_array", "(", "$", "this", "->", "name", ",", "self", "::", "$", "init_done", ")", ")", "{", "// Init css and js only on non ajax requests", "if", "(", "!", "$", "this", "->", "core", "->", "router", "->", "isAjax", "(", ")", ")", "{", "$", "this", "->", "initCss", "(", ")", ";", "$", "this", "->", "initJs", "(", ")", ";", "}", "// Store our apps name to be initiated", "self", "::", "$", "init_done", "[", "]", "=", "$", "this", "->", "name", ";", "}", "$", "string", "=", "new", "CamelCase", "(", "$", "name", ")", ";", "$", "name", "=", "$", "string", "->", "camelize", "(", "$", "name", ")", ";", "// Create classname of component to create", "$", "class", "=", "$", "this", "->", "getNamespace", "(", ")", ".", "'\\\\'", ".", "$", "type", ".", "'\\\\'", ".", "$", "name", ".", "$", "type", ";", "// By default each MVC component constructor needs at least a name and this app object as argument", "$", "args", "=", "[", "$", "name", ",", "$", "this", "]", ";", "// Add additional arguments", "if", "(", "isset", "(", "$", "arguments", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "arguments", ")", ")", "{", "$", "arguments", "=", "(", "array", ")", "$", "arguments", ";", "}", "foreach", "(", "$", "arguments", "as", "$", "arg", ")", "{", "$", "args", "[", "]", "=", "$", "arg", ";", "}", "}", "$", "classfile", "=", "new", "Classfile", "(", "$", "class", ")", ";", "if", "(", "!", "$", "classfile", "->", "exists", "(", ")", ")", "{", "return", "false", ";", "}", "$", "object", "=", "$", "this", "->", "core", "->", "di", "->", "instance", "(", "$", "class", ",", "$", "args", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'Controller'", ":", "$", "object", "->", "model", "=", "$", "this", "->", "getModel", "(", "$", "name", ")", ";", "break", ";", "}", "return", "$", "object", ";", "}" ]
Hidden method to factory mvc components like models, views or controllers @param string $name Components name @param string $type Components type @param mixed $arguments Optional arguments to be passed into the object to create @return Model|View|Controller
[ "Hidden", "method", "to", "factory", "mvc", "components", "like", "models", "views", "or", "controllers" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L471-L524
1,140
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.getComponentsName
private function getComponentsName(): string { $dt = debug_backtrace(); $parts = array_reverse(explode('\\', $dt[2]['class'])); $strip = [ 'Controller', 'Model', 'View' ]; return str_replace($strip, '', $parts[0]); }
php
private function getComponentsName(): string { $dt = debug_backtrace(); $parts = array_reverse(explode('\\', $dt[2]['class'])); $strip = [ 'Controller', 'Model', 'View' ]; return str_replace($strip, '', $parts[0]); }
[ "private", "function", "getComponentsName", "(", ")", ":", "string", "{", "$", "dt", "=", "debug_backtrace", "(", ")", ";", "$", "parts", "=", "array_reverse", "(", "explode", "(", "'\\\\'", ",", "$", "dt", "[", "2", "]", "[", "'class'", "]", ")", ")", ";", "$", "strip", "=", "[", "'Controller'", ",", "'Model'", ",", "'View'", "]", ";", "return", "str_replace", "(", "$", "strip", ",", "''", ",", "$", "parts", "[", "0", "]", ")", ";", "}" ]
Autodiscovery of the components name @return string
[ "Autodiscovery", "of", "the", "components", "name" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L531-L542
1,141
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.getModel
public function getModel(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } // Create a model instance from a different app? $model = $this->MVCFactory($name, 'Model'); return $model; }
php
public function getModel(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } // Create a model instance from a different app? $model = $this->MVCFactory($name, 'Model'); return $model; }
[ "public", "function", "getModel", "(", "string", "$", "name", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getComponentsName", "(", ")", ";", "}", "// Create a model instance from a different app?", "$", "model", "=", "$", "this", "->", "MVCFactory", "(", "$", "name", ",", "'Model'", ")", ";", "return", "$", "model", ";", "}" ]
Creates an app related model object form this or a different app @param string $name The models name @param string $app_name Name of a different app to get the model from @return Model
[ "Creates", "an", "app", "related", "model", "object", "form", "this", "or", "a", "different", "app" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L554-L564
1,142
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.getController
public function getController(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } $controller = $this->MVCFactory($name, 'Controller'); return $controller; }
php
public function getController(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } $controller = $this->MVCFactory($name, 'Controller'); return $controller; }
[ "public", "function", "getController", "(", "string", "$", "name", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getComponentsName", "(", ")", ";", "}", "$", "controller", "=", "$", "this", "->", "MVCFactory", "(", "$", "name", ",", "'Controller'", ")", ";", "return", "$", "controller", ";", "}" ]
Creates an app related controller object @param string $name @return Controller
[ "Creates", "an", "app", "related", "controller", "object" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L573-L582
1,143
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.getView
public function getView(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } $view = $this->MVCFactory($name, 'View'); return $view; }
php
public function getView(string $name = '') { if (empty($name)) { $name = $this->getComponentsName(); } $view = $this->MVCFactory($name, 'View'); return $view; }
[ "public", "function", "getView", "(", "string", "$", "name", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getComponentsName", "(", ")", ";", "}", "$", "view", "=", "$", "this", "->", "MVCFactory", "(", "$", "name", ",", "'View'", ")", ";", "return", "$", "view", ";", "}" ]
Creates an app related view object @param string $name @return View
[ "Creates", "an", "app", "related", "view", "object" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L591-L600
1,144
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.getName
public function getName(bool $uncamelize = false) { if ($uncamelize == true) { $string = new CamelCase($this->name); return $string->uncamelize(); } else { return $this->name; } }
php
public function getName(bool $uncamelize = false) { if ($uncamelize == true) { $string = new CamelCase($this->name); return $string->uncamelize(); } else { return $this->name; } }
[ "public", "function", "getName", "(", "bool", "$", "uncamelize", "=", "false", ")", "{", "if", "(", "$", "uncamelize", "==", "true", ")", "{", "$", "string", "=", "new", "CamelCase", "(", "$", "this", "->", "name", ")", ";", "return", "$", "string", "->", "uncamelize", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "name", ";", "}", "}" ]
Returns the name of this app. @param bool $uncamelize Set this flag to true to get the apps name in an uncamelized format @return string
[ "Returns", "the", "name", "of", "this", "app", "." ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L695-L704
1,145
tekkla/core-framework
Core/Framework/Amvc/App/AbstractApp.php
AbstractApp.url
public function url(string $name, array $params = []): string { return $this->core->router->generate($name, $params); }
php
public function url(string $name, array $params = []): string { return $this->core->router->generate($name, $params); }
[ "public", "function", "url", "(", "string", "$", "name", ",", "array", "$", "params", "=", "[", "]", ")", ":", "string", "{", "return", "$", "this", "->", "core", "->", "router", "->", "generate", "(", "$", "name", ",", "$", "params", ")", ";", "}" ]
Generates an url by it's name @param string $name @param array $params @return string
[ "Generates", "an", "url", "by", "it", "s", "name" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AbstractApp.php#L724-L727
1,146
Dhii/data-state-abstract
src/TransitionAwareTrait.php
TransitionAwareTrait._setTransition
protected function _setTransition($transition) { $this->transition = ($transition === null) ? null : $this->_normalizeStringable($transition); }
php
protected function _setTransition($transition) { $this->transition = ($transition === null) ? null : $this->_normalizeStringable($transition); }
[ "protected", "function", "_setTransition", "(", "$", "transition", ")", "{", "$", "this", "->", "transition", "=", "(", "$", "transition", "===", "null", ")", "?", "null", ":", "$", "this", "->", "_normalizeStringable", "(", "$", "transition", ")", ";", "}" ]
Sets the transition for with this instance. @since [*next-version*] @param string|Stringable|null $transition The transition.
[ "Sets", "the", "transition", "for", "with", "this", "instance", "." ]
c335c37a939861659e657b995cfc657bb3bb2733
https://github.com/Dhii/data-state-abstract/blob/c335c37a939861659e657b995cfc657bb3bb2733/src/TransitionAwareTrait.php#L43-L48
1,147
ManifestWebDesign/dabl-adapter
src/DBOracle.php
DBOracle.convertTimeZone
function convertTimeZone($date, $to_tz, $from_tz = null) { throw new RuntimeException('Not implemented!'); if ($to_tz instanceof DateTimeZone) { $to_tz = $to_tz->getName(); } if ($from_tz instanceof DateTimeZone) { $from_tz = $from_tz->getName(); } return "NEW_TIME($date, '$from_tz', '$to_tz')"; }
php
function convertTimeZone($date, $to_tz, $from_tz = null) { throw new RuntimeException('Not implemented!'); if ($to_tz instanceof DateTimeZone) { $to_tz = $to_tz->getName(); } if ($from_tz instanceof DateTimeZone) { $from_tz = $from_tz->getName(); } return "NEW_TIME($date, '$from_tz', '$to_tz')"; }
[ "function", "convertTimeZone", "(", "$", "date", ",", "$", "to_tz", ",", "$", "from_tz", "=", "null", ")", "{", "throw", "new", "RuntimeException", "(", "'Not implemented!'", ")", ";", "if", "(", "$", "to_tz", "instanceof", "DateTimeZone", ")", "{", "$", "to_tz", "=", "$", "to_tz", "->", "getName", "(", ")", ";", "}", "if", "(", "$", "from_tz", "instanceof", "DateTimeZone", ")", "{", "$", "from_tz", "=", "$", "from_tz", "->", "getName", "(", ")", ";", "}", "return", "\"NEW_TIME($date, '$from_tz', '$to_tz')\"", ";", "}" ]
Returns SQL which converts the date value to its value in the target timezone @param string $date SQL column expression @param string|DateTimeZone $to_tz DateTimeZone or timezone id @param string|DateTimeZone $from_tz DateTimeZone or timezone id @return string
[ "Returns", "SQL", "which", "converts", "the", "date", "value", "to", "its", "value", "in", "the", "target", "timezone" ]
98579ed23bec832d764e762ee2f93f0a88ef9cd3
https://github.com/ManifestWebDesign/dabl-adapter/blob/98579ed23bec832d764e762ee2f93f0a88ef9cd3/src/DBOracle.php#L65-L76
1,148
alfredoem/ragnarok
app/Ragnarok/Soul/RagnarokCurlResponse.php
RagnarokCurlResponse.resolve
public function resolve($curl, $response) { $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ( curl_errno($curl) ) { $this->fill(false, $http_status, curl_error($curl), []); } else { if ($http_status == 200) { $res = json_decode(EncryptAes::dencrypt($response)); $this->fill($res->success, $http_status, curl_error($curl), $res); } else { $this->fill(false, $http_status, curl_error($curl), []); } } return $this; }
php
public function resolve($curl, $response) { $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ( curl_errno($curl) ) { $this->fill(false, $http_status, curl_error($curl), []); } else { if ($http_status == 200) { $res = json_decode(EncryptAes::dencrypt($response)); $this->fill($res->success, $http_status, curl_error($curl), $res); } else { $this->fill(false, $http_status, curl_error($curl), []); } } return $this; }
[ "public", "function", "resolve", "(", "$", "curl", ",", "$", "response", ")", "{", "$", "http_status", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HTTP_CODE", ")", ";", "if", "(", "curl_errno", "(", "$", "curl", ")", ")", "{", "$", "this", "->", "fill", "(", "false", ",", "$", "http_status", ",", "curl_error", "(", "$", "curl", ")", ",", "[", "]", ")", ";", "}", "else", "{", "if", "(", "$", "http_status", "==", "200", ")", "{", "$", "res", "=", "json_decode", "(", "EncryptAes", "::", "dencrypt", "(", "$", "response", ")", ")", ";", "$", "this", "->", "fill", "(", "$", "res", "->", "success", ",", "$", "http_status", ",", "curl_error", "(", "$", "curl", ")", ",", "$", "res", ")", ";", "}", "else", "{", "$", "this", "->", "fill", "(", "false", ",", "$", "http_status", ",", "curl_error", "(", "$", "curl", ")", ",", "[", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Handle the curl response @param $curl @param $response @return $this
[ "Handle", "the", "curl", "response" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/RagnarokCurlResponse.php#L20-L44
1,149
alfredoem/ragnarok
app/Ragnarok/Soul/RagnarokCurlResponse.php
RagnarokCurlResponse.fill
public function fill($success, $statusCode, $statusText, $response) { $this->success = $success; $this->statusCode = $statusCode; $this->statusText = $statusText; $this->response = $response; }
php
public function fill($success, $statusCode, $statusText, $response) { $this->success = $success; $this->statusCode = $statusCode; $this->statusText = $statusText; $this->response = $response; }
[ "public", "function", "fill", "(", "$", "success", ",", "$", "statusCode", ",", "$", "statusText", ",", "$", "response", ")", "{", "$", "this", "->", "success", "=", "$", "success", ";", "$", "this", "->", "statusCode", "=", "$", "statusCode", ";", "$", "this", "->", "statusText", "=", "$", "statusText", ";", "$", "this", "->", "response", "=", "$", "response", ";", "}" ]
Fill the CurlResponse attributes @param $success @param $statusCode @param $statusText @param $response
[ "Fill", "the", "CurlResponse", "attributes" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/RagnarokCurlResponse.php#L53-L59
1,150
zepi/turbo-base
Zepi/Web/AccessControl/src/Entity/User.php
User.comparePasswords
public function comparePasswords($password) { $passwordSalted = $this->saltPassword($password); if (password_verify($passwordSalted, $this->privateKey)) { return true; } return false; }
php
public function comparePasswords($password) { $passwordSalted = $this->saltPassword($password); if (password_verify($passwordSalted, $this->privateKey)) { return true; } return false; }
[ "public", "function", "comparePasswords", "(", "$", "password", ")", "{", "$", "passwordSalted", "=", "$", "this", "->", "saltPassword", "(", "$", "password", ")", ";", "if", "(", "password_verify", "(", "$", "passwordSalted", ",", "$", "this", "->", "privateKey", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Compares the given password from the login form with the saved one. @access public @param string $password @return boolean
[ "Compares", "the", "given", "password", "from", "the", "login", "form", "with", "the", "saved", "one", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Entity/User.php#L79-L87
1,151
zepi/turbo-base
Zepi/Web/AccessControl/src/Entity/User.php
User.encodePassword
protected function encodePassword($password) { $passwordSalted = $this->saltPassword($password); $passwordEncoded = password_hash($passwordSalted, PASSWORD_DEFAULT); return $passwordEncoded; }
php
protected function encodePassword($password) { $passwordSalted = $this->saltPassword($password); $passwordEncoded = password_hash($passwordSalted, PASSWORD_DEFAULT); return $passwordEncoded; }
[ "protected", "function", "encodePassword", "(", "$", "password", ")", "{", "$", "passwordSalted", "=", "$", "this", "->", "saltPassword", "(", "$", "password", ")", ";", "$", "passwordEncoded", "=", "password_hash", "(", "$", "passwordSalted", ",", "PASSWORD_DEFAULT", ")", ";", "return", "$", "passwordEncoded", ";", "}" ]
Encodes the given plain password @access protected @param string $password @return string
[ "Encodes", "the", "given", "plain", "password" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Entity/User.php#L109-L115
1,152
zepi/turbo-base
Zepi/Web/AccessControl/src/Entity/User.php
User.saltPassword
protected function saltPassword($password) { if (isset($this->metaData['salt'])) { $salt = $this->metaData['salt']; } else { $salt = $this->generateSalt(); } return $salt . $password; }
php
protected function saltPassword($password) { if (isset($this->metaData['salt'])) { $salt = $this->metaData['salt']; } else { $salt = $this->generateSalt(); } return $salt . $password; }
[ "protected", "function", "saltPassword", "(", "$", "password", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "metaData", "[", "'salt'", "]", ")", ")", "{", "$", "salt", "=", "$", "this", "->", "metaData", "[", "'salt'", "]", ";", "}", "else", "{", "$", "salt", "=", "$", "this", "->", "generateSalt", "(", ")", ";", "}", "return", "$", "salt", ".", "$", "password", ";", "}" ]
Returns the salted password @access protected @param string $password @return string
[ "Returns", "the", "salted", "password" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Entity/User.php#L124-L133
1,153
dlabas/DlcDoctrine
src/DlcDoctrine/Service/Setup.php
Setup.getDbConnectionCmd
public function getDbConnectionCmd() { $dbParams = $this->getDbConnectionParams(); $dbConnectionCmd = 'mysql -u ' . $dbParams['user'] . ' -h ' . $dbParams['host'] . ' -P ' . $dbParams['port']; if (strlen($dbParams['password']) > 0) { $dbConnectionCmd .= ' -p"' . $dbParams['password'] . '"'; } return $dbConnectionCmd; }
php
public function getDbConnectionCmd() { $dbParams = $this->getDbConnectionParams(); $dbConnectionCmd = 'mysql -u ' . $dbParams['user'] . ' -h ' . $dbParams['host'] . ' -P ' . $dbParams['port']; if (strlen($dbParams['password']) > 0) { $dbConnectionCmd .= ' -p"' . $dbParams['password'] . '"'; } return $dbConnectionCmd; }
[ "public", "function", "getDbConnectionCmd", "(", ")", "{", "$", "dbParams", "=", "$", "this", "->", "getDbConnectionParams", "(", ")", ";", "$", "dbConnectionCmd", "=", "'mysql -u '", ".", "$", "dbParams", "[", "'user'", "]", ".", "' -h '", ".", "$", "dbParams", "[", "'host'", "]", ".", "' -P '", ".", "$", "dbParams", "[", "'port'", "]", ";", "if", "(", "strlen", "(", "$", "dbParams", "[", "'password'", "]", ")", ">", "0", ")", "{", "$", "dbConnectionCmd", ".=", "' -p\"'", ".", "$", "dbParams", "[", "'password'", "]", ".", "'\"'", ";", "}", "return", "$", "dbConnectionCmd", ";", "}" ]
Returns the mysql connection command @return string
[ "Returns", "the", "mysql", "connection", "command" ]
1e754c208197e9aa7a9d58efcc726e109aaa6edf
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Service/Setup.php#L27-L40
1,154
fsi-open/acl
lib/FSi/Component/ACL/ACL.php
ACL.isAllowed
public function isAllowed(RoleInterface $role, ResourceInterface $resource, PermissionInterface $permission, array $params = array()) { $roleId = spl_object_hash($role); $resourceId = spl_object_hash($resource); $permissionId = spl_object_hash($permission); if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf( " Start checking if role %s (class: %s) has permission %s (class: %s) to resource %s (class: %s)", $this->stringify($role), get_class($role), $this->stringify($permission), get_class($permission), $this->stringify($resource), get_class($resource) ), $params ); } $allowed = $this->searchACEs($roleId, $resourceId, $permissionId, $params, 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($roleId, $resourceId, $permissionId, $params, 1); } if (!isset($allowed)) { $allowed = $this->searchParentRoleACEs($roleId, $resourceId, $permissionId, $params, 1); } if (isset($allowed)) { return $allowed; } if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf(" Access denied because no ACE has taken any decision", $this->stringify($role), $this->stringify($permission), $this->stringify($resource) )); } return false; }
php
public function isAllowed(RoleInterface $role, ResourceInterface $resource, PermissionInterface $permission, array $params = array()) { $roleId = spl_object_hash($role); $resourceId = spl_object_hash($resource); $permissionId = spl_object_hash($permission); if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf( " Start checking if role %s (class: %s) has permission %s (class: %s) to resource %s (class: %s)", $this->stringify($role), get_class($role), $this->stringify($permission), get_class($permission), $this->stringify($resource), get_class($resource) ), $params ); } $allowed = $this->searchACEs($roleId, $resourceId, $permissionId, $params, 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($roleId, $resourceId, $permissionId, $params, 1); } if (!isset($allowed)) { $allowed = $this->searchParentRoleACEs($roleId, $resourceId, $permissionId, $params, 1); } if (isset($allowed)) { return $allowed; } if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf(" Access denied because no ACE has taken any decision", $this->stringify($role), $this->stringify($permission), $this->stringify($resource) )); } return false; }
[ "public", "function", "isAllowed", "(", "RoleInterface", "$", "role", ",", "ResourceInterface", "$", "resource", ",", "PermissionInterface", "$", "permission", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "roleId", "=", "spl_object_hash", "(", "$", "role", ")", ";", "$", "resourceId", "=", "spl_object_hash", "(", "$", "resource", ")", ";", "$", "permissionId", "=", "spl_object_hash", "(", "$", "permission", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "Logger", "::", "INFO", ",", "sprintf", "(", "\" Start checking if role %s (class: %s) has permission %s (class: %s) to resource %s (class: %s)\"", ",", "$", "this", "->", "stringify", "(", "$", "role", ")", ",", "get_class", "(", "$", "role", ")", ",", "$", "this", "->", "stringify", "(", "$", "permission", ")", ",", "get_class", "(", "$", "permission", ")", ",", "$", "this", "->", "stringify", "(", "$", "resource", ")", ",", "get_class", "(", "$", "resource", ")", ")", ",", "$", "params", ")", ";", "}", "$", "allowed", "=", "$", "this", "->", "searchACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "1", ")", ";", "if", "(", "!", "isset", "(", "$", "allowed", ")", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchParentResourceACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "allowed", ")", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchParentRoleACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "1", ")", ";", "}", "if", "(", "isset", "(", "$", "allowed", ")", ")", "{", "return", "$", "allowed", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "Logger", "::", "INFO", ",", "sprintf", "(", "\" Access denied because no ACE has taken any decision\"", ",", "$", "this", "->", "stringify", "(", "$", "role", ")", ",", "$", "this", "->", "stringify", "(", "$", "permission", ")", ",", "$", "this", "->", "stringify", "(", "$", "resource", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Check access right to the specified permission of the specified resource for the specified role. This method searches ACEs directly associated with specified params. If this gives no results (grant or revoke), then it searches ACEs up in the hierarchy tree of resources starting from the specified one. If again this gives no results, then it searches ACEs up in the hierarchy of roles starting from specified one. If none results are found then false is returned so the access is revoked. @param RoleInterface $role @param ResourceInterface $resource @param PermissionInterface $permission @param array $params @return bool
[ "Check", "access", "right", "to", "the", "specified", "permission", "of", "the", "specified", "resource", "for", "the", "specified", "role", "." ]
04b81a009b0589aaf8f63e1bc34854e3df056b3d
https://github.com/fsi-open/acl/blob/04b81a009b0589aaf8f63e1bc34854e3df056b3d/lib/FSi/Component/ACL/ACL.php#L452-L490
1,155
fsi-open/acl
lib/FSi/Component/ACL/ACL.php
ACL.searchParentRoleACEs
protected function searchParentRoleACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { $allowedAny = null; if (isset($this->rolesParents[$roleId]) && isset($this->resources[$resourceId]) && isset($this->permissions[$permissionId])) { if (isset($this->logger)) { $this->logger->addRecord(Logger::DEBUG, sprintf("%sChecking if any parent role has specified permission to specified resource", str_repeat(' ', $level) )); } foreach ($this->rolesParents[$roleId] as $parentRoleId => $parentRole) { $allowed = $this->searchACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); } if (!isset($allowed)) { $allowed = $this->searchParentRoleACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); } if (isset($allowed)) { if (!$allowed) { return $allowed; } else { $allowedAny = true; } } } } return $allowedAny; }
php
protected function searchParentRoleACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { $allowedAny = null; if (isset($this->rolesParents[$roleId]) && isset($this->resources[$resourceId]) && isset($this->permissions[$permissionId])) { if (isset($this->logger)) { $this->logger->addRecord(Logger::DEBUG, sprintf("%sChecking if any parent role has specified permission to specified resource", str_repeat(' ', $level) )); } foreach ($this->rolesParents[$roleId] as $parentRoleId => $parentRole) { $allowed = $this->searchACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); } if (!isset($allowed)) { $allowed = $this->searchParentRoleACEs($parentRoleId, $resourceId, $permissionId, $params, $level + 1); } if (isset($allowed)) { if (!$allowed) { return $allowed; } else { $allowedAny = true; } } } } return $allowedAny; }
[ "protected", "function", "searchParentRoleACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "level", "=", "0", ")", "{", "$", "allowedAny", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "rolesParents", "[", "$", "roleId", "]", ")", "&&", "isset", "(", "$", "this", "->", "resources", "[", "$", "resourceId", "]", ")", "&&", "isset", "(", "$", "this", "->", "permissions", "[", "$", "permissionId", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "Logger", "::", "DEBUG", ",", "sprintf", "(", "\"%sChecking if any parent role has specified permission to specified resource\"", ",", "str_repeat", "(", "' '", ",", "$", "level", ")", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "rolesParents", "[", "$", "roleId", "]", "as", "$", "parentRoleId", "=>", "$", "parentRole", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchACEs", "(", "$", "parentRoleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "$", "level", "+", "1", ")", ";", "if", "(", "!", "isset", "(", "$", "allowed", ")", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchParentResourceACEs", "(", "$", "parentRoleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "$", "level", "+", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "allowed", ")", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchParentRoleACEs", "(", "$", "parentRoleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "$", "params", ",", "$", "level", "+", "1", ")", ";", "}", "if", "(", "isset", "(", "$", "allowed", ")", ")", "{", "if", "(", "!", "$", "allowed", ")", "{", "return", "$", "allowed", ";", "}", "else", "{", "$", "allowedAny", "=", "true", ";", "}", "}", "}", "}", "return", "$", "allowedAny", ";", "}" ]
Search ACEs associated with parent roles of specified role for pemissions granted to the specified resource. If any of the parent roles has explicitly revoked access right to the specified resource then this method returns false. If any of parent roles has explicitly granted access right to the specified resource and none of them has it revoked then this method returns true. Otherwise this method returns null. @param string $roleId @param string $resourceId @param string $permissionId @param array $params @return bool|null
[ "Search", "ACEs", "associated", "with", "parent", "roles", "of", "specified", "role", "for", "pemissions", "granted", "to", "the", "specified", "resource", "." ]
04b81a009b0589aaf8f63e1bc34854e3df056b3d
https://github.com/fsi-open/acl/blob/04b81a009b0589aaf8f63e1bc34854e3df056b3d/lib/FSi/Component/ACL/ACL.php#L527-L554
1,156
fsi-open/acl
lib/FSi/Component/ACL/ACL.php
ACL.searchParentResourceACEs
protected function searchParentResourceACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { $allowedAny = null; if (isset($this->resourcesParents[$resourceId]) && isset($this->roles[$roleId]) && isset($this->permissions[$permissionId])) { if (isset($this->logger)) { $this->logger->addRecord(Logger::DEBUG, sprintf("%sChecking if specified role has specified permission to any parent resource", str_repeat(' ', $level) )); } foreach ($this->resourcesParents[$resourceId] as $parentResourceId => $parentResource) { $allowed = $this->searchACEs($roleId, $parentResourceId, $permissionId, $params, $level + 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($roleId, $parentResourceId, $permissionId, $params, $level + 1); } if (isset($allowed)) { if (!$allowed) { return $allowed; } else { $allowedAny = true; } } } } return $allowedAny; }
php
protected function searchParentResourceACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { $allowedAny = null; if (isset($this->resourcesParents[$resourceId]) && isset($this->roles[$roleId]) && isset($this->permissions[$permissionId])) { if (isset($this->logger)) { $this->logger->addRecord(Logger::DEBUG, sprintf("%sChecking if specified role has specified permission to any parent resource", str_repeat(' ', $level) )); } foreach ($this->resourcesParents[$resourceId] as $parentResourceId => $parentResource) { $allowed = $this->searchACEs($roleId, $parentResourceId, $permissionId, $params, $level + 1); if (!isset($allowed)) { $allowed = $this->searchParentResourceACEs($roleId, $parentResourceId, $permissionId, $params, $level + 1); } if (isset($allowed)) { if (!$allowed) { return $allowed; } else { $allowedAny = true; } } } } return $allowedAny; }
[ "protected", "function", "searchParentResourceACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "level", "=", "0", ")", "{", "$", "allowedAny", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "resourcesParents", "[", "$", "resourceId", "]", ")", "&&", "isset", "(", "$", "this", "->", "roles", "[", "$", "roleId", "]", ")", "&&", "isset", "(", "$", "this", "->", "permissions", "[", "$", "permissionId", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "Logger", "::", "DEBUG", ",", "sprintf", "(", "\"%sChecking if specified role has specified permission to any parent resource\"", ",", "str_repeat", "(", "' '", ",", "$", "level", ")", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "resourcesParents", "[", "$", "resourceId", "]", "as", "$", "parentResourceId", "=>", "$", "parentResource", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchACEs", "(", "$", "roleId", ",", "$", "parentResourceId", ",", "$", "permissionId", ",", "$", "params", ",", "$", "level", "+", "1", ")", ";", "if", "(", "!", "isset", "(", "$", "allowed", ")", ")", "{", "$", "allowed", "=", "$", "this", "->", "searchParentResourceACEs", "(", "$", "roleId", ",", "$", "parentResourceId", ",", "$", "permissionId", ",", "$", "params", ",", "$", "level", "+", "1", ")", ";", "}", "if", "(", "isset", "(", "$", "allowed", ")", ")", "{", "if", "(", "!", "$", "allowed", ")", "{", "return", "$", "allowed", ";", "}", "else", "{", "$", "allowedAny", "=", "true", ";", "}", "}", "}", "}", "return", "$", "allowedAny", ";", "}" ]
Search ACEs associated with parent resources of specified resource for pemissions granted for the specified role. If specified role has explicitly revoked access right to any of the parent resources then this method returns false. If specified role has explicitly granted access right to any of the parent resources and has not revoked access right to any of them, then this method returns true. Otherwise this method returns null. @param string $roleId @param string $resourceId @param string $permissionId @param array $params @return bool|null
[ "Search", "ACEs", "associated", "with", "parent", "resources", "of", "specified", "resource", "for", "pemissions", "granted", "for", "the", "specified", "role", "." ]
04b81a009b0589aaf8f63e1bc34854e3df056b3d
https://github.com/fsi-open/acl/blob/04b81a009b0589aaf8f63e1bc34854e3df056b3d/lib/FSi/Component/ACL/ACL.php#L569-L593
1,157
fsi-open/acl
lib/FSi/Component/ACL/ACL.php
ACL.searchACEs
protected function searchACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { if (!isset($this->ACEs[$roleId][$resourceId][$permissionId])) { return null; } else { $allowedAny = null; foreach ($this->ACEs[$roleId][$resourceId][$permissionId] as $ace) { $allowed = $ace->isAllowed($params); if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf(" %s%s ACE (class: %s) {resource: %s (class: %s), role: %s (class: %s), permission: %s (class: %s)}", str_repeat(' ', $level), isset($allowed)?($allowed?'Access granted by':'Access denied by'):'No decision from', $ace, $this->stringify($ace->getResource()), get_class($ace->getResource()), $this->stringify($ace->getRole()), get_class($ace->getRole()), $this->stringify($this->permissions[$permissionId]), get_class($this->permissions[$permissionId]) )); } if (isset($allowed)) { if (!$allowed) { return false; } else { $allowedAny = true; } } } return $allowedAny; } }
php
protected function searchACEs($roleId, $resourceId, $permissionId, array $params = array(), $level = 0) { if (!isset($this->ACEs[$roleId][$resourceId][$permissionId])) { return null; } else { $allowedAny = null; foreach ($this->ACEs[$roleId][$resourceId][$permissionId] as $ace) { $allowed = $ace->isAllowed($params); if (isset($this->logger)) { $this->logger->addRecord(Logger::INFO, sprintf(" %s%s ACE (class: %s) {resource: %s (class: %s), role: %s (class: %s), permission: %s (class: %s)}", str_repeat(' ', $level), isset($allowed)?($allowed?'Access granted by':'Access denied by'):'No decision from', $ace, $this->stringify($ace->getResource()), get_class($ace->getResource()), $this->stringify($ace->getRole()), get_class($ace->getRole()), $this->stringify($this->permissions[$permissionId]), get_class($this->permissions[$permissionId]) )); } if (isset($allowed)) { if (!$allowed) { return false; } else { $allowedAny = true; } } } return $allowedAny; } }
[ "protected", "function", "searchACEs", "(", "$", "roleId", ",", "$", "resourceId", ",", "$", "permissionId", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "level", "=", "0", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "ACEs", "[", "$", "roleId", "]", "[", "$", "resourceId", "]", "[", "$", "permissionId", "]", ")", ")", "{", "return", "null", ";", "}", "else", "{", "$", "allowedAny", "=", "null", ";", "foreach", "(", "$", "this", "->", "ACEs", "[", "$", "roleId", "]", "[", "$", "resourceId", "]", "[", "$", "permissionId", "]", "as", "$", "ace", ")", "{", "$", "allowed", "=", "$", "ace", "->", "isAllowed", "(", "$", "params", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "logger", ")", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "Logger", "::", "INFO", ",", "sprintf", "(", "\" %s%s ACE (class: %s) {resource: %s (class: %s), role: %s (class: %s), permission: %s (class: %s)}\"", ",", "str_repeat", "(", "' '", ",", "$", "level", ")", ",", "isset", "(", "$", "allowed", ")", "?", "(", "$", "allowed", "?", "'Access granted by'", ":", "'Access denied by'", ")", ":", "'No decision from'", ",", "$", "ace", ",", "$", "this", "->", "stringify", "(", "$", "ace", "->", "getResource", "(", ")", ")", ",", "get_class", "(", "$", "ace", "->", "getResource", "(", ")", ")", ",", "$", "this", "->", "stringify", "(", "$", "ace", "->", "getRole", "(", ")", ")", ",", "get_class", "(", "$", "ace", "->", "getRole", "(", ")", ")", ",", "$", "this", "->", "stringify", "(", "$", "this", "->", "permissions", "[", "$", "permissionId", "]", ")", ",", "get_class", "(", "$", "this", "->", "permissions", "[", "$", "permissionId", "]", ")", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "allowed", ")", ")", "{", "if", "(", "!", "$", "allowed", ")", "{", "return", "false", ";", "}", "else", "{", "$", "allowedAny", "=", "true", ";", "}", "}", "}", "return", "$", "allowedAny", ";", "}", "}" ]
Search ACEs associated with specified role, resource and permission. This method returns true or false only if specified role has directly granted or revoked specified permission to specified resource. Otherwise it returns null. @param string $roleId @param string $resourceId @param string $permissionId @param array $params @return bool|null
[ "Search", "ACEs", "associated", "with", "specified", "role", "resource", "and", "permission", "." ]
04b81a009b0589aaf8f63e1bc34854e3df056b3d
https://github.com/fsi-open/acl/blob/04b81a009b0589aaf8f63e1bc34854e3df056b3d/lib/FSi/Component/ACL/ACL.php#L607-L638
1,158
zetta-code/tss-bootstrap
src/View/Helper/FlashMessenger.php
FlashMessenger.getFlashMessengerHelper
protected function getFlashMessengerHelper() { if ($this->flashMessengerHelper) { return $this->flashMessengerHelper; } if (method_exists($this->view, 'plugin')) { $this->flashMessengerHelper = $this->view->plugin(FlashMessengerHelper::class); } if (!$this->flashMessengerHelper instanceof FlashMessengerHelper) { $this->flashMessengerHelper = new FlashMessengerHelper(); } return $this->flashMessengerHelper; }
php
protected function getFlashMessengerHelper() { if ($this->flashMessengerHelper) { return $this->flashMessengerHelper; } if (method_exists($this->view, 'plugin')) { $this->flashMessengerHelper = $this->view->plugin(FlashMessengerHelper::class); } if (!$this->flashMessengerHelper instanceof FlashMessengerHelper) { $this->flashMessengerHelper = new FlashMessengerHelper(); } return $this->flashMessengerHelper; }
[ "protected", "function", "getFlashMessengerHelper", "(", ")", "{", "if", "(", "$", "this", "->", "flashMessengerHelper", ")", "{", "return", "$", "this", "->", "flashMessengerHelper", ";", "}", "if", "(", "method_exists", "(", "$", "this", "->", "view", ",", "'plugin'", ")", ")", "{", "$", "this", "->", "flashMessengerHelper", "=", "$", "this", "->", "view", "->", "plugin", "(", "FlashMessengerHelper", "::", "class", ")", ";", "}", "if", "(", "!", "$", "this", "->", "flashMessengerHelper", "instanceof", "FlashMessengerHelper", ")", "{", "$", "this", "->", "flashMessengerHelper", "=", "new", "FlashMessengerHelper", "(", ")", ";", "}", "return", "$", "this", "->", "flashMessengerHelper", ";", "}" ]
Retrieve the FlashMessenger helper @return FlashMessengerHelper
[ "Retrieve", "the", "FlashMessenger", "helper" ]
8dddfca8440ccd4e5cf645c81f732a424b78235e
https://github.com/zetta-code/tss-bootstrap/blob/8dddfca8440ccd4e5cf645c81f732a424b78235e/src/View/Helper/FlashMessenger.php#L77-L92
1,159
CatLabInteractive/Neuron
src/Neuron/Models/Observable.php
Observable.trigger
protected function trigger ($event) { $arguments = func_get_args (); array_shift ($arguments); // Check for events if (isset ($this->events[$event])) { foreach ($this->events[$event] as $call) { call_user_func_array ($call, $arguments); } } // Notify everyone foreach ($this->observing as $observer) { $observer->update (); } }
php
protected function trigger ($event) { $arguments = func_get_args (); array_shift ($arguments); // Check for events if (isset ($this->events[$event])) { foreach ($this->events[$event] as $call) { call_user_func_array ($call, $arguments); } } // Notify everyone foreach ($this->observing as $observer) { $observer->update (); } }
[ "protected", "function", "trigger", "(", "$", "event", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "arguments", ")", ";", "// Check for events", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "event", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "events", "[", "$", "event", "]", "as", "$", "call", ")", "{", "call_user_func_array", "(", "$", "call", ",", "$", "arguments", ")", ";", "}", "}", "// Notify everyone", "foreach", "(", "$", "this", "->", "observing", "as", "$", "observer", ")", "{", "$", "observer", "->", "update", "(", ")", ";", "}", "}" ]
Trigger an event, possibly with parameters. @param $event
[ "Trigger", "an", "event", "possibly", "with", "parameters", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Models/Observable.php#L34-L53
1,160
CatLabInteractive/Neuron
src/Neuron/Models/Observable.php
Observable.on
public function on ($event, callable $callback) { if (!isset ($this->events[$event])) { $this->events[$event] = array (); } $this->events[$event][] = $callback; }
php
public function on ($event, callable $callback) { if (!isset ($this->events[$event])) { $this->events[$event] = array (); } $this->events[$event][] = $callback; }
[ "public", "function", "on", "(", "$", "event", ",", "callable", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "events", "[", "$", "event", "]", ")", ")", "{", "$", "this", "->", "events", "[", "$", "event", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "events", "[", "$", "event", "]", "[", "]", "=", "$", "callback", ";", "}" ]
Listen to specific events @param $event @param callable $callback
[ "Listen", "to", "specific", "events" ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Models/Observable.php#L60-L67
1,161
budkit/budkit-framework
src/Budkit/Helper/Object.php
Object.get
public function get($property, $default = null) { //if its an array of properties; if (is_array($property)) { $values = array(); foreach ($property as $key => $prop) { if (isset($this->$prop)) { $values[$prop] = $this->$prop; } } return (!empty($values)) ? $values : $default; } if (isset($this->$property)) { return $this->$property; } return $default; }
php
public function get($property, $default = null) { //if its an array of properties; if (is_array($property)) { $values = array(); foreach ($property as $key => $prop) { if (isset($this->$prop)) { $values[$prop] = $this->$prop; } } return (!empty($values)) ? $values : $default; } if (isset($this->$property)) { return $this->$property; } return $default; }
[ "public", "function", "get", "(", "$", "property", ",", "$", "default", "=", "null", ")", "{", "//if its an array of properties;", "if", "(", "is_array", "(", "$", "property", ")", ")", "{", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "property", "as", "$", "key", "=>", "$", "prop", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "$", "prop", ")", ")", "{", "$", "values", "[", "$", "prop", "]", "=", "$", "this", "->", "$", "prop", ";", "}", "}", "return", "(", "!", "empty", "(", "$", "values", ")", ")", "?", "$", "values", ":", "$", "default", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "$", "property", ")", ")", "{", "return", "$", "this", "->", "$", "property", ";", "}", "return", "$", "default", ";", "}" ]
Get a protected object property @param string $property @param mixed $default @return mixed
[ "Get", "a", "protected", "object", "property" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Object.php#L65-L84
1,162
budkit/budkit-framework
src/Budkit/Helper/Object.php
Object.getError
final public function getError($i = null, $toString = true) { // Find the error if ($i === null) { // Default, return the last message $error = end(self::$errors); } else if (!array_key_exists($i, self::$errors)) { // If $i has been specified but does not exist, return false return false; } else { $error = self::$errors[$i]; } return $error; }
php
final public function getError($i = null, $toString = true) { // Find the error if ($i === null) { // Default, return the last message $error = end(self::$errors); } else if (!array_key_exists($i, self::$errors)) { // If $i has been specified but does not exist, return false return false; } else { $error = self::$errors[$i]; } return $error; }
[ "final", "public", "function", "getError", "(", "$", "i", "=", "null", ",", "$", "toString", "=", "true", ")", "{", "// Find the error", "if", "(", "$", "i", "===", "null", ")", "{", "// Default, return the last message", "$", "error", "=", "end", "(", "self", "::", "$", "errors", ")", ";", "}", "else", "if", "(", "!", "array_key_exists", "(", "$", "i", ",", "self", "::", "$", "errors", ")", ")", "{", "// If $i has been specified but does not exist, return false", "return", "false", ";", "}", "else", "{", "$", "error", "=", "self", "::", "$", "errors", "[", "$", "i", "]", ";", "}", "return", "$", "error", ";", "}" ]
Returns a referenced error @param type $i @param type $toString @return type
[ "Returns", "a", "referenced", "error" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Object.php#L93-L109
1,163
budkit/budkit-framework
src/Budkit/Helper/Object.php
Object.getErrorString
final public function getErrorString() { $errors = self::getErrors(); $string = '<ul>'; foreach ($errors as $error) { $string .= '<li>' . $error . '</li>'; } //An ordered lists of all errors; return $string . '</ul>'; }
php
final public function getErrorString() { $errors = self::getErrors(); $string = '<ul>'; foreach ($errors as $error) { $string .= '<li>' . $error . '</li>'; } //An ordered lists of all errors; return $string . '</ul>'; }
[ "final", "public", "function", "getErrorString", "(", ")", "{", "$", "errors", "=", "self", "::", "getErrors", "(", ")", ";", "$", "string", "=", "'<ul>'", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "string", ".=", "'<li>'", ".", "$", "error", ".", "'</li>'", ";", "}", "//An ordered lists of all errors;", "return", "$", "string", ".", "'</ul>'", ";", "}" ]
Returns the error string @return type
[ "Returns", "the", "error", "string" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Object.php#L116-L127
1,164
budkit/budkit-framework
src/Budkit/Helper/Object.php
Object.set
public function set($property, $value = null, $overwrite = false) { $previous = isset($this->$property) ? $this->$property : null; $this->$property = $value; return $previous; }
php
public function set($property, $value = null, $overwrite = false) { $previous = isset($this->$property) ? $this->$property : null; $this->$property = $value; return $previous; }
[ "public", "function", "set", "(", "$", "property", ",", "$", "value", "=", "null", ",", "$", "overwrite", "=", "false", ")", "{", "$", "previous", "=", "isset", "(", "$", "this", "->", "$", "property", ")", "?", "$", "this", "->", "$", "property", ":", "null", ";", "$", "this", "->", "$", "property", "=", "$", "value", ";", "return", "$", "previous", ";", "}" ]
Sets an object property @param type $property @param type $value @return type
[ "Sets", "an", "object", "property" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Object.php#L146-L154
1,165
budkit/budkit-framework
src/Budkit/Helper/Object.php
Object.referencedArgs
final private function referencedArgs(&$arr) { if (strnatcmp(phpversion(), '5.3') >= 0) { //Reference is required for PHP 5.3+ $refs = array(); foreach ($arr as $key => $value) $refs[] = &$arr[$key]; return $refs; } return $arr; }
php
final private function referencedArgs(&$arr) { if (strnatcmp(phpversion(), '5.3') >= 0) { //Reference is required for PHP 5.3+ $refs = array(); foreach ($arr as $key => $value) $refs[] = &$arr[$key]; return $refs; } return $arr; }
[ "final", "private", "function", "referencedArgs", "(", "&", "$", "arr", ")", "{", "if", "(", "strnatcmp", "(", "phpversion", "(", ")", ",", "'5.3'", ")", ">=", "0", ")", "{", "//Reference is required for PHP 5.3+", "$", "refs", "=", "array", "(", ")", ";", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "$", "refs", "[", "]", "=", "&", "$", "arr", "[", "$", "key", "]", ";", "return", "$", "refs", ";", "}", "return", "$", "arr", ";", "}" ]
Solution to passing data by reference, http://ca.php.net/manual/en/mysqli-stmt.bind-param.php#96770 @param type $arr @return type
[ "Solution", "to", "passing", "data", "by", "reference" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Object.php#L201-L211
1,166
konservs/brilliant.framework
libraries/Items/BItemsTree.php
BItemsTree.itemsFilterIds
public function itemsFilterIds($params){ if(empty($params['orderby'])){ $params['orderby']=$this->leftKeyName; } return parent::itemsFilterIds($params); }
php
public function itemsFilterIds($params){ if(empty($params['orderby'])){ $params['orderby']=$this->leftKeyName; } return parent::itemsFilterIds($params); }
[ "public", "function", "itemsFilterIds", "(", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "params", "[", "'orderby'", "]", ")", ")", "{", "$", "params", "[", "'orderby'", "]", "=", "$", "this", "->", "leftKeyName", ";", "}", "return", "parent", "::", "itemsFilterIds", "(", "$", "params", ")", ";", "}" ]
Filters items and return array of IDs @param $params @return array|null
[ "Filters", "items", "and", "return", "array", "of", "IDs" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsTree.php#L18-L23
1,167
konservs/brilliant.framework
libraries/Items/BItemsTree.php
BItemsTree.itemsFilterHash
public function itemsFilterHash($params){ $db=\Brilliant\BFactory::getDBO(); $itemshash=parent::itemsFilterHash($params); //Select categories only with some level if(isset($params['level'])){ $itemshash.=':level='.$params['level']; } //Select categories only with parentid=$params['parent']. if(isset($params['parent'])){ $itemshash.=':parent='.$params['parent']; } //Entire parents tree. if(isset($params['parenttree'])){ $itemid=(int)$params['parenttree']; $item=$this->itemGet($itemid); if(empty($item)){ return false; } $itemshash.=':parenttree-'.$item->lft.'-'.$item->rgt; } //Entire parents tree, second version. if((isset($params['parenttree_lft']))&&(isset($params['parenttree_rgt']))){ $lft=$params['parenttree_lft']; $rgt=$params['parenttree_rgt']; if(($lft<1)||($rgt<1)||($lft>=$rgt)){ return false; } $itemshash.=':parenttree-'.$lft.'-'.$rgt; } //Entire parents chain. if(isset($params['parentchain'])){ $itemid=(int)$params['parentchain']; $item=$this->itemGet($itemid); if(empty($item)){ return false; } $itemshash.=':parentchain-'.$item->lft.'-'.$item->rgt; } //Entire parents chain, second version. if((isset($params['parentchain_lft']))&&(isset($params['parentchain_rgt']))){ $lft=$params['parentchain_lft']; $rgt=$params['parentchain_rgt']; if(($lft<1)||($rgt<1)||($lft>=$rgt)){ return false; } $itemshash.=':parentchain-'.$lft.'-'.$rgt; } return $itemshash; }
php
public function itemsFilterHash($params){ $db=\Brilliant\BFactory::getDBO(); $itemshash=parent::itemsFilterHash($params); //Select categories only with some level if(isset($params['level'])){ $itemshash.=':level='.$params['level']; } //Select categories only with parentid=$params['parent']. if(isset($params['parent'])){ $itemshash.=':parent='.$params['parent']; } //Entire parents tree. if(isset($params['parenttree'])){ $itemid=(int)$params['parenttree']; $item=$this->itemGet($itemid); if(empty($item)){ return false; } $itemshash.=':parenttree-'.$item->lft.'-'.$item->rgt; } //Entire parents tree, second version. if((isset($params['parenttree_lft']))&&(isset($params['parenttree_rgt']))){ $lft=$params['parenttree_lft']; $rgt=$params['parenttree_rgt']; if(($lft<1)||($rgt<1)||($lft>=$rgt)){ return false; } $itemshash.=':parenttree-'.$lft.'-'.$rgt; } //Entire parents chain. if(isset($params['parentchain'])){ $itemid=(int)$params['parentchain']; $item=$this->itemGet($itemid); if(empty($item)){ return false; } $itemshash.=':parentchain-'.$item->lft.'-'.$item->rgt; } //Entire parents chain, second version. if((isset($params['parentchain_lft']))&&(isset($params['parentchain_rgt']))){ $lft=$params['parentchain_lft']; $rgt=$params['parentchain_rgt']; if(($lft<1)||($rgt<1)||($lft>=$rgt)){ return false; } $itemshash.=':parentchain-'.$lft.'-'.$rgt; } return $itemshash; }
[ "public", "function", "itemsFilterHash", "(", "$", "params", ")", "{", "$", "db", "=", "\\", "Brilliant", "\\", "BFactory", "::", "getDBO", "(", ")", ";", "$", "itemshash", "=", "parent", "::", "itemsFilterHash", "(", "$", "params", ")", ";", "//Select categories only with some level", "if", "(", "isset", "(", "$", "params", "[", "'level'", "]", ")", ")", "{", "$", "itemshash", ".=", "':level='", ".", "$", "params", "[", "'level'", "]", ";", "}", "//Select categories only with parentid=$params['parent'].", "if", "(", "isset", "(", "$", "params", "[", "'parent'", "]", ")", ")", "{", "$", "itemshash", ".=", "':parent='", ".", "$", "params", "[", "'parent'", "]", ";", "}", "//Entire parents tree. ", "if", "(", "isset", "(", "$", "params", "[", "'parenttree'", "]", ")", ")", "{", "$", "itemid", "=", "(", "int", ")", "$", "params", "[", "'parenttree'", "]", ";", "$", "item", "=", "$", "this", "->", "itemGet", "(", "$", "itemid", ")", ";", "if", "(", "empty", "(", "$", "item", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parenttree-'", ".", "$", "item", "->", "lft", ".", "'-'", ".", "$", "item", "->", "rgt", ";", "}", "//Entire parents tree, second version. ", "if", "(", "(", "isset", "(", "$", "params", "[", "'parenttree_lft'", "]", ")", ")", "&&", "(", "isset", "(", "$", "params", "[", "'parenttree_rgt'", "]", ")", ")", ")", "{", "$", "lft", "=", "$", "params", "[", "'parenttree_lft'", "]", ";", "$", "rgt", "=", "$", "params", "[", "'parenttree_rgt'", "]", ";", "if", "(", "(", "$", "lft", "<", "1", ")", "||", "(", "$", "rgt", "<", "1", ")", "||", "(", "$", "lft", ">=", "$", "rgt", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parenttree-'", ".", "$", "lft", ".", "'-'", ".", "$", "rgt", ";", "}", "//Entire parents chain. ", "if", "(", "isset", "(", "$", "params", "[", "'parentchain'", "]", ")", ")", "{", "$", "itemid", "=", "(", "int", ")", "$", "params", "[", "'parentchain'", "]", ";", "$", "item", "=", "$", "this", "->", "itemGet", "(", "$", "itemid", ")", ";", "if", "(", "empty", "(", "$", "item", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parentchain-'", ".", "$", "item", "->", "lft", ".", "'-'", ".", "$", "item", "->", "rgt", ";", "}", "//Entire parents chain, second version. ", "if", "(", "(", "isset", "(", "$", "params", "[", "'parentchain_lft'", "]", ")", ")", "&&", "(", "isset", "(", "$", "params", "[", "'parentchain_rgt'", "]", ")", ")", ")", "{", "$", "lft", "=", "$", "params", "[", "'parentchain_lft'", "]", ";", "$", "rgt", "=", "$", "params", "[", "'parentchain_rgt'", "]", ";", "if", "(", "(", "$", "lft", "<", "1", ")", "||", "(", "$", "rgt", "<", "1", ")", "||", "(", "$", "lft", ">=", "$", "rgt", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parentchain-'", ".", "$", "lft", ".", "'-'", ".", "$", "rgt", ";", "}", "return", "$", "itemshash", ";", "}" ]
News categories tree cache hash.
[ "News", "categories", "tree", "cache", "hash", "." ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsTree.php#L91-L140
1,168
konservs/brilliant.framework
libraries/Items/BItemsTree.php
BItemsTree.getSimpleTreeRecursive
public function getSimpleTreeRecursive($fields=array(),$transfields=array(),$lang='',$wh=array()){ $list=$this->getSimpleTree($fields,$transfields,$lang,$wh); if(!is_array($list)){ return array(); } $tree=array(); foreach($list as $li){ $id=(int)$li->{$this->primaryKeyName}; $ti=$li; //TODO: finish children $ti->children=array(); $tree[]=$ti; } return $tree; }
php
public function getSimpleTreeRecursive($fields=array(),$transfields=array(),$lang='',$wh=array()){ $list=$this->getSimpleTree($fields,$transfields,$lang,$wh); if(!is_array($list)){ return array(); } $tree=array(); foreach($list as $li){ $id=(int)$li->{$this->primaryKeyName}; $ti=$li; //TODO: finish children $ti->children=array(); $tree[]=$ti; } return $tree; }
[ "public", "function", "getSimpleTreeRecursive", "(", "$", "fields", "=", "array", "(", ")", ",", "$", "transfields", "=", "array", "(", ")", ",", "$", "lang", "=", "''", ",", "$", "wh", "=", "array", "(", ")", ")", "{", "$", "list", "=", "$", "this", "->", "getSimpleTree", "(", "$", "fields", ",", "$", "transfields", ",", "$", "lang", ",", "$", "wh", ")", ";", "if", "(", "!", "is_array", "(", "$", "list", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "tree", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "li", ")", "{", "$", "id", "=", "(", "int", ")", "$", "li", "->", "{", "$", "this", "->", "primaryKeyName", "}", ";", "$", "ti", "=", "$", "li", ";", "//TODO: finish children", "$", "ti", "->", "children", "=", "array", "(", ")", ";", "$", "tree", "[", "]", "=", "$", "ti", ";", "}", "return", "$", "tree", ";", "}" ]
Get recursive tree
[ "Get", "recursive", "tree" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsTree.php#L358-L372
1,169
MINISTRYGmbH/morrow-core
src/Header.php
Header.setCache
public function setCache($cachetime, $etag = true) { $this->_cachetime = $cachetime; $this->_cacheetag = $etag; }
php
public function setCache($cachetime, $etag = true) { $this->_cachetime = $cachetime; $this->_cacheetag = $etag; }
[ "public", "function", "setCache", "(", "$", "cachetime", ",", "$", "etag", "=", "true", ")", "{", "$", "this", "->", "_cachetime", "=", "$", "cachetime", ";", "$", "this", "->", "_cacheetag", "=", "$", "etag", ";", "}" ]
Sets the caching time for the current page. @param string $cachetime A string in the format of strtotime() to specify when the current page should expire. @param string $etag Set to false prevents Morrow to set an eTag header. That means the client cache cannot be unset until the Last-Modified header time expires. @return null
[ "Sets", "the", "caching", "time", "for", "the", "current", "page", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Header.php#L136-L139
1,170
MINISTRYGmbH/morrow-core
src/Header.php
Header.getAll
public function getAll($handle) { // set content type at first position so it will get overwritten by later definitions array_unshift($this->_header, 'Content-Type: text/html; charset=utf-8'); $this->_header[] = 'Vary:'; // use etag for content validation (only HTTP1.1) rewind($handle); $hash = hash_init('md5'); hash_update_stream($hash, $handle); $hash = hash_final($hash); // add all user defined headers to hash // if we change one of those we also want to see the actual view $hash = md5($hash . implode('', $this->_header)); if ($this->_cacheetag) $this->_header[] = 'ETag: '.$hash; // HTTP 1.1 if ($this->_cachetime === null) { // no caching if ($this->_cacheetag) $this->_header[] = 'Cache-Control: no-cache, must-revalidate'; else $this->_header[] = 'Cache-Control: no-store, no-cache, must-revalidate'; // to overwrite default php setting with "no-store" } else { // caching $fileexpired = strtotime($this->_cachetime); $filemaxage = $fileexpired-time(); // HTTP 1.0 $this->_header[] = 'Pragma: '; $this->_header[] = 'Expires: '.gmdate("D, d M Y H:i:s", $fileexpired) ." GMT"; // HTTP 1.1 $this->_header[] = 'Cache-Control: public, max-age='.$filemaxage; } // check for etag if (!isset($_SERVER['HTTP_CACHE_CONTROL']) || !preg_match('/max-age=0|no-cache/i', $_SERVER['HTTP_CACHE_CONTROL'])) // by-pass "not modified" on explicit reload if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $hash) { $this->_etag_is_different = false; $this->_header[] = 'HTTP/1.1 304 Not Modified'; } // set download header if (!empty($this->_filename)) { $this->_header[] = 'Content-Type: ' . $this->getMimeType($this->_filename); $this->_header[] = 'Content-Disposition: attachment; filename='.basename($this->_filename); } return $this->_header; }
php
public function getAll($handle) { // set content type at first position so it will get overwritten by later definitions array_unshift($this->_header, 'Content-Type: text/html; charset=utf-8'); $this->_header[] = 'Vary:'; // use etag for content validation (only HTTP1.1) rewind($handle); $hash = hash_init('md5'); hash_update_stream($hash, $handle); $hash = hash_final($hash); // add all user defined headers to hash // if we change one of those we also want to see the actual view $hash = md5($hash . implode('', $this->_header)); if ($this->_cacheetag) $this->_header[] = 'ETag: '.$hash; // HTTP 1.1 if ($this->_cachetime === null) { // no caching if ($this->_cacheetag) $this->_header[] = 'Cache-Control: no-cache, must-revalidate'; else $this->_header[] = 'Cache-Control: no-store, no-cache, must-revalidate'; // to overwrite default php setting with "no-store" } else { // caching $fileexpired = strtotime($this->_cachetime); $filemaxage = $fileexpired-time(); // HTTP 1.0 $this->_header[] = 'Pragma: '; $this->_header[] = 'Expires: '.gmdate("D, d M Y H:i:s", $fileexpired) ." GMT"; // HTTP 1.1 $this->_header[] = 'Cache-Control: public, max-age='.$filemaxage; } // check for etag if (!isset($_SERVER['HTTP_CACHE_CONTROL']) || !preg_match('/max-age=0|no-cache/i', $_SERVER['HTTP_CACHE_CONTROL'])) // by-pass "not modified" on explicit reload if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $hash) { $this->_etag_is_different = false; $this->_header[] = 'HTTP/1.1 304 Not Modified'; } // set download header if (!empty($this->_filename)) { $this->_header[] = 'Content-Type: ' . $this->getMimeType($this->_filename); $this->_header[] = 'Content-Disposition: attachment; filename='.basename($this->_filename); } return $this->_header; }
[ "public", "function", "getAll", "(", "$", "handle", ")", "{", "// set content type at first position so it will get overwritten by later definitions", "array_unshift", "(", "$", "this", "->", "_header", ",", "'Content-Type: text/html; charset=utf-8'", ")", ";", "$", "this", "->", "_header", "[", "]", "=", "'Vary:'", ";", "// use etag for content validation (only HTTP1.1)", "rewind", "(", "$", "handle", ")", ";", "$", "hash", "=", "hash_init", "(", "'md5'", ")", ";", "hash_update_stream", "(", "$", "hash", ",", "$", "handle", ")", ";", "$", "hash", "=", "hash_final", "(", "$", "hash", ")", ";", "// add all user defined headers to hash", "// if we change one of those we also want to see the actual view", "$", "hash", "=", "md5", "(", "$", "hash", ".", "implode", "(", "''", ",", "$", "this", "->", "_header", ")", ")", ";", "if", "(", "$", "this", "->", "_cacheetag", ")", "$", "this", "->", "_header", "[", "]", "=", "'ETag: '", ".", "$", "hash", ";", "// HTTP 1.1", "if", "(", "$", "this", "->", "_cachetime", "===", "null", ")", "{", "// no caching", "if", "(", "$", "this", "->", "_cacheetag", ")", "$", "this", "->", "_header", "[", "]", "=", "'Cache-Control: no-cache, must-revalidate'", ";", "else", "$", "this", "->", "_header", "[", "]", "=", "'Cache-Control: no-store, no-cache, must-revalidate'", ";", "// to overwrite default php setting with \"no-store\"", "}", "else", "{", "// caching", "$", "fileexpired", "=", "strtotime", "(", "$", "this", "->", "_cachetime", ")", ";", "$", "filemaxage", "=", "$", "fileexpired", "-", "time", "(", ")", ";", "// HTTP 1.0", "$", "this", "->", "_header", "[", "]", "=", "'Pragma: '", ";", "$", "this", "->", "_header", "[", "]", "=", "'Expires: '", ".", "gmdate", "(", "\"D, d M Y H:i:s\"", ",", "$", "fileexpired", ")", ".", "\" GMT\"", ";", "// HTTP 1.1", "$", "this", "->", "_header", "[", "]", "=", "'Cache-Control: public, max-age='", ".", "$", "filemaxage", ";", "}", "// check for etag", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'HTTP_CACHE_CONTROL'", "]", ")", "||", "!", "preg_match", "(", "'/max-age=0|no-cache/i'", ",", "$", "_SERVER", "[", "'HTTP_CACHE_CONTROL'", "]", ")", ")", "// by-pass \"not modified\" on explicit reload", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_IF_NONE_MATCH'", "]", ")", "&&", "$", "_SERVER", "[", "'HTTP_IF_NONE_MATCH'", "]", "==", "$", "hash", ")", "{", "$", "this", "->", "_etag_is_different", "=", "false", ";", "$", "this", "->", "_header", "[", "]", "=", "'HTTP/1.1 304 Not Modified'", ";", "}", "// set download header", "if", "(", "!", "empty", "(", "$", "this", "->", "_filename", ")", ")", "{", "$", "this", "->", "_header", "[", "]", "=", "'Content-Type: '", ".", "$", "this", "->", "getMimeType", "(", "$", "this", "->", "_filename", ")", ";", "$", "this", "->", "_header", "[", "]", "=", "'Content-Disposition: attachment; filename='", ".", "basename", "(", "$", "this", "->", "_filename", ")", ";", "}", "return", "$", "this", "->", "_header", ";", "}" ]
Returns all headers for a given content. This is internally used by the \Morrow\Core\Frontcontroller class. @param object $handle The stream handle for the generated content. @return array All headers as array.
[ "Returns", "all", "headers", "for", "a", "given", "content", ".", "This", "is", "internally", "used", "by", "the", "\\", "Morrow", "\\", "Core", "\\", "Frontcontroller", "class", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Header.php#L166-L214
1,171
mvccore/ext-view-helper-dataurl
src/MvcCore/Ext/Views/Helpers/DataUrlHelper.php
DataUrlHelper.DataUrl
public function DataUrl ($relativeOrAbsolutePath) { $currentDirFullPath = $this->view->GetCurrentViewDirectory(); $searchedPaths = []; // first - try to find file relatively from currently rendered view array_unshift($searchedPaths, $currentDirFullPath . '/' . $relativeOrAbsolutePath); if (!file_exists($searchedPaths[0])) { // second - try to find file relatively from application root array_unshift($searchedPaths, $this->appRoot . '/' . ltrim($relativeOrAbsolutePath, '/')); if (!file_exists($searchedPaths[0])) { // third - try to find file absolutely array_unshift($searchedPaths, $relativeOrAbsolutePath); if (!file_exists($searchedPaths[0])) { // throw an error at last $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \InvalidArgumentException( "[".$selfClass."] File not found in paths: '" . implode("', '", array_reverse($searchedPaths)) . "'." ); } } } // get last searched path $fileFullPath = $searchedPaths[0]; // Read image path, convert to base64 encoding $imageData = base64_encode(file_get_contents($fileFullPath)); // Format the image SRC: data:{mime};base64,{data}; $result = 'data: '.mime_content_type($fileFullPath).';base64,'.$imageData; return $result; }
php
public function DataUrl ($relativeOrAbsolutePath) { $currentDirFullPath = $this->view->GetCurrentViewDirectory(); $searchedPaths = []; // first - try to find file relatively from currently rendered view array_unshift($searchedPaths, $currentDirFullPath . '/' . $relativeOrAbsolutePath); if (!file_exists($searchedPaths[0])) { // second - try to find file relatively from application root array_unshift($searchedPaths, $this->appRoot . '/' . ltrim($relativeOrAbsolutePath, '/')); if (!file_exists($searchedPaths[0])) { // third - try to find file absolutely array_unshift($searchedPaths, $relativeOrAbsolutePath); if (!file_exists($searchedPaths[0])) { // throw an error at last $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \InvalidArgumentException( "[".$selfClass."] File not found in paths: '" . implode("', '", array_reverse($searchedPaths)) . "'." ); } } } // get last searched path $fileFullPath = $searchedPaths[0]; // Read image path, convert to base64 encoding $imageData = base64_encode(file_get_contents($fileFullPath)); // Format the image SRC: data:{mime};base64,{data}; $result = 'data: '.mime_content_type($fileFullPath).';base64,'.$imageData; return $result; }
[ "public", "function", "DataUrl", "(", "$", "relativeOrAbsolutePath", ")", "{", "$", "currentDirFullPath", "=", "$", "this", "->", "view", "->", "GetCurrentViewDirectory", "(", ")", ";", "$", "searchedPaths", "=", "[", "]", ";", "// first - try to find file relatively from currently rendered view", "array_unshift", "(", "$", "searchedPaths", ",", "$", "currentDirFullPath", ".", "'/'", ".", "$", "relativeOrAbsolutePath", ")", ";", "if", "(", "!", "file_exists", "(", "$", "searchedPaths", "[", "0", "]", ")", ")", "{", "// second - try to find file relatively from application root", "array_unshift", "(", "$", "searchedPaths", ",", "$", "this", "->", "appRoot", ".", "'/'", ".", "ltrim", "(", "$", "relativeOrAbsolutePath", ",", "'/'", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "searchedPaths", "[", "0", "]", ")", ")", "{", "// third - try to find file absolutely", "array_unshift", "(", "$", "searchedPaths", ",", "$", "relativeOrAbsolutePath", ")", ";", "if", "(", "!", "file_exists", "(", "$", "searchedPaths", "[", "0", "]", ")", ")", "{", "// throw an error at last", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "\"[\"", ".", "$", "selfClass", ".", "\"] File not found in paths: '\"", ".", "implode", "(", "\"', '\"", ",", "array_reverse", "(", "$", "searchedPaths", ")", ")", ".", "\"'.\"", ")", ";", "}", "}", "}", "// get last searched path", "$", "fileFullPath", "=", "$", "searchedPaths", "[", "0", "]", ";", "// Read image path, convert to base64 encoding", "$", "imageData", "=", "base64_encode", "(", "file_get_contents", "(", "$", "fileFullPath", ")", ")", ";", "// Format the image SRC: data:{mime};base64,{data};", "$", "result", "=", "'data: '", ".", "mime_content_type", "(", "$", "fileFullPath", ")", ".", "';base64,'", ".", "$", "imageData", ";", "return", "$", "result", ";", "}" ]
Return any file content by given relative or absolute path in data url. Path could be relative from currently rendered view, relative from application root or absolute path to file. @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs @param string $relativeOrAbsolutePath @throws \InvalidArgumentException If file not found by given path in any searched place. @return string Data URL value like: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA...`
[ "Return", "any", "file", "content", "by", "given", "relative", "or", "absolute", "path", "in", "data", "url", ".", "Path", "could", "be", "relative", "from", "currently", "rendered", "view", "relative", "from", "application", "root", "or", "absolute", "path", "to", "file", "." ]
08e49cfe4b56726d2bafab6e07f4db21a9d13e35
https://github.com/mvccore/ext-view-helper-dataurl/blob/08e49cfe4b56726d2bafab6e07f4db21a9d13e35/src/MvcCore/Ext/Views/Helpers/DataUrlHelper.php#L79-L106
1,172
rzproject/SearchBundle
DependencyInjection/RzSearchExtension.php
RzSearchExtension.registerSearchSettings
protected function registerSearchSettings(array $config, ContainerBuilder $container) { if (empty($config['configs'])) { throw ConfigManagerException::error('At least 1 configuration should be present under configs.'); } $definition = $container->getDefinition('rz_search.manager.config'); foreach ($config['configs'] as $name => $configuration) { if ($configuration['model']['processor'] && $configuration['model']['identifier']) { $definition->addMethodCall('setConfig', array($name, $configuration)); $definition->addMethodCall('setIndex', array($name, $configuration['model']['identifier'])); } } }
php
protected function registerSearchSettings(array $config, ContainerBuilder $container) { if (empty($config['configs'])) { throw ConfigManagerException::error('At least 1 configuration should be present under configs.'); } $definition = $container->getDefinition('rz_search.manager.config'); foreach ($config['configs'] as $name => $configuration) { if ($configuration['model']['processor'] && $configuration['model']['identifier']) { $definition->addMethodCall('setConfig', array($name, $configuration)); $definition->addMethodCall('setIndex', array($name, $configuration['model']['identifier'])); } } }
[ "protected", "function", "registerSearchSettings", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "empty", "(", "$", "config", "[", "'configs'", "]", ")", ")", "{", "throw", "ConfigManagerException", "::", "error", "(", "'At least 1 configuration should be present under configs.'", ")", ";", "}", "$", "definition", "=", "$", "container", "->", "getDefinition", "(", "'rz_search.manager.config'", ")", ";", "foreach", "(", "$", "config", "[", "'configs'", "]", "as", "$", "name", "=>", "$", "configuration", ")", "{", "if", "(", "$", "configuration", "[", "'model'", "]", "[", "'processor'", "]", "&&", "$", "configuration", "[", "'model'", "]", "[", "'identifier'", "]", ")", "{", "$", "definition", "->", "addMethodCall", "(", "'setConfig'", ",", "array", "(", "$", "name", ",", "$", "configuration", ")", ")", ";", "$", "definition", "->", "addMethodCall", "(", "'setIndex'", ",", "array", "(", "$", "name", ",", "$", "configuration", "[", "'model'", "]", "[", "'identifier'", "]", ")", ")", ";", "}", "}", "}" ]
Registers ckeditor widget.
[ "Registers", "ckeditor", "widget", "." ]
1f6efe031e29db6e2bd15864185f03317a725261
https://github.com/rzproject/SearchBundle/blob/1f6efe031e29db6e2bd15864185f03317a725261/DependencyInjection/RzSearchExtension.php#L164-L177
1,173
emsifa/rakit-slimmy
src/Rakit/Slimmy/TwigView.php
TwigView.render
public function render($template, $data = null) { $twig = $this->getTwig(); $parser = $twig->loadTemplate($template); return $parser->render($this->all(), $data); }
php
public function render($template, $data = null) { $twig = $this->getTwig(); $parser = $twig->loadTemplate($template); return $parser->render($this->all(), $data); }
[ "public", "function", "render", "(", "$", "template", ",", "$", "data", "=", "null", ")", "{", "$", "twig", "=", "$", "this", "->", "getTwig", "(", ")", ";", "$", "parser", "=", "$", "twig", "->", "loadTemplate", "(", "$", "template", ")", ";", "return", "$", "parser", "->", "render", "(", "$", "this", "->", "all", "(", ")", ",", "$", "data", ")", ";", "}" ]
Custom render method @param string template filename to render @param array data
[ "Custom", "render", "method" ]
e60296f95df18e225f7301a5a3156fb1142e1226
https://github.com/emsifa/rakit-slimmy/blob/e60296f95df18e225f7301a5a3156fb1142e1226/src/Rakit/Slimmy/TwigView.php#L48-L54
1,174
phlexible/phlexible
src/Phlexible/Component/MetaSet/Model/MetaSetCollection.php
MetaSetCollection.add
public function add(MetaSetInterface $metaSet) { $this->metaSets[$metaSet->getId()] = $metaSet; $this->nameMap[$metaSet->getName()] = $metaSet->getId(); return $this; }
php
public function add(MetaSetInterface $metaSet) { $this->metaSets[$metaSet->getId()] = $metaSet; $this->nameMap[$metaSet->getName()] = $metaSet->getId(); return $this; }
[ "public", "function", "add", "(", "MetaSetInterface", "$", "metaSet", ")", "{", "$", "this", "->", "metaSets", "[", "$", "metaSet", "->", "getId", "(", ")", "]", "=", "$", "metaSet", ";", "$", "this", "->", "nameMap", "[", "$", "metaSet", "->", "getName", "(", ")", "]", "=", "$", "metaSet", "->", "getId", "(", ")", ";", "return", "$", "this", ";", "}" ]
Add meta set. @param MetaSetInterface $metaSet @return $this
[ "Add", "meta", "set", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MetaSet/Model/MetaSetCollection.php#L38-L44
1,175
bishopb/vanilla
library/core/class.gdn.php
Gdn.Config
public static function Config($Name = FALSE, $Default = FALSE) { $Config = self::$_Config; if ($Name === FALSE) $Result = $Config; else $Result = $Config->Get($Name, $Default); return $Result; }
php
public static function Config($Name = FALSE, $Default = FALSE) { $Config = self::$_Config; if ($Name === FALSE) $Result = $Config; else $Result = $Config->Get($Name, $Default); return $Result; }
[ "public", "static", "function", "Config", "(", "$", "Name", "=", "FALSE", ",", "$", "Default", "=", "FALSE", ")", "{", "$", "Config", "=", "self", "::", "$", "_Config", ";", "if", "(", "$", "Name", "===", "FALSE", ")", "$", "Result", "=", "$", "Config", ";", "else", "$", "Result", "=", "$", "Config", "->", "Get", "(", "$", "Name", ",", "$", "Default", ")", ";", "return", "$", "Result", ";", "}" ]
Get a configuration setting for the application. @param string $Name The name of the configuration setting. Settings in different sections are seperated by a dot ('.') @param mixed $Default The result to return if the configuration setting is not found. @return mixed The configuration setting.
[ "Get", "a", "configuration", "setting", "for", "the", "application", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L96-L104
1,176
bishopb/vanilla
library/core/class.gdn.php
Gdn.Controller
public static function Controller($Value = NULL) { static $Controller = NULL; if ($Value !== NULL) $Controller = $Value; return $Controller; }
php
public static function Controller($Value = NULL) { static $Controller = NULL; if ($Value !== NULL) $Controller = $Value; return $Controller; }
[ "public", "static", "function", "Controller", "(", "$", "Value", "=", "NULL", ")", "{", "static", "$", "Controller", "=", "NULL", ";", "if", "(", "$", "Value", "!==", "NULL", ")", "$", "Controller", "=", "$", "Value", ";", "return", "$", "Controller", ";", "}" ]
The current controller being targetted. @param Gdn_Controller $Value @return Gdn_Controller
[ "The", "current", "controller", "being", "targetted", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L112-L119
1,177
bishopb/vanilla
library/core/class.gdn.php
Gdn.Factory
public static function Factory($Alias = FALSE) { if (is_null(self::$_Factory)) { self::SetFactory(new Gdn_Factory()); self::FactoryOverwrite(FALSE); } if ($Alias === FALSE) return self::$_Factory; // Get the arguments to pass to the factory. //$Args = array($Arg1, $Arg2, $Arg3, $Arg4, $Arg5); $Args = func_get_args(); array_shift($Args); return self::$_Factory->Factory($Alias, $Args); }
php
public static function Factory($Alias = FALSE) { if (is_null(self::$_Factory)) { self::SetFactory(new Gdn_Factory()); self::FactoryOverwrite(FALSE); } if ($Alias === FALSE) return self::$_Factory; // Get the arguments to pass to the factory. //$Args = array($Arg1, $Arg2, $Arg3, $Arg4, $Arg5); $Args = func_get_args(); array_shift($Args); return self::$_Factory->Factory($Alias, $Args); }
[ "public", "static", "function", "Factory", "(", "$", "Alias", "=", "FALSE", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "_Factory", ")", ")", "{", "self", "::", "SetFactory", "(", "new", "Gdn_Factory", "(", ")", ")", ";", "self", "::", "FactoryOverwrite", "(", "FALSE", ")", ";", "}", "if", "(", "$", "Alias", "===", "FALSE", ")", "return", "self", "::", "$", "_Factory", ";", "// Get the arguments to pass to the factory.", "//$Args = array($Arg1, $Arg2, $Arg3, $Arg4, $Arg5);", "$", "Args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "Args", ")", ";", "return", "self", "::", "$", "_Factory", "->", "Factory", "(", "$", "Alias", ",", "$", "Args", ")", ";", "}" ]
Get an object from the factory. @param string $Alias The alias of the class. @param mixed $Args A variable number of arguments to pass to the constructor. @see Gdn_Factory::Factory()
[ "Get", "an", "object", "from", "the", "factory", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L143-L157
1,178
bishopb/vanilla
library/core/class.gdn.php
Gdn.FactoryInstallDependency
public static function FactoryInstallDependency($Alias, $PropertyName, $SourceAlias) { self::Factory()->InstallDependency($Alias, $PropertyName, $SourceAlias); }
php
public static function FactoryInstallDependency($Alias, $PropertyName, $SourceAlias) { self::Factory()->InstallDependency($Alias, $PropertyName, $SourceAlias); }
[ "public", "static", "function", "FactoryInstallDependency", "(", "$", "Alias", ",", "$", "PropertyName", ",", "$", "SourceAlias", ")", "{", "self", "::", "Factory", "(", ")", "->", "InstallDependency", "(", "$", "Alias", ",", "$", "PropertyName", ",", "$", "SourceAlias", ")", ";", "}" ]
Installs a dependency to the factory. @param string $Alias The alias of the class that will have the dependency. @param string $PropertyName The name of the property on the class that will have the dependency. @param string $SourceAlias The alias of the class that will provide the value of the property when objects are instantiated. @see Gdn_Factory::InstalDependency()
[ "Installs", "a", "dependency", "to", "the", "factory", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L214-L216
1,179
bishopb/vanilla
library/core/class.gdn.php
Gdn.FactoryInstallDependencyFromConfig
public static function FactoryInstallDependencyFromConfig($Config, $Alias = NULL) { if (is_string($Config)) $Config = self::Config($Config); if (is_null($Alias)) $Alias = $Config['Alias']; $PropertyName = $Config['PropertyName']; $SourceAlias = $Config['SourceAlias']; $Override = ArrayValue('Override', $Config, TRUE); self::FactoryInstallDependency($Alias, $PropertyName, $SourceAlias, $Override); }
php
public static function FactoryInstallDependencyFromConfig($Config, $Alias = NULL) { if (is_string($Config)) $Config = self::Config($Config); if (is_null($Alias)) $Alias = $Config['Alias']; $PropertyName = $Config['PropertyName']; $SourceAlias = $Config['SourceAlias']; $Override = ArrayValue('Override', $Config, TRUE); self::FactoryInstallDependency($Alias, $PropertyName, $SourceAlias, $Override); }
[ "public", "static", "function", "FactoryInstallDependencyFromConfig", "(", "$", "Config", ",", "$", "Alias", "=", "NULL", ")", "{", "if", "(", "is_string", "(", "$", "Config", ")", ")", "$", "Config", "=", "self", "::", "Config", "(", "$", "Config", ")", ";", "if", "(", "is_null", "(", "$", "Alias", ")", ")", "$", "Alias", "=", "$", "Config", "[", "'Alias'", "]", ";", "$", "PropertyName", "=", "$", "Config", "[", "'PropertyName'", "]", ";", "$", "SourceAlias", "=", "$", "Config", "[", "'SourceAlias'", "]", ";", "$", "Override", "=", "ArrayValue", "(", "'Override'", ",", "$", "Config", ",", "TRUE", ")", ";", "self", "::", "FactoryInstallDependency", "(", "$", "Alias", ",", "$", "PropertyName", ",", "$", "SourceAlias", ",", "$", "Override", ")", ";", "}" ]
Installs a dependency to the factory with the settings from a configuration. @param mixed $Config The configuration of the factory definition. This argument can be of the following types: - <b>string</b>: The configuration will be looked up by calling inline{@link Gdn::Config()} - <b>array</b>: The configuration will be set from the array. @param string $Alias The class alias to install into the factory. If omitted then it must be in the configuration. The dependency will be installed from the configuration array depending on the following keys: - <b>Alias</b>: Optional if $Alias is passed as an argument. - <b>PropertyName</b>: Required. - <b>SourceAlias</b>: Required. - <b>Override</b> Optional. All of these values are passed to the corresponding argument in inline{@link Gdn::FactoryInstallDependency()}.
[ "Installs", "a", "dependency", "to", "the", "factory", "with", "the", "settings", "from", "a", "configuration", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L233-L244
1,180
bishopb/vanilla
library/core/class.gdn.php
Gdn.FactoryInstallFromConfig
public static function FactoryInstallFromConfig($Config, $Alias = NULL) { if (is_string($Config)) $Config = self::Config($Config); if (is_null($Alias)) $Alias = $Config['Alias']; $FactoryType = $Config['FactoryType']; $Data = ArrayValue('Data', $Config, NULL); $Override = ArrayValue('Override', $Config, TRUE); self::FactoryInstall($Alias, $Config['ClassName'], $Config['Path'], $FactoryType, $Data, $Override); if (array_key_exists('Dependencies', $Config)) { $Dependencies = $Config['Dependencies']; foreach($Dependencies as $Index => $DependencyConfig) { self::FactoryInstallFromConfig($DependencyConfig, $Alias); } } }
php
public static function FactoryInstallFromConfig($Config, $Alias = NULL) { if (is_string($Config)) $Config = self::Config($Config); if (is_null($Alias)) $Alias = $Config['Alias']; $FactoryType = $Config['FactoryType']; $Data = ArrayValue('Data', $Config, NULL); $Override = ArrayValue('Override', $Config, TRUE); self::FactoryInstall($Alias, $Config['ClassName'], $Config['Path'], $FactoryType, $Data, $Override); if (array_key_exists('Dependencies', $Config)) { $Dependencies = $Config['Dependencies']; foreach($Dependencies as $Index => $DependencyConfig) { self::FactoryInstallFromConfig($DependencyConfig, $Alias); } } }
[ "public", "static", "function", "FactoryInstallFromConfig", "(", "$", "Config", ",", "$", "Alias", "=", "NULL", ")", "{", "if", "(", "is_string", "(", "$", "Config", ")", ")", "$", "Config", "=", "self", "::", "Config", "(", "$", "Config", ")", ";", "if", "(", "is_null", "(", "$", "Alias", ")", ")", "$", "Alias", "=", "$", "Config", "[", "'Alias'", "]", ";", "$", "FactoryType", "=", "$", "Config", "[", "'FactoryType'", "]", ";", "$", "Data", "=", "ArrayValue", "(", "'Data'", ",", "$", "Config", ",", "NULL", ")", ";", "$", "Override", "=", "ArrayValue", "(", "'Override'", ",", "$", "Config", ",", "TRUE", ")", ";", "self", "::", "FactoryInstall", "(", "$", "Alias", ",", "$", "Config", "[", "'ClassName'", "]", ",", "$", "Config", "[", "'Path'", "]", ",", "$", "FactoryType", ",", "$", "Data", ",", "$", "Override", ")", ";", "if", "(", "array_key_exists", "(", "'Dependencies'", ",", "$", "Config", ")", ")", "{", "$", "Dependencies", "=", "$", "Config", "[", "'Dependencies'", "]", ";", "foreach", "(", "$", "Dependencies", "as", "$", "Index", "=>", "$", "DependencyConfig", ")", "{", "self", "::", "FactoryInstallFromConfig", "(", "$", "DependencyConfig", ",", "$", "Alias", ")", ";", "}", "}", "}" ]
Installs a class to the factory with the settings from a configuration. @param mixed $Config The configuration of the factory definition. This argument can be of the following types: - <b>string</b>: The configuration will be looked up by calling inline{@link Gdn::Config()} - <b>array</b>: The configuration will be set from the array. @param string $Alias The class alias to install into the factory. If omitted then it must be in the configuration. The factory will be installed from the configuration array depending on the following keys: - <b>Alias</b>: Optional if $Alias is passed as an argument. - <b>FactoryType</b>: Required. - <b>Data</b>: Optional. - <b>Override</b> Optional. - <b>Dependencies</b> Optional. Dependencies for the class can be defined as a subarray. Each item in the subarray will be passed to inline{@link Gdn::FactoryInstallDependencyFromConfig}. All of these values (except Dependencies) are passed to the corresponding argument in inline{@link Gdn::FactoryInstall()}.
[ "Installs", "a", "class", "to", "the", "factory", "with", "the", "settings", "from", "a", "configuration", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L262-L280
1,181
bishopb/vanilla
library/core/class.gdn.php
Gdn.Request
public static function Request($NewRequest = NULL) { $Request = self::$_Request; //self::Factory(self::AliasRequest); if (!is_null($NewRequest)) { if (is_string($NewRequest)) $Request->WithURI($NewRequest); elseif (is_object($NewRequest)) $Request->FromImport($NewRequest); } return $Request; }
php
public static function Request($NewRequest = NULL) { $Request = self::$_Request; //self::Factory(self::AliasRequest); if (!is_null($NewRequest)) { if (is_string($NewRequest)) $Request->WithURI($NewRequest); elseif (is_object($NewRequest)) $Request->FromImport($NewRequest); } return $Request; }
[ "public", "static", "function", "Request", "(", "$", "NewRequest", "=", "NULL", ")", "{", "$", "Request", "=", "self", "::", "$", "_Request", ";", "//self::Factory(self::AliasRequest);", "if", "(", "!", "is_null", "(", "$", "NewRequest", ")", ")", "{", "if", "(", "is_string", "(", "$", "NewRequest", ")", ")", "$", "Request", "->", "WithURI", "(", "$", "NewRequest", ")", ";", "elseif", "(", "is_object", "(", "$", "NewRequest", ")", ")", "$", "Request", "->", "FromImport", "(", "$", "NewRequest", ")", ";", "}", "return", "$", "Request", ";", "}" ]
Get or set the current request object. @param Gdn_Request $NewRequest The new request or null to just get the request. @return Gdn_Request
[ "Get", "or", "set", "the", "current", "request", "object", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L396-L406
1,182
bishopb/vanilla
library/core/class.gdn.php
Gdn.Slice
public static function Slice($Slice) { $Result = self::Factory(self::AliasSlice); return $Result->Execute($Slice); }
php
public static function Slice($Slice) { $Result = self::Factory(self::AliasSlice); return $Result->Execute($Slice); }
[ "public", "static", "function", "Slice", "(", "$", "Slice", ")", "{", "$", "Result", "=", "self", "::", "Factory", "(", "self", "::", "AliasSlice", ")", ";", "return", "$", "Result", "->", "Execute", "(", "$", "Slice", ")", ";", "}" ]
Get a reference to the Gdn_Slice @param string $Slice Slice to execute @return Gdn_Slice
[ "Get", "a", "reference", "to", "the", "Gdn_Slice" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L434-L437
1,183
bishopb/vanilla
library/core/class.gdn.php
Gdn.SetFactory
public static function SetFactory($Factory, $Override = TRUE) { if ($Override || is_null(self::$_Factory)) self::$_Factory = $Factory; }
php
public static function SetFactory($Factory, $Override = TRUE) { if ($Override || is_null(self::$_Factory)) self::$_Factory = $Factory; }
[ "public", "static", "function", "SetFactory", "(", "$", "Factory", ",", "$", "Override", "=", "TRUE", ")", "{", "if", "(", "$", "Override", "||", "is_null", "(", "self", "::", "$", "_Factory", ")", ")", "self", "::", "$", "_Factory", "=", "$", "Factory", ";", "}" ]
Set the object used as the factory for the api. @param Gdn_Factory $Factory The object used as the factory. @param boolean $Override whether to override the property if it is already set.
[ "Set", "the", "object", "used", "as", "the", "factory", "for", "the", "api", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.gdn.php#L531-L534
1,184
kettari/tallanto-client-api-bundle
Api/TallantoApiClient.php
TallantoApiClient.execute
public function execute(TallantoMethodInterface $method) { // Build options $options = []; // Is endpoint secured? if ($method instanceof AbstractSecuredTallantoMethod) { if ($method->isSecured()) { $options['auth'] = [$method->getLogin(), $method->getPassword()]; } } // Should we supply JSON data in the body? if (!is_null($jsonData = $method->getJsonData())) { $options['json'] = $jsonData; } // Get query parameters $options['query'] = $method->getQueryParameters(); // Get request headers $options['headers'] = $method->getRequestHeaders(); // Does endpoint pageable? if ($method instanceof PageableTallantoMethodInterface) { $options['query']['total_count'] = 'true'; $options['query']['page_size'] = $method->getPageSize(); $options['query']['page_number'] = $method->getPageNumber(); } $this->logger->debug( 'Performing Guzzle {method} request to {uri}', [ 'method' => $method->getMethod(), 'uri' => $method->getUri(), 'options' => $options, ] ); // Make request try { $response = $this->getClient() ->request( $method->getMethod(), $method->getUri(), $options ); } catch (RequestException $e) { throw new TransportTallantoException( 'Guzzle request failed: '.$e->getResponse() ->getBody() ->getContents(), 0, $e ); } catch (\Exception $e) { throw new TransportTallantoException('Guzzle request failed.', 0, $e); } // Assign response $method->setResponse($response); }
php
public function execute(TallantoMethodInterface $method) { // Build options $options = []; // Is endpoint secured? if ($method instanceof AbstractSecuredTallantoMethod) { if ($method->isSecured()) { $options['auth'] = [$method->getLogin(), $method->getPassword()]; } } // Should we supply JSON data in the body? if (!is_null($jsonData = $method->getJsonData())) { $options['json'] = $jsonData; } // Get query parameters $options['query'] = $method->getQueryParameters(); // Get request headers $options['headers'] = $method->getRequestHeaders(); // Does endpoint pageable? if ($method instanceof PageableTallantoMethodInterface) { $options['query']['total_count'] = 'true'; $options['query']['page_size'] = $method->getPageSize(); $options['query']['page_number'] = $method->getPageNumber(); } $this->logger->debug( 'Performing Guzzle {method} request to {uri}', [ 'method' => $method->getMethod(), 'uri' => $method->getUri(), 'options' => $options, ] ); // Make request try { $response = $this->getClient() ->request( $method->getMethod(), $method->getUri(), $options ); } catch (RequestException $e) { throw new TransportTallantoException( 'Guzzle request failed: '.$e->getResponse() ->getBody() ->getContents(), 0, $e ); } catch (\Exception $e) { throw new TransportTallantoException('Guzzle request failed.', 0, $e); } // Assign response $method->setResponse($response); }
[ "public", "function", "execute", "(", "TallantoMethodInterface", "$", "method", ")", "{", "// Build options", "$", "options", "=", "[", "]", ";", "// Is endpoint secured?", "if", "(", "$", "method", "instanceof", "AbstractSecuredTallantoMethod", ")", "{", "if", "(", "$", "method", "->", "isSecured", "(", ")", ")", "{", "$", "options", "[", "'auth'", "]", "=", "[", "$", "method", "->", "getLogin", "(", ")", ",", "$", "method", "->", "getPassword", "(", ")", "]", ";", "}", "}", "// Should we supply JSON data in the body?", "if", "(", "!", "is_null", "(", "$", "jsonData", "=", "$", "method", "->", "getJsonData", "(", ")", ")", ")", "{", "$", "options", "[", "'json'", "]", "=", "$", "jsonData", ";", "}", "// Get query parameters", "$", "options", "[", "'query'", "]", "=", "$", "method", "->", "getQueryParameters", "(", ")", ";", "// Get request headers", "$", "options", "[", "'headers'", "]", "=", "$", "method", "->", "getRequestHeaders", "(", ")", ";", "// Does endpoint pageable?", "if", "(", "$", "method", "instanceof", "PageableTallantoMethodInterface", ")", "{", "$", "options", "[", "'query'", "]", "[", "'total_count'", "]", "=", "'true'", ";", "$", "options", "[", "'query'", "]", "[", "'page_size'", "]", "=", "$", "method", "->", "getPageSize", "(", ")", ";", "$", "options", "[", "'query'", "]", "[", "'page_number'", "]", "=", "$", "method", "->", "getPageNumber", "(", ")", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'Performing Guzzle {method} request to {uri}'", ",", "[", "'method'", "=>", "$", "method", "->", "getMethod", "(", ")", ",", "'uri'", "=>", "$", "method", "->", "getUri", "(", ")", ",", "'options'", "=>", "$", "options", ",", "]", ")", ";", "// Make request", "try", "{", "$", "response", "=", "$", "this", "->", "getClient", "(", ")", "->", "request", "(", "$", "method", "->", "getMethod", "(", ")", ",", "$", "method", "->", "getUri", "(", ")", ",", "$", "options", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "throw", "new", "TransportTallantoException", "(", "'Guzzle request failed: '", ".", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "TransportTallantoException", "(", "'Guzzle request failed.'", ",", "0", ",", "$", "e", ")", ";", "}", "// Assign response", "$", "method", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Executes API method. @param \Tallanto\ClientApiBundle\Api\Method\TallantoMethodInterface $method @throws \Tallanto\ClientApiBundle\Exception\TransportTallantoException
[ "Executes", "API", "method", "." ]
09863d2b0fed306cc1218ed602ba6c6ad461c3da
https://github.com/kettari/tallanto-client-api-bundle/blob/09863d2b0fed306cc1218ed602ba6c6ad461c3da/Api/TallantoApiClient.php#L44-L98
1,185
NoczCore/ini
src/IniWriter.php
IniWriter.writeToFile
public function writeToFile($filename, $data, $header = '') { $ini = $this->writeToString($data, $header); if (!file_put_contents($filename, $ini)) throw new IniWritingException(sprintf('Impossible to write to file %s', $filename)); }
php
public function writeToFile($filename, $data, $header = '') { $ini = $this->writeToString($data, $header); if (!file_put_contents($filename, $ini)) throw new IniWritingException(sprintf('Impossible to write to file %s', $filename)); }
[ "public", "function", "writeToFile", "(", "$", "filename", ",", "$", "data", ",", "$", "header", "=", "''", ")", "{", "$", "ini", "=", "$", "this", "->", "writeToString", "(", "$", "data", ",", "$", "header", ")", ";", "if", "(", "!", "file_put_contents", "(", "$", "filename", ",", "$", "ini", ")", ")", "throw", "new", "IniWritingException", "(", "sprintf", "(", "'Impossible to write to file %s'", ",", "$", "filename", ")", ")", ";", "}" ]
Convert an array or an IniCollection to INI string in file. @param string $filename @param IniCollection|array $data @param string $header Add header before INI content. @throws IniWritingException
[ "Convert", "an", "array", "or", "an", "IniCollection", "to", "INI", "string", "in", "file", "." ]
7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970
https://github.com/NoczCore/ini/blob/7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970/src/IniWriter.php#L27-L32
1,186
NoczCore/ini
src/IniWriter.php
IniWriter.writeToString
public function writeToString($data, $header = '') { if ($data instanceof IniCollection) $data = $data->toArray(); else if (!is_array($data)) throw new IniWritingException('The expected type is array or \NoczCore\Ini\IniCollection'); $ini = ''; if (!empty($header)) $ini .= $header.PHP_EOL; foreach ($data as $k => $v) { if (is_array($v)) { if (empty($v)) continue; $ini .= "[$k]" . PHP_EOL; foreach ($this->convertRecursive($v) as $key => $value) { $last = explode('.', $key); $last = end($last); if (strpos($key, '.') !== false && is_numeric($last)) $key = substr($key, 0, -strlen('.' . $last)) . '[]'; $ini .= "$key = {$this->encode($value)}" . PHP_EOL; } } else { $ini .= "$k = {$this->encode($v)}" . PHP_EOL; } } return $ini; }
php
public function writeToString($data, $header = '') { if ($data instanceof IniCollection) $data = $data->toArray(); else if (!is_array($data)) throw new IniWritingException('The expected type is array or \NoczCore\Ini\IniCollection'); $ini = ''; if (!empty($header)) $ini .= $header.PHP_EOL; foreach ($data as $k => $v) { if (is_array($v)) { if (empty($v)) continue; $ini .= "[$k]" . PHP_EOL; foreach ($this->convertRecursive($v) as $key => $value) { $last = explode('.', $key); $last = end($last); if (strpos($key, '.') !== false && is_numeric($last)) $key = substr($key, 0, -strlen('.' . $last)) . '[]'; $ini .= "$key = {$this->encode($value)}" . PHP_EOL; } } else { $ini .= "$k = {$this->encode($v)}" . PHP_EOL; } } return $ini; }
[ "public", "function", "writeToString", "(", "$", "data", ",", "$", "header", "=", "''", ")", "{", "if", "(", "$", "data", "instanceof", "IniCollection", ")", "$", "data", "=", "$", "data", "->", "toArray", "(", ")", ";", "else", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "throw", "new", "IniWritingException", "(", "'The expected type is array or \\NoczCore\\Ini\\IniCollection'", ")", ";", "$", "ini", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "header", ")", ")", "$", "ini", ".=", "$", "header", ".", "PHP_EOL", ";", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "if", "(", "empty", "(", "$", "v", ")", ")", "continue", ";", "$", "ini", ".=", "\"[$k]\"", ".", "PHP_EOL", ";", "foreach", "(", "$", "this", "->", "convertRecursive", "(", "$", "v", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "last", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "last", "=", "end", "(", "$", "last", ")", ";", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "!==", "false", "&&", "is_numeric", "(", "$", "last", ")", ")", "$", "key", "=", "substr", "(", "$", "key", ",", "0", ",", "-", "strlen", "(", "'.'", ".", "$", "last", ")", ")", ".", "'[]'", ";", "$", "ini", ".=", "\"$key = {$this->encode($value)}\"", ".", "PHP_EOL", ";", "}", "}", "else", "{", "$", "ini", ".=", "\"$k = {$this->encode($v)}\"", ".", "PHP_EOL", ";", "}", "}", "return", "$", "ini", ";", "}" ]
Convert an array or an IniCollection to INI string. @param IniCollection|array $data @param string $header Add header before INI content. @return string @throws IniWritingException
[ "Convert", "an", "array", "or", "an", "IniCollection", "to", "INI", "string", "." ]
7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970
https://github.com/NoczCore/ini/blob/7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970/src/IniWriter.php#L41-L68
1,187
NoczCore/ini
src/IniWriter.php
IniWriter.convertRecursive
private function convertRecursive(array $array, $parentKey = null) { $return = []; if (!is_null($parentKey)) $parentKey .= '.'; foreach ($array as $k => $v) { if (is_array($v)) $return[] = $this->convertRecursive($v, $parentKey . $k); else $return[$parentKey . $k] = $v; } return $this->array_flatten($return); }
php
private function convertRecursive(array $array, $parentKey = null) { $return = []; if (!is_null($parentKey)) $parentKey .= '.'; foreach ($array as $k => $v) { if (is_array($v)) $return[] = $this->convertRecursive($v, $parentKey . $k); else $return[$parentKey . $k] = $v; } return $this->array_flatten($return); }
[ "private", "function", "convertRecursive", "(", "array", "$", "array", ",", "$", "parentKey", "=", "null", ")", "{", "$", "return", "=", "[", "]", ";", "if", "(", "!", "is_null", "(", "$", "parentKey", ")", ")", "$", "parentKey", ".=", "'.'", ";", "foreach", "(", "$", "array", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "$", "return", "[", "]", "=", "$", "this", "->", "convertRecursive", "(", "$", "v", ",", "$", "parentKey", ".", "$", "k", ")", ";", "else", "$", "return", "[", "$", "parentKey", ".", "$", "k", "]", "=", "$", "v", ";", "}", "return", "$", "this", "->", "array_flatten", "(", "$", "return", ")", ";", "}" ]
Transform a recursive array to a basic array with a point for the recursive keys. @param array $array @param null|string $parentKey @return array
[ "Transform", "a", "recursive", "array", "to", "a", "basic", "array", "with", "a", "point", "for", "the", "recursive", "keys", "." ]
7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970
https://github.com/NoczCore/ini/blob/7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970/src/IniWriter.php#L76-L89
1,188
NoczCore/ini
src/IniWriter.php
IniWriter.encode
private function encode($value) { if ($value === true) $value = "true"; else if ($value === false) $value = "false"; else if (is_string($value)) $value = "\"$value\""; return $value; }
php
private function encode($value) { if ($value === true) $value = "true"; else if ($value === false) $value = "false"; else if (is_string($value)) $value = "\"$value\""; return $value; }
[ "private", "function", "encode", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "true", ")", "$", "value", "=", "\"true\"", ";", "else", "if", "(", "$", "value", "===", "false", ")", "$", "value", "=", "\"false\"", ";", "else", "if", "(", "is_string", "(", "$", "value", ")", ")", "$", "value", "=", "\"\\\"$value\\\"\"", ";", "return", "$", "value", ";", "}" ]
Encode value. @param mixed $value @return string
[ "Encode", "value", "." ]
7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970
https://github.com/NoczCore/ini/blob/7fb02ee25e82cae263e3ed6bed7c0f5dde6dc970/src/IniWriter.php#L96-L105
1,189
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.forge
public static function forge($body = null, $status = 200, array $headers = array()) { $response = new static($body, $status, $headers); // fire any response created events \Event::instance()->has_events('response_created') and \Event::instance()->trigger('response_created', '', 'none'); return $response; }
php
public static function forge($body = null, $status = 200, array $headers = array()) { $response = new static($body, $status, $headers); // fire any response created events \Event::instance()->has_events('response_created') and \Event::instance()->trigger('response_created', '', 'none'); return $response; }
[ "public", "static", "function", "forge", "(", "$", "body", "=", "null", ",", "$", "status", "=", "200", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "response", "=", "new", "static", "(", "$", "body", ",", "$", "status", ",", "$", "headers", ")", ";", "// fire any response created events", "\\", "Event", "::", "instance", "(", ")", "->", "has_events", "(", "'response_created'", ")", "and", "\\", "Event", "::", "instance", "(", ")", "->", "trigger", "(", "'response_created'", ",", "''", ",", "'none'", ")", ";", "return", "$", "response", ";", "}" ]
Creates an instance of the Response class @param string $body The response body @param int $status The HTTP response status for this response @param array $headers Array of HTTP headers for this reponse @return Response
[ "Creates", "an", "instance", "of", "the", "Response", "class" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L96-L104
1,190
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.redirect_back
public static function redirect_back($url = '', $method = 'location', $code = 302) { // do we have a referrer? if ($referrer = \Input::referrer()) { // is it within our website? And not equal to the current url? if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) { // redirect back to where we came from static::redirect($referrer, $method, $code); } } // no referrer or an external link, do a normal redirect static::redirect($url, $method, $code); }
php
public static function redirect_back($url = '', $method = 'location', $code = 302) { // do we have a referrer? if ($referrer = \Input::referrer()) { // is it within our website? And not equal to the current url? if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) { // redirect back to where we came from static::redirect($referrer, $method, $code); } } // no referrer or an external link, do a normal redirect static::redirect($url, $method, $code); }
[ "public", "static", "function", "redirect_back", "(", "$", "url", "=", "''", ",", "$", "method", "=", "'location'", ",", "$", "code", "=", "302", ")", "{", "// do we have a referrer?", "if", "(", "$", "referrer", "=", "\\", "Input", "::", "referrer", "(", ")", ")", "{", "// is it within our website? And not equal to the current url?", "if", "(", "strpos", "(", "$", "referrer", ",", "\\", "Uri", "::", "base", "(", ")", ")", "===", "0", "and", "$", "referrer", "!=", "\\", "Uri", "::", "current", "(", ")", ")", "{", "// redirect back to where we came from", "static", "::", "redirect", "(", "$", "referrer", ",", "$", "method", ",", "$", "code", ")", ";", "}", "}", "// no referrer or an external link, do a normal redirect", "static", "::", "redirect", "(", "$", "url", ",", "$", "method", ",", "$", "code", ")", ";", "}" ]
Redirects back to the previous page, if that page is within the current application. If not, it will redirect to the given url, and if none is given, back to the application root @param string $url The url @param string $method The redirect method @param int $code The redirect status code @return void
[ "Redirects", "back", "to", "the", "previous", "page", "if", "that", "page", "is", "within", "the", "current", "application", ".", "If", "not", "it", "will", "redirect", "to", "the", "given", "url", "and", "if", "none", "is", "given", "back", "to", "the", "application", "root" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L163-L178
1,191
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.set_header
public function set_header($name, $value, $replace = true) { if ($replace) { $this->headers[$name] = $value; } else { $this->headers[] = array($name, $value); } return $this; }
php
public function set_header($name, $value, $replace = true) { if ($replace) { $this->headers[$name] = $value; } else { $this->headers[] = array($name, $value); } return $this; }
[ "public", "function", "set_header", "(", "$", "name", ",", "$", "value", ",", "$", "replace", "=", "true", ")", "{", "if", "(", "$", "replace", ")", "{", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "headers", "[", "]", "=", "array", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a header to the queue @param string The header name @param string The header value @param string Whether to replace existing value for the header, will never overwrite/be overwritten when false @return Response
[ "Adds", "a", "header", "to", "the", "queue" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L233-L245
1,192
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.get_header
public function get_header($name = null) { if (func_num_args()) { return isset($this->headers[$name]) ? $this->headers[$name] : null; } else { return $this->headers; } }
php
public function get_header($name = null) { if (func_num_args()) { return isset($this->headers[$name]) ? $this->headers[$name] : null; } else { return $this->headers; } }
[ "public", "function", "get_header", "(", "$", "name", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", ")", "{", "return", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", "?", "$", "this", "->", "headers", "[", "$", "name", "]", ":", "null", ";", "}", "else", "{", "return", "$", "this", "->", "headers", ";", "}", "}" ]
Gets header information from the queue @param string The header name, or null for all headers @return mixed
[ "Gets", "header", "information", "from", "the", "queue" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L254-L264
1,193
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.send_headers
public function send_headers() { if ( ! headers_sent()) { // Send the protocol/status line first, FCGI servers need different status header if ( ! empty($_SERVER['FCGI_SERVER_VERSION'])) { header('Status: '.$this->status.' '.static::$statuses[$this->status]); } else { $protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1'; header($protocol.' '.$this->status.' '.static::$statuses[$this->status]); } foreach ($this->headers as $name => $value) { // Parse non-replace headers if (is_int($name) and is_array($value)) { isset($value[0]) and $name = $value[0]; isset($value[1]) and $value = $value[1]; } // Create the header is_string($name) and $value = "{$name}: {$value}"; // Send it header($value, true); } return true; } return false; }
php
public function send_headers() { if ( ! headers_sent()) { // Send the protocol/status line first, FCGI servers need different status header if ( ! empty($_SERVER['FCGI_SERVER_VERSION'])) { header('Status: '.$this->status.' '.static::$statuses[$this->status]); } else { $protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1'; header($protocol.' '.$this->status.' '.static::$statuses[$this->status]); } foreach ($this->headers as $name => $value) { // Parse non-replace headers if (is_int($name) and is_array($value)) { isset($value[0]) and $name = $value[0]; isset($value[1]) and $value = $value[1]; } // Create the header is_string($name) and $value = "{$name}: {$value}"; // Send it header($value, true); } return true; } return false; }
[ "public", "function", "send_headers", "(", ")", "{", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "// Send the protocol/status line first, FCGI servers need different status header", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'FCGI_SERVER_VERSION'", "]", ")", ")", "{", "header", "(", "'Status: '", ".", "$", "this", "->", "status", ".", "' '", ".", "static", "::", "$", "statuses", "[", "$", "this", "->", "status", "]", ")", ";", "}", "else", "{", "$", "protocol", "=", "\\", "Input", "::", "server", "(", "'SERVER_PROTOCOL'", ")", "?", "\\", "Input", "::", "server", "(", "'SERVER_PROTOCOL'", ")", ":", "'HTTP/1.1'", ";", "header", "(", "$", "protocol", ".", "' '", ".", "$", "this", "->", "status", ".", "' '", ".", "static", "::", "$", "statuses", "[", "$", "this", "->", "status", "]", ")", ";", "}", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "// Parse non-replace headers", "if", "(", "is_int", "(", "$", "name", ")", "and", "is_array", "(", "$", "value", ")", ")", "{", "isset", "(", "$", "value", "[", "0", "]", ")", "and", "$", "name", "=", "$", "value", "[", "0", "]", ";", "isset", "(", "$", "value", "[", "1", "]", ")", "and", "$", "value", "=", "$", "value", "[", "1", "]", ";", "}", "// Create the header", "is_string", "(", "$", "name", ")", "and", "$", "value", "=", "\"{$name}: {$value}\"", ";", "// Send it", "header", "(", "$", "value", ",", "true", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Sends the headers if they haven't already been sent. Returns whether they were sent or not. @return bool
[ "Sends", "the", "headers", "if", "they", "haven", "t", "already", "been", "sent", ".", "Returns", "whether", "they", "were", "sent", "or", "not", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L290-L323
1,194
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/response.php
Response.send
public function send($send_headers = false) { $body = $this->__toString(); if ($send_headers) { $this->send_headers(); } if ($this->body != null) { echo $body; } }
php
public function send($send_headers = false) { $body = $this->__toString(); if ($send_headers) { $this->send_headers(); } if ($this->body != null) { echo $body; } }
[ "public", "function", "send", "(", "$", "send_headers", "=", "false", ")", "{", "$", "body", "=", "$", "this", "->", "__toString", "(", ")", ";", "if", "(", "$", "send_headers", ")", "{", "$", "this", "->", "send_headers", "(", ")", ";", "}", "if", "(", "$", "this", "->", "body", "!=", "null", ")", "{", "echo", "$", "body", ";", "}", "}" ]
Sends the response to the output buffer. Optionally will send the headers. @param bool $send_headers Whether or not to send the defined HTTP headers @return void
[ "Sends", "the", "response", "to", "the", "output", "buffer", ".", "Optionally", "will", "send", "the", "headers", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/response.php#L333-L346
1,195
Apatis/Config
src/Factory.php
Factory.fromFile
public static function fromFile(string $file, string $driver = null) : ConfigInterface { if (!$driver) { $ext = strtolower((string) pathinfo($file, PATHINFO_EXTENSION)); /** * extension yml is also known as .yaml also * @link https://en.wikipedia.org/wiki/YAML */ if ($ext === 'yml') { $ext = ConfigAdapterInterface::ADAPTER_YAML; } $driver = isset(static::$availableAdapter[$ext]) ? static::$availableAdapter[$ext] : static::$availableAdapter[static::DEFAULT_ADAPTER]; } if (! is_subclass_of($driver, ConfigAdapterInterface::class)) { throw new \InvalidArgumentException( sprintf( 'Config Driver invalid. Driver %s must be implement interface %s', $driver, ConfigAdapterInterface::class ), E_WARNING ); } /** * @var ConfigAdapterInterface $driver */ return $driver::fromFile($file); }
php
public static function fromFile(string $file, string $driver = null) : ConfigInterface { if (!$driver) { $ext = strtolower((string) pathinfo($file, PATHINFO_EXTENSION)); /** * extension yml is also known as .yaml also * @link https://en.wikipedia.org/wiki/YAML */ if ($ext === 'yml') { $ext = ConfigAdapterInterface::ADAPTER_YAML; } $driver = isset(static::$availableAdapter[$ext]) ? static::$availableAdapter[$ext] : static::$availableAdapter[static::DEFAULT_ADAPTER]; } if (! is_subclass_of($driver, ConfigAdapterInterface::class)) { throw new \InvalidArgumentException( sprintf( 'Config Driver invalid. Driver %s must be implement interface %s', $driver, ConfigAdapterInterface::class ), E_WARNING ); } /** * @var ConfigAdapterInterface $driver */ return $driver::fromFile($file); }
[ "public", "static", "function", "fromFile", "(", "string", "$", "file", ",", "string", "$", "driver", "=", "null", ")", ":", "ConfigInterface", "{", "if", "(", "!", "$", "driver", ")", "{", "$", "ext", "=", "strtolower", "(", "(", "string", ")", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ")", ";", "/**\n * extension yml is also known as .yaml also\n * @link https://en.wikipedia.org/wiki/YAML\n */", "if", "(", "$", "ext", "===", "'yml'", ")", "{", "$", "ext", "=", "ConfigAdapterInterface", "::", "ADAPTER_YAML", ";", "}", "$", "driver", "=", "isset", "(", "static", "::", "$", "availableAdapter", "[", "$", "ext", "]", ")", "?", "static", "::", "$", "availableAdapter", "[", "$", "ext", "]", ":", "static", "::", "$", "availableAdapter", "[", "static", "::", "DEFAULT_ADAPTER", "]", ";", "}", "if", "(", "!", "is_subclass_of", "(", "$", "driver", ",", "ConfigAdapterInterface", "::", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Config Driver invalid. Driver %s must be implement interface %s'", ",", "$", "driver", ",", "ConfigAdapterInterface", "::", "class", ")", ",", "E_WARNING", ")", ";", "}", "/**\n * @var ConfigAdapterInterface $driver\n */", "return", "$", "driver", "::", "fromFile", "(", "$", "file", ")", ";", "}" ]
Get from file @param string $file @param string|null $driver @return ConfigInterface
[ "Get", "from", "file" ]
f93d1761e5ea84185f563fb9c7a113e64c4623ba
https://github.com/Apatis/Config/blob/f93d1761e5ea84185f563fb9c7a113e64c4623ba/src/Factory.php#L75-L107
1,196
metrophp/metrodi
container.php
Metrodi_Container.didef
public function didef($thing, $file) { $this->thingList[$thing] = $file; $args = func_get_args(); //remove 2 known params array_shift($args); array_shift($args); if (count($args)) { $this->thingArgList[$thing] = $args; } }
php
public function didef($thing, $file) { $this->thingList[$thing] = $file; $args = func_get_args(); //remove 2 known params array_shift($args); array_shift($args); if (count($args)) { $this->thingArgList[$thing] = $args; } }
[ "public", "function", "didef", "(", "$", "thing", ",", "$", "file", ")", "{", "$", "this", "->", "thingList", "[", "$", "thing", "]", "=", "$", "file", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "//remove 2 known params", "array_shift", "(", "$", "args", ")", ";", "array_shift", "(", "$", "args", ")", ";", "if", "(", "count", "(", "$", "args", ")", ")", "{", "$", "this", "->", "thingArgList", "[", "$", "thing", "]", "=", "$", "args", ";", "}", "}" ]
Define a file as a thing. Any extra arguments are saved and used as constructor arguments
[ "Define", "a", "file", "as", "a", "thing", ".", "Any", "extra", "arguments", "are", "saved", "and", "used", "as", "constructor", "arguments" ]
61fab6aa11dbb235bc2a734aa0e738b80074da0b
https://github.com/metrophp/metrodi/blob/61fab6aa11dbb235bc2a734aa0e738b80074da0b/container.php#L42-L52
1,197
metrophp/metrodi
container.php
Metrodi_Container.attachServices
public function attachServices($obj) { $args = get_class_vars( get_class($obj) ); foreach ($args as $_k=>$_v) { if (substr($_k, -7) == 'Service') { $obj->$_k = _makePromise($_k); } } }
php
public function attachServices($obj) { $args = get_class_vars( get_class($obj) ); foreach ($args as $_k=>$_v) { if (substr($_k, -7) == 'Service') { $obj->$_k = _makePromise($_k); } } }
[ "public", "function", "attachServices", "(", "$", "obj", ")", "{", "$", "args", "=", "get_class_vars", "(", "get_class", "(", "$", "obj", ")", ")", ";", "foreach", "(", "$", "args", "as", "$", "_k", "=>", "$", "_v", ")", "{", "if", "(", "substr", "(", "$", "_k", ",", "-", "7", ")", "==", "'Service'", ")", "{", "$", "obj", "->", "$", "_k", "=", "_makePromise", "(", "$", "_k", ")", ";", "}", "}", "}" ]
Set a DI promise object on every class var that ends with 'Service'
[ "Set", "a", "DI", "promise", "object", "on", "every", "class", "var", "that", "ends", "with", "Service" ]
61fab6aa11dbb235bc2a734aa0e738b80074da0b
https://github.com/metrophp/metrodi/blob/61fab6aa11dbb235bc2a734aa0e738b80074da0b/container.php#L258-L265
1,198
praxigento/mobi_mod_wallet
Service/Sale/Payment.php
Payment.validateCustomerBalance
private function validateCustomerBalance($balance, $amount, $useDelta = false) { if ($useDelta) { $result = (($balance + self::CONVERSION_DELTA) >= $amount); } else { $result = ($balance >= $amount); } return $result; }
php
private function validateCustomerBalance($balance, $amount, $useDelta = false) { if ($useDelta) { $result = (($balance + self::CONVERSION_DELTA) >= $amount); } else { $result = ($balance >= $amount); } return $result; }
[ "private", "function", "validateCustomerBalance", "(", "$", "balance", ",", "$", "amount", ",", "$", "useDelta", "=", "false", ")", "{", "if", "(", "$", "useDelta", ")", "{", "$", "result", "=", "(", "(", "$", "balance", "+", "self", "::", "CONVERSION_DELTA", ")", ">=", "$", "amount", ")", ";", "}", "else", "{", "$", "result", "=", "(", "$", "balance", ">=", "$", "amount", ")", ";", "}", "return", "$", "result", ";", "}" ]
Customer balance should be greater or equal to transaction amount. @param float $balance @param float $amount @param bool $useDelta use some delta in values comparison (currency conversion gap) @return bool
[ "Customer", "balance", "should", "be", "greater", "or", "equal", "to", "transaction", "amount", "." ]
8f4789645f2e3c95b1323984aa67215b1647fa39
https://github.com/praxigento/mobi_mod_wallet/blob/8f4789645f2e3c95b1323984aa67215b1647fa39/Service/Sale/Payment.php#L121-L129
1,199
consolle/framework
src/Foundation/Application.php
Application.rootPath
public function rootPath() { return ('phar:' === substr($this->basePath, 0, 5)) ? dirname(str_replace('phar://', '', $this->basePath)) : $this->basePath; }
php
public function rootPath() { return ('phar:' === substr($this->basePath, 0, 5)) ? dirname(str_replace('phar://', '', $this->basePath)) : $this->basePath; }
[ "public", "function", "rootPath", "(", ")", "{", "return", "(", "'phar:'", "===", "substr", "(", "$", "this", "->", "basePath", ",", "0", ",", "5", ")", ")", "?", "dirname", "(", "str_replace", "(", "'phar://'", ",", "''", ",", "$", "this", "->", "basePath", ")", ")", ":", "$", "this", "->", "basePath", ";", "}" ]
Get the path of root @return string
[ "Get", "the", "path", "of", "root" ]
2799921d6983f31e775099eac116c337bbe29c74
https://github.com/consolle/framework/blob/2799921d6983f31e775099eac116c337bbe29c74/src/Foundation/Application.php#L268-L271