id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
38,000
larriereguichet/AdminBundle
src/Bridge/Twig/Extension/FieldExtension.php
FieldExtension.renderFieldHeader
public function renderFieldHeader(ViewInterface $admin, FieldInterface $field) { return $this->renderer->renderHeader($admin, $field); }
php
public function renderFieldHeader(ViewInterface $admin, FieldInterface $field) { return $this->renderer->renderHeader($admin, $field); }
[ "public", "function", "renderFieldHeader", "(", "ViewInterface", "$", "admin", ",", "FieldInterface", "$", "field", ")", "{", "return", "$", "this", "->", "renderer", "->", "renderHeader", "(", "$", "admin", ",", "$", "field", ")", ";", "}" ]
Return the field header label. @param ViewInterface $admin @param FieldInterface $field @return string
[ "Return", "the", "field", "header", "label", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Twig/Extension/FieldExtension.php#L44-L47
38,001
yawik/cv
src/Factory/Form/AttachmentsFormFactory.php
AttachmentsFormFactory.configureForm
protected function configureForm($form, AbstractOptions $options) { if (!$options instanceof ModuleOptions) { throw new \InvalidArgumentException(sprintf('$options must be instance of %s', ModuleOptions::class)); } $size = $options->getAttachmentsMaxSize(); $type = $options->getAttachmentsMimeType(); $count = $options->getAttachmentsCount(); $form->setIsDisableCapable(false) ->setIsDisableElementsCapable(false) ->setIsDescriptionsEnabled(true) ->setDescription( /*@translate*/ 'Attach images or PDF Documents to your CV. Drag&drop them, or click into the attachement area. You can upload up to %sMB', [round($size/(1024*1024))>0? round($size/(1024*1024)):round($size/(1024*1024), 1)] ) ->setParam('return', 'file-uri') ->setLabel(/*@translate*/ 'Attachments'); /* @var $file \Core\Form\Element\FileUpload */ $file = $form->get($this->fileName); $file->setMaxSize($size); if ($type) { $file->setAllowedTypes($type); } $file->setMaxFileCount($count); // pass form to element. Needed for file count validation // I did not find another (better) way. $file->setForm($form); }
php
protected function configureForm($form, AbstractOptions $options) { if (!$options instanceof ModuleOptions) { throw new \InvalidArgumentException(sprintf('$options must be instance of %s', ModuleOptions::class)); } $size = $options->getAttachmentsMaxSize(); $type = $options->getAttachmentsMimeType(); $count = $options->getAttachmentsCount(); $form->setIsDisableCapable(false) ->setIsDisableElementsCapable(false) ->setIsDescriptionsEnabled(true) ->setDescription( /*@translate*/ 'Attach images or PDF Documents to your CV. Drag&drop them, or click into the attachement area. You can upload up to %sMB', [round($size/(1024*1024))>0? round($size/(1024*1024)):round($size/(1024*1024), 1)] ) ->setParam('return', 'file-uri') ->setLabel(/*@translate*/ 'Attachments'); /* @var $file \Core\Form\Element\FileUpload */ $file = $form->get($this->fileName); $file->setMaxSize($size); if ($type) { $file->setAllowedTypes($type); } $file->setMaxFileCount($count); // pass form to element. Needed for file count validation // I did not find another (better) way. $file->setForm($form); }
[ "protected", "function", "configureForm", "(", "$", "form", ",", "AbstractOptions", "$", "options", ")", "{", "if", "(", "!", "$", "options", "instanceof", "ModuleOptions", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'$options must be instance of %s'", ",", "ModuleOptions", "::", "class", ")", ")", ";", "}", "$", "size", "=", "$", "options", "->", "getAttachmentsMaxSize", "(", ")", ";", "$", "type", "=", "$", "options", "->", "getAttachmentsMimeType", "(", ")", ";", "$", "count", "=", "$", "options", "->", "getAttachmentsCount", "(", ")", ";", "$", "form", "->", "setIsDisableCapable", "(", "false", ")", "->", "setIsDisableElementsCapable", "(", "false", ")", "->", "setIsDescriptionsEnabled", "(", "true", ")", "->", "setDescription", "(", "/*@translate*/", "'Attach images or PDF Documents to your CV. Drag&drop them, or click into the attachement area. You can upload up to %sMB'", ",", "[", "round", "(", "$", "size", "/", "(", "1024", "*", "1024", ")", ")", ">", "0", "?", "round", "(", "$", "size", "/", "(", "1024", "*", "1024", ")", ")", ":", "round", "(", "$", "size", "/", "(", "1024", "*", "1024", ")", ",", "1", ")", "]", ")", "->", "setParam", "(", "'return'", ",", "'file-uri'", ")", "->", "setLabel", "(", "/*@translate*/", "'Attachments'", ")", ";", "/* @var $file \\Core\\Form\\Element\\FileUpload */", "$", "file", "=", "$", "form", "->", "get", "(", "$", "this", "->", "fileName", ")", ";", "$", "file", "->", "setMaxSize", "(", "$", "size", ")", ";", "if", "(", "$", "type", ")", "{", "$", "file", "->", "setAllowedTypes", "(", "$", "type", ")", ";", "}", "$", "file", "->", "setMaxFileCount", "(", "$", "count", ")", ";", "// pass form to element. Needed for file count validation", "// I did not find another (better) way.", "$", "file", "->", "setForm", "(", "$", "form", ")", ";", "}" ]
configure the formular for uploading attachments @param Form $form @param AbstractOptions $options
[ "configure", "the", "formular", "for", "uploading", "attachments" ]
a3c57c060d3f1c353c3e8ef3542b77147d4ec012
https://github.com/yawik/cv/blob/a3c57c060d3f1c353c3e8ef3542b77147d4ec012/src/Factory/Form/AttachmentsFormFactory.php#L65-L97
38,002
larriereguichet/AdminBundle
src/Bridge/Doctrine/ORM/DataProvider/ORMDataProvider.php
ORMDataProvider.getCollection
public function getCollection(AdminInterface $admin, array $filters = []) { $adminConfiguration = $admin->getConfiguration(); $actionConfiguration = $admin->getAction()->getConfiguration(); // Create a query builder for the configured entity class $queryBuilder = $this ->getRepository($adminConfiguration->getParameter('entity')) ->createQueryBuilder('entity') ; // Dispatch an event to allow filter alteration on the query builder $event = new ORMFilterEvent($queryBuilder, $admin, $filters); $this->eventDispatcher->dispatch(Events::DOCTRINE_ORM_FILTER, $event); if ('pagerfanta' === $actionConfiguration->getParameter('pager')) { $pageParameter = $actionConfiguration->getParameter('page_parameter'); $request = $this->requestStack->getCurrentRequest(); $page = (int) $request->get($pageParameter, 1); $adapter = new DoctrineORMAdapter($queryBuilder); $pager = new Pagerfanta($adapter); $pager->setCurrentPage($page); $pager->setMaxPerPage($actionConfiguration->getParameter('max_per_page')); $entities = $pager; } else { $entities = $queryBuilder->getQuery()->getResult(); } return $entities; }
php
public function getCollection(AdminInterface $admin, array $filters = []) { $adminConfiguration = $admin->getConfiguration(); $actionConfiguration = $admin->getAction()->getConfiguration(); // Create a query builder for the configured entity class $queryBuilder = $this ->getRepository($adminConfiguration->getParameter('entity')) ->createQueryBuilder('entity') ; // Dispatch an event to allow filter alteration on the query builder $event = new ORMFilterEvent($queryBuilder, $admin, $filters); $this->eventDispatcher->dispatch(Events::DOCTRINE_ORM_FILTER, $event); if ('pagerfanta' === $actionConfiguration->getParameter('pager')) { $pageParameter = $actionConfiguration->getParameter('page_parameter'); $request = $this->requestStack->getCurrentRequest(); $page = (int) $request->get($pageParameter, 1); $adapter = new DoctrineORMAdapter($queryBuilder); $pager = new Pagerfanta($adapter); $pager->setCurrentPage($page); $pager->setMaxPerPage($actionConfiguration->getParameter('max_per_page')); $entities = $pager; } else { $entities = $queryBuilder->getQuery()->getResult(); } return $entities; }
[ "public", "function", "getCollection", "(", "AdminInterface", "$", "admin", ",", "array", "$", "filters", "=", "[", "]", ")", "{", "$", "adminConfiguration", "=", "$", "admin", "->", "getConfiguration", "(", ")", ";", "$", "actionConfiguration", "=", "$", "admin", "->", "getAction", "(", ")", "->", "getConfiguration", "(", ")", ";", "// Create a query builder for the configured entity class", "$", "queryBuilder", "=", "$", "this", "->", "getRepository", "(", "$", "adminConfiguration", "->", "getParameter", "(", "'entity'", ")", ")", "->", "createQueryBuilder", "(", "'entity'", ")", ";", "// Dispatch an event to allow filter alteration on the query builder", "$", "event", "=", "new", "ORMFilterEvent", "(", "$", "queryBuilder", ",", "$", "admin", ",", "$", "filters", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Events", "::", "DOCTRINE_ORM_FILTER", ",", "$", "event", ")", ";", "if", "(", "'pagerfanta'", "===", "$", "actionConfiguration", "->", "getParameter", "(", "'pager'", ")", ")", "{", "$", "pageParameter", "=", "$", "actionConfiguration", "->", "getParameter", "(", "'page_parameter'", ")", ";", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "$", "page", "=", "(", "int", ")", "$", "request", "->", "get", "(", "$", "pageParameter", ",", "1", ")", ";", "$", "adapter", "=", "new", "DoctrineORMAdapter", "(", "$", "queryBuilder", ")", ";", "$", "pager", "=", "new", "Pagerfanta", "(", "$", "adapter", ")", ";", "$", "pager", "->", "setCurrentPage", "(", "$", "page", ")", ";", "$", "pager", "->", "setMaxPerPage", "(", "$", "actionConfiguration", "->", "getParameter", "(", "'max_per_page'", ")", ")", ";", "$", "entities", "=", "$", "pager", ";", "}", "else", "{", "$", "entities", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}", "return", "$", "entities", ";", "}" ]
Load a collection of entities. @param AdminInterface $admin @param array $filters @return mixed
[ "Load", "a", "collection", "of", "entities", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Doctrine/ORM/DataProvider/ORMDataProvider.php#L60-L90
38,003
larriereguichet/AdminBundle
src/Factory/DataProviderFactory.php
DataProviderFactory.add
public function add($id, DataProviderInterface $dataProvider) { if ($this->has($id)) { throw new Exception('Trying to add the data provider '.$id.' twice'); } // add the data provider to collection, indexed by ids $this->dataProviders[$id] = $dataProvider; }
php
public function add($id, DataProviderInterface $dataProvider) { if ($this->has($id)) { throw new Exception('Trying to add the data provider '.$id.' twice'); } // add the data provider to collection, indexed by ids $this->dataProviders[$id] = $dataProvider; }
[ "public", "function", "add", "(", "$", "id", ",", "DataProviderInterface", "$", "dataProvider", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "id", ")", ")", "{", "throw", "new", "Exception", "(", "'Trying to add the data provider '", ".", "$", "id", ".", "' twice'", ")", ";", "}", "// add the data provider to collection, indexed by ids", "$", "this", "->", "dataProviders", "[", "$", "id", "]", "=", "$", "dataProvider", ";", "}" ]
Add a data provider to the collection. @param string $id The data provider service id @param DataProviderInterface $dataProvider The data provider @throws Exception
[ "Add", "a", "data", "provider", "to", "the", "collection", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Factory/DataProviderFactory.php#L41-L48
38,004
larriereguichet/AdminBundle
src/Factory/DataProviderFactory.php
DataProviderFactory.get
public function get(string $id): DataProviderInterface { if (!$this->has($id)) { throw new Exception('No data provider with id "'.$id.'" was loaded'); } return $this->dataProviders[$id]; }
php
public function get(string $id): DataProviderInterface { if (!$this->has($id)) { throw new Exception('No data provider with id "'.$id.'" was loaded'); } return $this->dataProviders[$id]; }
[ "public", "function", "get", "(", "string", "$", "id", ")", ":", "DataProviderInterface", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "id", ")", ")", "{", "throw", "new", "Exception", "(", "'No data provider with id \"'", ".", "$", "id", ".", "'\" was loaded'", ")", ";", "}", "return", "$", "this", "->", "dataProviders", "[", "$", "id", "]", ";", "}" ]
Return an configured data provider or try to create one for the given entity class. @param string $id The id of an existing data provider service registry @return DataProviderInterface @throws Exception
[ "Return", "an", "configured", "data", "provider", "or", "try", "to", "create", "one", "for", "the", "given", "entity", "class", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Factory/DataProviderFactory.php#L60-L67
38,005
larriereguichet/AdminBundle
src/Event/Subscriber/ExtraConfigurationSubscriber.php
ExtraConfigurationSubscriber.addDefaultActions
private function addDefaultActions(array &$configuration) { if (!key_exists('actions', $configuration) || !is_array($configuration['actions'])) { $configuration['actions'] = []; } if (0 !== count($configuration['actions'])) { return; } $configuration['actions'] = [ 'create' => [], 'list' => [], 'edit' => [], 'delete' => [], ]; }
php
private function addDefaultActions(array &$configuration) { if (!key_exists('actions', $configuration) || !is_array($configuration['actions'])) { $configuration['actions'] = []; } if (0 !== count($configuration['actions'])) { return; } $configuration['actions'] = [ 'create' => [], 'list' => [], 'edit' => [], 'delete' => [], ]; }
[ "private", "function", "addDefaultActions", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "key_exists", "(", "'actions'", ",", "$", "configuration", ")", "||", "!", "is_array", "(", "$", "configuration", "[", "'actions'", "]", ")", ")", "{", "$", "configuration", "[", "'actions'", "]", "=", "[", "]", ";", "}", "if", "(", "0", "!==", "count", "(", "$", "configuration", "[", "'actions'", "]", ")", ")", "{", "return", ";", "}", "$", "configuration", "[", "'actions'", "]", "=", "[", "'create'", "=>", "[", "]", ",", "'list'", "=>", "[", "]", ",", "'edit'", "=>", "[", "]", ",", "'delete'", "=>", "[", "]", ",", "]", ";", "}" ]
Defines the default CRUD actions if no action was configured. @param array $configuration
[ "Defines", "the", "default", "CRUD", "actions", "if", "no", "action", "was", "configured", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/ExtraConfigurationSubscriber.php#L125-L140
38,006
larriereguichet/AdminBundle
src/Event/Subscriber/ExtraConfigurationSubscriber.php
ExtraConfigurationSubscriber.addDefaultLeftMenu
private function addDefaultLeftMenu(array &$configuration) { if (!$this->applicationConfiguration->getParameter('enable_menus')) { return; } $menus = $this->configurationFactory->createResourceMenuConfiguration(); // Add the resources menu for each action of the admin foreach ($configuration['actions'] as $name => $action) { if (null === $action) { $action = []; } if (key_exists('menus', $action) && key_exists('left', $action)) { continue; } $configuration['actions'][$name]['menus']['left'] = $menus; } }
php
private function addDefaultLeftMenu(array &$configuration) { if (!$this->applicationConfiguration->getParameter('enable_menus')) { return; } $menus = $this->configurationFactory->createResourceMenuConfiguration(); // Add the resources menu for each action of the admin foreach ($configuration['actions'] as $name => $action) { if (null === $action) { $action = []; } if (key_exists('menus', $action) && key_exists('left', $action)) { continue; } $configuration['actions'][$name]['menus']['left'] = $menus; } }
[ "private", "function", "addDefaultLeftMenu", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "$", "this", "->", "applicationConfiguration", "->", "getParameter", "(", "'enable_menus'", ")", ")", "{", "return", ";", "}", "$", "menus", "=", "$", "this", "->", "configurationFactory", "->", "createResourceMenuConfiguration", "(", ")", ";", "// Add the resources menu for each action of the admin", "foreach", "(", "$", "configuration", "[", "'actions'", "]", "as", "$", "name", "=>", "$", "action", ")", "{", "if", "(", "null", "===", "$", "action", ")", "{", "$", "action", "=", "[", "]", ";", "}", "if", "(", "key_exists", "(", "'menus'", ",", "$", "action", ")", "&&", "key_exists", "(", "'left'", ",", "$", "action", ")", ")", "{", "continue", ";", "}", "$", "configuration", "[", "'actions'", "]", "[", "$", "name", "]", "[", "'menus'", "]", "[", "'left'", "]", "=", "$", "menus", ";", "}", "}" ]
Add the default left menu configuration. One item for each Admin. @param array $configuration
[ "Add", "the", "default", "left", "menu", "configuration", ".", "One", "item", "for", "each", "Admin", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/ExtraConfigurationSubscriber.php#L147-L166
38,007
larriereguichet/AdminBundle
src/Event/Subscriber/ExtraConfigurationSubscriber.php
ExtraConfigurationSubscriber.addDefaultRightMenu
private function addDefaultRightMenu(array &$configuration) { if (!$this->applicationConfiguration->getParameter('enable_menus')) { return; } if (!key_exists('list', $configuration['actions'])) { return; } if ( key_exists('menus', $configuration['actions']['list']) && is_array($configuration['actions']['list']['menus']) && key_exists('right', $configuration['actions']['list']['menus']) ) { return; } $configuration['actions']['list']['menus']['right'] = []; }
php
private function addDefaultRightMenu(array &$configuration) { if (!$this->applicationConfiguration->getParameter('enable_menus')) { return; } if (!key_exists('list', $configuration['actions'])) { return; } if ( key_exists('menus', $configuration['actions']['list']) && is_array($configuration['actions']['list']['menus']) && key_exists('right', $configuration['actions']['list']['menus']) ) { return; } $configuration['actions']['list']['menus']['right'] = []; }
[ "private", "function", "addDefaultRightMenu", "(", "array", "&", "$", "configuration", ")", "{", "if", "(", "!", "$", "this", "->", "applicationConfiguration", "->", "getParameter", "(", "'enable_menus'", ")", ")", "{", "return", ";", "}", "if", "(", "!", "key_exists", "(", "'list'", ",", "$", "configuration", "[", "'actions'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "key_exists", "(", "'menus'", ",", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", ")", "&&", "is_array", "(", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", "[", "'menus'", "]", ")", "&&", "key_exists", "(", "'right'", ",", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", "[", "'menus'", "]", ")", ")", "{", "return", ";", "}", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", "[", "'menus'", "]", "[", "'right'", "]", "=", "[", "]", ";", "}" ]
Add the default right menu. @param array $configuration
[ "Add", "the", "default", "right", "menu", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/ExtraConfigurationSubscriber.php#L173-L192
38,008
larriereguichet/AdminBundle
src/Event/Subscriber/ExtraConfigurationSubscriber.php
ExtraConfigurationSubscriber.addDefaultFilters
private function addDefaultFilters(array &$configuration) { // Add the filters only for the "list" action if (!key_exists('list', $configuration['actions'])) { return; } // If some filters are already configured, we do not add the default filters if (key_exists('filter', $configuration['actions']['list'])) { return; } // TODO add a default unified filter $metadata = $this->findMetadata($configuration['entity']); if (null === $metadata) { return; } $filters = []; foreach ($metadata->getFieldNames() as $fieldName) { $type = $metadata->getTypeOfField($fieldName); $operator = $this->getOperatorFromFieldType($type); $filters[$fieldName] = [ 'type' => $type, 'options' => [], 'comparator' => $operator, ]; } $configuration['actions']['list']['filters'] = $filters; }
php
private function addDefaultFilters(array &$configuration) { // Add the filters only for the "list" action if (!key_exists('list', $configuration['actions'])) { return; } // If some filters are already configured, we do not add the default filters if (key_exists('filter', $configuration['actions']['list'])) { return; } // TODO add a default unified filter $metadata = $this->findMetadata($configuration['entity']); if (null === $metadata) { return; } $filters = []; foreach ($metadata->getFieldNames() as $fieldName) { $type = $metadata->getTypeOfField($fieldName); $operator = $this->getOperatorFromFieldType($type); $filters[$fieldName] = [ 'type' => $type, 'options' => [], 'comparator' => $operator, ]; } $configuration['actions']['list']['filters'] = $filters; }
[ "private", "function", "addDefaultFilters", "(", "array", "&", "$", "configuration", ")", "{", "// Add the filters only for the \"list\" action", "if", "(", "!", "key_exists", "(", "'list'", ",", "$", "configuration", "[", "'actions'", "]", ")", ")", "{", "return", ";", "}", "// If some filters are already configured, we do not add the default filters", "if", "(", "key_exists", "(", "'filter'", ",", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", ")", ")", "{", "return", ";", "}", "// TODO add a default unified filter", "$", "metadata", "=", "$", "this", "->", "findMetadata", "(", "$", "configuration", "[", "'entity'", "]", ")", ";", "if", "(", "null", "===", "$", "metadata", ")", "{", "return", ";", "}", "$", "filters", "=", "[", "]", ";", "foreach", "(", "$", "metadata", "->", "getFieldNames", "(", ")", "as", "$", "fieldName", ")", "{", "$", "type", "=", "$", "metadata", "->", "getTypeOfField", "(", "$", "fieldName", ")", ";", "$", "operator", "=", "$", "this", "->", "getOperatorFromFieldType", "(", "$", "type", ")", ";", "$", "filters", "[", "$", "fieldName", "]", "=", "[", "'type'", "=>", "$", "type", ",", "'options'", "=>", "[", "]", ",", "'comparator'", "=>", "$", "operator", ",", "]", ";", "}", "$", "configuration", "[", "'actions'", "]", "[", "'list'", "]", "[", "'filters'", "]", "=", "$", "filters", ";", "}" ]
Add default filters for the list actions, guessed using the entity metadata. @param array $configuration
[ "Add", "default", "filters", "for", "the", "list", "actions", "guessed", "using", "the", "entity", "metadata", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/ExtraConfigurationSubscriber.php#L269-L299
38,009
larriereguichet/AdminBundle
src/Configuration/ApplicationConfiguration.php
ApplicationConfiguration.configureOptions
public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefaults([ // enable or disable extra configuration listener 'enable_extra_configuration' => true, 'enable_security' => true, 'enable_menus' => true, 'enable_homepage' => true, 'translation' => false, 'translation_pattern' => false, 'title' => 'AdminBundle application', 'description' => '', 'locale' => 'en', // Main base template as bundles are not loaded when reading the configuration, the kernel // locateResources will always failed. So we must not check resource existence here. 'base_template' => '@LAGAdmin/base.html.twig', 'block_template' => '@LAGAdmin/Form/fields.html.twig', 'menu_template' => '@LAGAdmin/Menu/menu.html.twig', 'list_template' => '@LAGAdmin/CRUD/list.html.twig', 'edit_template' => '@LAGAdmin/CRUD/edit.html.twig', 'create_template' => '@LAGAdmin/CRUD/create.html.twig', 'delete_template' => '@LAGAdmin/CRUD/delete.html.twig', 'homepage_template' => '@LAGAdmin/Pages/home.html.twig', 'homepage_route' => 'lag.admin.homepage', 'routing_url_pattern' => '/{admin}/{action}', 'routing_name_pattern' => 'lag.admin.{admin}.{action}', 'bootstrap' => true, 'date_format' => 'Y/m/d', 'pager' => 'pagerfanta', // string length before truncation (0 means no truncation) 'string_length' => 200, 'string_length_truncate' => '...', 'max_per_page' => 20, 'admin_class' => Admin::class, 'action_class' => Action::class, 'permissions' => 'ROLE_ADMIN', 'page_parameter' => 'page', ]) ->setAllowedTypes('enable_extra_configuration', 'boolean') ->setAllowedTypes('enable_security', 'boolean') ->setAllowedTypes('enable_menus', 'boolean') ->setAllowedTypes('title', 'string') ->setAllowedTypes('description', 'string') ->setAllowedTypes('locale', 'string') ->setAllowedTypes('base_template', 'string') ->setAllowedTypes('block_template', 'string') ->setAllowedTypes('bootstrap', 'boolean') ->setAllowedTypes('date_format', 'string') ->setAllowedTypes('string_length', 'integer') ->setAllowedTypes('string_length_truncate', 'string') ->setAllowedTypes('max_per_page', 'integer') ->setAllowedTypes('admin_class', 'string') ->setAllowedTypes('routing_name_pattern', 'string') ->setAllowedTypes('routing_url_pattern', 'string') ->setAllowedTypes('page_parameter', 'string') ->setNormalizer('routing_name_pattern', function(Options $options, $value) { if (false === strstr($value, '{admin}')) { throw new InvalidOptionsException( 'Admin routing configuration pattern name should contains the {admin} placeholder' ); } if (false === strstr($value, '{action}')) { throw new InvalidOptionsException( 'Admin routing configuration pattern name should contains the {action} placeholder' ); } return $value; }) ->setNormalizer('routing_url_pattern', function(Options $options, $value) { if (false === strstr($value, '{admin}')) { throw new InvalidOptionsException('Admin routing configuration url pattern should contains {admin} placeholder'); } if (false === strstr($value, '{action}')) { throw new InvalidOptionsException('Admin routing configuration url pattern should contains the {action} placeholder'); } return $value; }) ; // admin field type mapping $this->setFieldsOptions($resolver); }
php
public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefaults([ // enable or disable extra configuration listener 'enable_extra_configuration' => true, 'enable_security' => true, 'enable_menus' => true, 'enable_homepage' => true, 'translation' => false, 'translation_pattern' => false, 'title' => 'AdminBundle application', 'description' => '', 'locale' => 'en', // Main base template as bundles are not loaded when reading the configuration, the kernel // locateResources will always failed. So we must not check resource existence here. 'base_template' => '@LAGAdmin/base.html.twig', 'block_template' => '@LAGAdmin/Form/fields.html.twig', 'menu_template' => '@LAGAdmin/Menu/menu.html.twig', 'list_template' => '@LAGAdmin/CRUD/list.html.twig', 'edit_template' => '@LAGAdmin/CRUD/edit.html.twig', 'create_template' => '@LAGAdmin/CRUD/create.html.twig', 'delete_template' => '@LAGAdmin/CRUD/delete.html.twig', 'homepage_template' => '@LAGAdmin/Pages/home.html.twig', 'homepage_route' => 'lag.admin.homepage', 'routing_url_pattern' => '/{admin}/{action}', 'routing_name_pattern' => 'lag.admin.{admin}.{action}', 'bootstrap' => true, 'date_format' => 'Y/m/d', 'pager' => 'pagerfanta', // string length before truncation (0 means no truncation) 'string_length' => 200, 'string_length_truncate' => '...', 'max_per_page' => 20, 'admin_class' => Admin::class, 'action_class' => Action::class, 'permissions' => 'ROLE_ADMIN', 'page_parameter' => 'page', ]) ->setAllowedTypes('enable_extra_configuration', 'boolean') ->setAllowedTypes('enable_security', 'boolean') ->setAllowedTypes('enable_menus', 'boolean') ->setAllowedTypes('title', 'string') ->setAllowedTypes('description', 'string') ->setAllowedTypes('locale', 'string') ->setAllowedTypes('base_template', 'string') ->setAllowedTypes('block_template', 'string') ->setAllowedTypes('bootstrap', 'boolean') ->setAllowedTypes('date_format', 'string') ->setAllowedTypes('string_length', 'integer') ->setAllowedTypes('string_length_truncate', 'string') ->setAllowedTypes('max_per_page', 'integer') ->setAllowedTypes('admin_class', 'string') ->setAllowedTypes('routing_name_pattern', 'string') ->setAllowedTypes('routing_url_pattern', 'string') ->setAllowedTypes('page_parameter', 'string') ->setNormalizer('routing_name_pattern', function(Options $options, $value) { if (false === strstr($value, '{admin}')) { throw new InvalidOptionsException( 'Admin routing configuration pattern name should contains the {admin} placeholder' ); } if (false === strstr($value, '{action}')) { throw new InvalidOptionsException( 'Admin routing configuration pattern name should contains the {action} placeholder' ); } return $value; }) ->setNormalizer('routing_url_pattern', function(Options $options, $value) { if (false === strstr($value, '{admin}')) { throw new InvalidOptionsException('Admin routing configuration url pattern should contains {admin} placeholder'); } if (false === strstr($value, '{action}')) { throw new InvalidOptionsException('Admin routing configuration url pattern should contains the {action} placeholder'); } return $value; }) ; // admin field type mapping $this->setFieldsOptions($resolver); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setDefaults", "(", "[", "// enable or disable extra configuration listener", "'enable_extra_configuration'", "=>", "true", ",", "'enable_security'", "=>", "true", ",", "'enable_menus'", "=>", "true", ",", "'enable_homepage'", "=>", "true", ",", "'translation'", "=>", "false", ",", "'translation_pattern'", "=>", "false", ",", "'title'", "=>", "'AdminBundle application'", ",", "'description'", "=>", "''", ",", "'locale'", "=>", "'en'", ",", "// Main base template as bundles are not loaded when reading the configuration, the kernel", "// locateResources will always failed. So we must not check resource existence here.", "'base_template'", "=>", "'@LAGAdmin/base.html.twig'", ",", "'block_template'", "=>", "'@LAGAdmin/Form/fields.html.twig'", ",", "'menu_template'", "=>", "'@LAGAdmin/Menu/menu.html.twig'", ",", "'list_template'", "=>", "'@LAGAdmin/CRUD/list.html.twig'", ",", "'edit_template'", "=>", "'@LAGAdmin/CRUD/edit.html.twig'", ",", "'create_template'", "=>", "'@LAGAdmin/CRUD/create.html.twig'", ",", "'delete_template'", "=>", "'@LAGAdmin/CRUD/delete.html.twig'", ",", "'homepage_template'", "=>", "'@LAGAdmin/Pages/home.html.twig'", ",", "'homepage_route'", "=>", "'lag.admin.homepage'", ",", "'routing_url_pattern'", "=>", "'/{admin}/{action}'", ",", "'routing_name_pattern'", "=>", "'lag.admin.{admin}.{action}'", ",", "'bootstrap'", "=>", "true", ",", "'date_format'", "=>", "'Y/m/d'", ",", "'pager'", "=>", "'pagerfanta'", ",", "// string length before truncation (0 means no truncation)", "'string_length'", "=>", "200", ",", "'string_length_truncate'", "=>", "'...'", ",", "'max_per_page'", "=>", "20", ",", "'admin_class'", "=>", "Admin", "::", "class", ",", "'action_class'", "=>", "Action", "::", "class", ",", "'permissions'", "=>", "'ROLE_ADMIN'", ",", "'page_parameter'", "=>", "'page'", ",", "]", ")", "->", "setAllowedTypes", "(", "'enable_extra_configuration'", ",", "'boolean'", ")", "->", "setAllowedTypes", "(", "'enable_security'", ",", "'boolean'", ")", "->", "setAllowedTypes", "(", "'enable_menus'", ",", "'boolean'", ")", "->", "setAllowedTypes", "(", "'title'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'description'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'locale'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'base_template'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'block_template'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'bootstrap'", ",", "'boolean'", ")", "->", "setAllowedTypes", "(", "'date_format'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'string_length'", ",", "'integer'", ")", "->", "setAllowedTypes", "(", "'string_length_truncate'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'max_per_page'", ",", "'integer'", ")", "->", "setAllowedTypes", "(", "'admin_class'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'routing_name_pattern'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'routing_url_pattern'", ",", "'string'", ")", "->", "setAllowedTypes", "(", "'page_parameter'", ",", "'string'", ")", "->", "setNormalizer", "(", "'routing_name_pattern'", ",", "function", "(", "Options", "$", "options", ",", "$", "value", ")", "{", "if", "(", "false", "===", "strstr", "(", "$", "value", ",", "'{admin}'", ")", ")", "{", "throw", "new", "InvalidOptionsException", "(", "'Admin routing configuration pattern name should contains the {admin} placeholder'", ")", ";", "}", "if", "(", "false", "===", "strstr", "(", "$", "value", ",", "'{action}'", ")", ")", "{", "throw", "new", "InvalidOptionsException", "(", "'Admin routing configuration pattern name should contains the {action} placeholder'", ")", ";", "}", "return", "$", "value", ";", "}", ")", "->", "setNormalizer", "(", "'routing_url_pattern'", ",", "function", "(", "Options", "$", "options", ",", "$", "value", ")", "{", "if", "(", "false", "===", "strstr", "(", "$", "value", ",", "'{admin}'", ")", ")", "{", "throw", "new", "InvalidOptionsException", "(", "'Admin routing configuration url pattern should contains {admin} placeholder'", ")", ";", "}", "if", "(", "false", "===", "strstr", "(", "$", "value", ",", "'{action}'", ")", ")", "{", "throw", "new", "InvalidOptionsException", "(", "'Admin routing configuration url pattern should contains the {action} placeholder'", ")", ";", "}", "return", "$", "value", ";", "}", ")", ";", "// admin field type mapping", "$", "this", "->", "setFieldsOptions", "(", "$", "resolver", ")", ";", "}" ]
Configure configuration allowed parameters. @param OptionsResolver $resolver
[ "Configure", "configuration", "allowed", "parameters", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Configuration/ApplicationConfiguration.php#L33-L117
38,010
larriereguichet/AdminBundle
src/DependencyInjection/LAGAdminExtension.php
LAGAdminExtension.load
public function load(array $configs, ContainerBuilder $builder) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($builder, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); $loader->load('services/factories.yaml'); $loader->load('services/fields.yaml'); $loader->load('services/resources.yaml'); $loader->load('services/subscribers.yaml'); $loader->load('services/twig.yaml'); if ('dev' === $builder->getParameter('kernel.environment')) { $loader->load('services_dev.yaml'); } $applicationConfig = []; $adminsConfig = []; $menusConfig = []; $enableExtraConfig = true; if (key_exists('application', $config)) { if (key_exists('enable_extra_configuration', $config['application'])) { $enableExtraConfig = $config['application']['enable_extra_configuration']; } $applicationConfig = $config['application']; } if (key_exists('admins', $config)) { $adminsConfig = $config['admins']; } if (key_exists('menus', $config)) { $menusConfig = $config['menus']; foreach ($menusConfig as $name => $menu) { if (null === $menu) { $menusConfig[$name] = []; } } } $builder->setParameter('lag.admin.enable_extra_configuration', $enableExtraConfig); $builder->setParameter('lag.admin.application_configuration', $applicationConfig); $builder->setParameter('lag.admins', $adminsConfig); $builder->setParameter('lag.menus', $menusConfig); }
php
public function load(array $configs, ContainerBuilder $builder) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($builder, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); $loader->load('services/factories.yaml'); $loader->load('services/fields.yaml'); $loader->load('services/resources.yaml'); $loader->load('services/subscribers.yaml'); $loader->load('services/twig.yaml'); if ('dev' === $builder->getParameter('kernel.environment')) { $loader->load('services_dev.yaml'); } $applicationConfig = []; $adminsConfig = []; $menusConfig = []; $enableExtraConfig = true; if (key_exists('application', $config)) { if (key_exists('enable_extra_configuration', $config['application'])) { $enableExtraConfig = $config['application']['enable_extra_configuration']; } $applicationConfig = $config['application']; } if (key_exists('admins', $config)) { $adminsConfig = $config['admins']; } if (key_exists('menus', $config)) { $menusConfig = $config['menus']; foreach ($menusConfig as $name => $menu) { if (null === $menu) { $menusConfig[$name] = []; } } } $builder->setParameter('lag.admin.enable_extra_configuration', $enableExtraConfig); $builder->setParameter('lag.admin.application_configuration', $applicationConfig); $builder->setParameter('lag.admins', $adminsConfig); $builder->setParameter('lag.menus', $menusConfig); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "builder", ")", "{", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "loader", "=", "new", "Loader", "\\", "YamlFileLoader", "(", "$", "builder", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'services.yaml'", ")", ";", "$", "loader", "->", "load", "(", "'services/factories.yaml'", ")", ";", "$", "loader", "->", "load", "(", "'services/fields.yaml'", ")", ";", "$", "loader", "->", "load", "(", "'services/resources.yaml'", ")", ";", "$", "loader", "->", "load", "(", "'services/subscribers.yaml'", ")", ";", "$", "loader", "->", "load", "(", "'services/twig.yaml'", ")", ";", "if", "(", "'dev'", "===", "$", "builder", "->", "getParameter", "(", "'kernel.environment'", ")", ")", "{", "$", "loader", "->", "load", "(", "'services_dev.yaml'", ")", ";", "}", "$", "applicationConfig", "=", "[", "]", ";", "$", "adminsConfig", "=", "[", "]", ";", "$", "menusConfig", "=", "[", "]", ";", "$", "enableExtraConfig", "=", "true", ";", "if", "(", "key_exists", "(", "'application'", ",", "$", "config", ")", ")", "{", "if", "(", "key_exists", "(", "'enable_extra_configuration'", ",", "$", "config", "[", "'application'", "]", ")", ")", "{", "$", "enableExtraConfig", "=", "$", "config", "[", "'application'", "]", "[", "'enable_extra_configuration'", "]", ";", "}", "$", "applicationConfig", "=", "$", "config", "[", "'application'", "]", ";", "}", "if", "(", "key_exists", "(", "'admins'", ",", "$", "config", ")", ")", "{", "$", "adminsConfig", "=", "$", "config", "[", "'admins'", "]", ";", "}", "if", "(", "key_exists", "(", "'menus'", ",", "$", "config", ")", ")", "{", "$", "menusConfig", "=", "$", "config", "[", "'menus'", "]", ";", "foreach", "(", "$", "menusConfig", "as", "$", "name", "=>", "$", "menu", ")", "{", "if", "(", "null", "===", "$", "menu", ")", "{", "$", "menusConfig", "[", "$", "name", "]", "=", "[", "]", ";", "}", "}", "}", "$", "builder", "->", "setParameter", "(", "'lag.admin.enable_extra_configuration'", ",", "$", "enableExtraConfig", ")", ";", "$", "builder", "->", "setParameter", "(", "'lag.admin.application_configuration'", ",", "$", "applicationConfig", ")", ";", "$", "builder", "->", "setParameter", "(", "'lag.admins'", ",", "$", "adminsConfig", ")", ";", "$", "builder", "->", "setParameter", "(", "'lag.menus'", ",", "$", "menusConfig", ")", ";", "}" ]
Load the configuration into the container. @param array $configs @param ContainerBuilder $builder
[ "Load", "the", "configuration", "into", "the", "container", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/DependencyInjection/LAGAdminExtension.php#L21-L66
38,011
fxpio/fxp-resource
Domain/Domain.php
Domain.doPersistList
protected function doPersistList(ResourceListInterface $resources, $autoCommit, $type) { $hasError = false; $hasFlushError = false; foreach ($resources as $i => $resource) { if (!$autoCommit && $hasError) { $resource->setStatus(ResourceStatutes::CANCELED); } elseif ($autoCommit && $hasFlushError && $hasError) { DomainUtil::addResourceError($resource, $this->translator->trans('domain.database_previous_error', [], 'FxpResource')); } else { list($successStatus, $hasFlushError) = $this->doPersistResource($resource, $autoCommit, $type); $hasError = $this->finalizeResourceStatus($resource, $successStatus, $hasError); } } return $hasError; }
php
protected function doPersistList(ResourceListInterface $resources, $autoCommit, $type) { $hasError = false; $hasFlushError = false; foreach ($resources as $i => $resource) { if (!$autoCommit && $hasError) { $resource->setStatus(ResourceStatutes::CANCELED); } elseif ($autoCommit && $hasFlushError && $hasError) { DomainUtil::addResourceError($resource, $this->translator->trans('domain.database_previous_error', [], 'FxpResource')); } else { list($successStatus, $hasFlushError) = $this->doPersistResource($resource, $autoCommit, $type); $hasError = $this->finalizeResourceStatus($resource, $successStatus, $hasError); } } return $hasError; }
[ "protected", "function", "doPersistList", "(", "ResourceListInterface", "$", "resources", ",", "$", "autoCommit", ",", "$", "type", ")", "{", "$", "hasError", "=", "false", ";", "$", "hasFlushError", "=", "false", ";", "foreach", "(", "$", "resources", "as", "$", "i", "=>", "$", "resource", ")", "{", "if", "(", "!", "$", "autoCommit", "&&", "$", "hasError", ")", "{", "$", "resource", "->", "setStatus", "(", "ResourceStatutes", "::", "CANCELED", ")", ";", "}", "elseif", "(", "$", "autoCommit", "&&", "$", "hasFlushError", "&&", "$", "hasError", ")", "{", "DomainUtil", "::", "addResourceError", "(", "$", "resource", ",", "$", "this", "->", "translator", "->", "trans", "(", "'domain.database_previous_error'", ",", "[", "]", ",", "'FxpResource'", ")", ")", ";", "}", "else", "{", "list", "(", "$", "successStatus", ",", "$", "hasFlushError", ")", "=", "$", "this", "->", "doPersistResource", "(", "$", "resource", ",", "$", "autoCommit", ",", "$", "type", ")", ";", "$", "hasError", "=", "$", "this", "->", "finalizeResourceStatus", "(", "$", "resource", ",", "$", "successStatus", ",", "$", "hasError", ")", ";", "}", "}", "return", "$", "hasError", ";", "}" ]
Do persist the resources. @param ResourceListInterface $resources The list of object resource instance @param bool $autoCommit Commit transaction for each resource or all (continue the action even if there is an error on a resource) @param int $type The type of persist action @return bool Check if there is an error in list
[ "Do", "persist", "the", "resources", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L149-L166
38,012
fxpio/fxp-resource
Domain/Domain.php
Domain.doPersistResource
protected function doPersistResource(ResourceInterface $resource, $autoCommit, $type) { $object = $resource->getRealData(); $this->validateUndeleteResource($resource, $type); $this->validateResource($resource, $type); $successStatus = $this->getSuccessStatus($type, $object); $hasFlushError = false; if ($resource->isValid()) { try { $this->om->persist($object); $hasFlushError = $this->doAutoCommitFlushTransaction($resource, $autoCommit); } catch (\Exception $e) { $hasFlushError = DomainUtil::injectErrorMessage($this->translator, $resource, $e, $this->debug); } } return [$successStatus, $hasFlushError]; }
php
protected function doPersistResource(ResourceInterface $resource, $autoCommit, $type) { $object = $resource->getRealData(); $this->validateUndeleteResource($resource, $type); $this->validateResource($resource, $type); $successStatus = $this->getSuccessStatus($type, $object); $hasFlushError = false; if ($resource->isValid()) { try { $this->om->persist($object); $hasFlushError = $this->doAutoCommitFlushTransaction($resource, $autoCommit); } catch (\Exception $e) { $hasFlushError = DomainUtil::injectErrorMessage($this->translator, $resource, $e, $this->debug); } } return [$successStatus, $hasFlushError]; }
[ "protected", "function", "doPersistResource", "(", "ResourceInterface", "$", "resource", ",", "$", "autoCommit", ",", "$", "type", ")", "{", "$", "object", "=", "$", "resource", "->", "getRealData", "(", ")", ";", "$", "this", "->", "validateUndeleteResource", "(", "$", "resource", ",", "$", "type", ")", ";", "$", "this", "->", "validateResource", "(", "$", "resource", ",", "$", "type", ")", ";", "$", "successStatus", "=", "$", "this", "->", "getSuccessStatus", "(", "$", "type", ",", "$", "object", ")", ";", "$", "hasFlushError", "=", "false", ";", "if", "(", "$", "resource", "->", "isValid", "(", ")", ")", "{", "try", "{", "$", "this", "->", "om", "->", "persist", "(", "$", "object", ")", ";", "$", "hasFlushError", "=", "$", "this", "->", "doAutoCommitFlushTransaction", "(", "$", "resource", ",", "$", "autoCommit", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "hasFlushError", "=", "DomainUtil", "::", "injectErrorMessage", "(", "$", "this", "->", "translator", ",", "$", "resource", ",", "$", "e", ",", "$", "this", "->", "debug", ")", ";", "}", "}", "return", "[", "$", "successStatus", ",", "$", "hasFlushError", "]", ";", "}" ]
Do persist a resource. @param ResourceInterface $resource The resource @param bool $autoCommit Commit transaction for each resource or all (continue the action even if there is an error on a resource) @param int $type The type of persist action @return array The successStatus and hasFlushError value
[ "Do", "persist", "a", "resource", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L178-L196
38,013
fxpio/fxp-resource
Domain/Domain.php
Domain.validateUndeleteResource
protected function validateUndeleteResource(ResourceInterface $resource, $type): void { if (static::TYPE_UNDELETE === $type) { $object = $resource->getRealData(); if ($object instanceof SoftDeletableInterface) { $object->setDeletedAt(); } else { DomainUtil::addResourceError($resource, $this->translator->trans('domain.resource_type_not_undeleted', [], 'FxpResource')); } } }
php
protected function validateUndeleteResource(ResourceInterface $resource, $type): void { if (static::TYPE_UNDELETE === $type) { $object = $resource->getRealData(); if ($object instanceof SoftDeletableInterface) { $object->setDeletedAt(); } else { DomainUtil::addResourceError($resource, $this->translator->trans('domain.resource_type_not_undeleted', [], 'FxpResource')); } } }
[ "protected", "function", "validateUndeleteResource", "(", "ResourceInterface", "$", "resource", ",", "$", "type", ")", ":", "void", "{", "if", "(", "static", "::", "TYPE_UNDELETE", "===", "$", "type", ")", "{", "$", "object", "=", "$", "resource", "->", "getRealData", "(", ")", ";", "if", "(", "$", "object", "instanceof", "SoftDeletableInterface", ")", "{", "$", "object", "->", "setDeletedAt", "(", ")", ";", "}", "else", "{", "DomainUtil", "::", "addResourceError", "(", "$", "resource", ",", "$", "this", "->", "translator", "->", "trans", "(", "'domain.resource_type_not_undeleted'", ",", "[", "]", ",", "'FxpResource'", ")", ")", ";", "}", "}", "}" ]
Validate the resource only when type is undelete. @param ResourceInterface $resource The resource @param int $type The type of persist action
[ "Validate", "the", "resource", "only", "when", "type", "is", "undelete", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L204-L215
38,014
fxpio/fxp-resource
Domain/Domain.php
Domain.doDeleteList
protected function doDeleteList(ResourceListInterface $resources, $autoCommit, $soft = true) { $hasError = false; $hasFlushError = false; foreach ($resources as $i => $resource) { list($continue, $hasError) = $this->prepareDeleteResource($resource, $autoCommit, $hasError, $hasFlushError); if (!$continue) { $skipped = $this->doDeleteResource($resource, $soft); $hasFlushError = $this->doAutoCommitFlushTransaction($resource, $autoCommit, $skipped); $hasError = $this->finalizeResourceStatus($resource, ResourceStatutes::DELETED, $hasError); } } return $hasError; }
php
protected function doDeleteList(ResourceListInterface $resources, $autoCommit, $soft = true) { $hasError = false; $hasFlushError = false; foreach ($resources as $i => $resource) { list($continue, $hasError) = $this->prepareDeleteResource($resource, $autoCommit, $hasError, $hasFlushError); if (!$continue) { $skipped = $this->doDeleteResource($resource, $soft); $hasFlushError = $this->doAutoCommitFlushTransaction($resource, $autoCommit, $skipped); $hasError = $this->finalizeResourceStatus($resource, ResourceStatutes::DELETED, $hasError); } } return $hasError; }
[ "protected", "function", "doDeleteList", "(", "ResourceListInterface", "$", "resources", ",", "$", "autoCommit", ",", "$", "soft", "=", "true", ")", "{", "$", "hasError", "=", "false", ";", "$", "hasFlushError", "=", "false", ";", "foreach", "(", "$", "resources", "as", "$", "i", "=>", "$", "resource", ")", "{", "list", "(", "$", "continue", ",", "$", "hasError", ")", "=", "$", "this", "->", "prepareDeleteResource", "(", "$", "resource", ",", "$", "autoCommit", ",", "$", "hasError", ",", "$", "hasFlushError", ")", ";", "if", "(", "!", "$", "continue", ")", "{", "$", "skipped", "=", "$", "this", "->", "doDeleteResource", "(", "$", "resource", ",", "$", "soft", ")", ";", "$", "hasFlushError", "=", "$", "this", "->", "doAutoCommitFlushTransaction", "(", "$", "resource", ",", "$", "autoCommit", ",", "$", "skipped", ")", ";", "$", "hasError", "=", "$", "this", "->", "finalizeResourceStatus", "(", "$", "resource", ",", "ResourceStatutes", "::", "DELETED", ",", "$", "hasError", ")", ";", "}", "}", "return", "$", "hasError", ";", "}" ]
Do delete the resources. @param ResourceListInterface $resources The list of object resource instance @param bool $autoCommit Commit transaction for each resource or all (continue the action even if there is an error on a resource) @param bool $soft The soft deletable @return bool Check if there is an error in list
[ "Do", "delete", "the", "resources", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L227-L243
38,015
fxpio/fxp-resource
Domain/Domain.php
Domain.prepareDeleteResource
protected function prepareDeleteResource(ResourceInterface $resource, $autoCommit, $hasError, $hasFlushError) { $continue = false; if (!$autoCommit && $hasError) { $resource->setStatus(ResourceStatutes::CANCELED); $continue = true; } elseif ($autoCommit && $hasFlushError && $hasError) { DomainUtil::addResourceError($resource, $this->translator->trans('domain.database_previous_error', [], 'FxpResource')); $continue = true; } elseif (null !== $idError = $this->getErrorIdentifier($resource->getRealData(), static::TYPE_DELETE)) { $hasError = true; $resource->setStatus(ResourceStatutes::ERROR); $resource->getErrors()->add(new ConstraintViolation($idError, $idError, [], $resource->getRealData(), null, null)); $continue = true; } return [$continue, $hasError]; }
php
protected function prepareDeleteResource(ResourceInterface $resource, $autoCommit, $hasError, $hasFlushError) { $continue = false; if (!$autoCommit && $hasError) { $resource->setStatus(ResourceStatutes::CANCELED); $continue = true; } elseif ($autoCommit && $hasFlushError && $hasError) { DomainUtil::addResourceError($resource, $this->translator->trans('domain.database_previous_error', [], 'FxpResource')); $continue = true; } elseif (null !== $idError = $this->getErrorIdentifier($resource->getRealData(), static::TYPE_DELETE)) { $hasError = true; $resource->setStatus(ResourceStatutes::ERROR); $resource->getErrors()->add(new ConstraintViolation($idError, $idError, [], $resource->getRealData(), null, null)); $continue = true; } return [$continue, $hasError]; }
[ "protected", "function", "prepareDeleteResource", "(", "ResourceInterface", "$", "resource", ",", "$", "autoCommit", ",", "$", "hasError", ",", "$", "hasFlushError", ")", "{", "$", "continue", "=", "false", ";", "if", "(", "!", "$", "autoCommit", "&&", "$", "hasError", ")", "{", "$", "resource", "->", "setStatus", "(", "ResourceStatutes", "::", "CANCELED", ")", ";", "$", "continue", "=", "true", ";", "}", "elseif", "(", "$", "autoCommit", "&&", "$", "hasFlushError", "&&", "$", "hasError", ")", "{", "DomainUtil", "::", "addResourceError", "(", "$", "resource", ",", "$", "this", "->", "translator", "->", "trans", "(", "'domain.database_previous_error'", ",", "[", "]", ",", "'FxpResource'", ")", ")", ";", "$", "continue", "=", "true", ";", "}", "elseif", "(", "null", "!==", "$", "idError", "=", "$", "this", "->", "getErrorIdentifier", "(", "$", "resource", "->", "getRealData", "(", ")", ",", "static", "::", "TYPE_DELETE", ")", ")", "{", "$", "hasError", "=", "true", ";", "$", "resource", "->", "setStatus", "(", "ResourceStatutes", "::", "ERROR", ")", ";", "$", "resource", "->", "getErrors", "(", ")", "->", "add", "(", "new", "ConstraintViolation", "(", "$", "idError", ",", "$", "idError", ",", "[", "]", ",", "$", "resource", "->", "getRealData", "(", ")", ",", "null", ",", "null", ")", ")", ";", "$", "continue", "=", "true", ";", "}", "return", "[", "$", "continue", ",", "$", "hasError", "]", ";", "}" ]
Prepare the deletion of resource. @param ResourceInterface $resource The resource @param bool $autoCommit Commit transaction for each resource or all (continue the action even if there is an error on a resource) @param bool $hasError Check if there is an previous error @param bool $hasFlushError Check if there is an previous flush error @return array The check if the delete action must be continued and check if there is an error
[ "Prepare", "the", "deletion", "of", "resource", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L256-L274
38,016
fxpio/fxp-resource
Domain/Domain.php
Domain.doDeleteResource
protected function doDeleteResource(ResourceInterface $resource, $soft) { $skipped = false; $object = $resource->getRealData(); if ($object instanceof SoftDeletableInterface) { if ($soft) { if ($object->isDeleted()) { $skipped = true; } else { $this->doDeleteResourceAction($resource); } } else { if (!$object->isDeleted()) { $object->setDeletedAt(new \DateTime()); } $this->doDeleteResourceAction($resource); } } else { $this->doDeleteResourceAction($resource); } return $skipped; }
php
protected function doDeleteResource(ResourceInterface $resource, $soft) { $skipped = false; $object = $resource->getRealData(); if ($object instanceof SoftDeletableInterface) { if ($soft) { if ($object->isDeleted()) { $skipped = true; } else { $this->doDeleteResourceAction($resource); } } else { if (!$object->isDeleted()) { $object->setDeletedAt(new \DateTime()); } $this->doDeleteResourceAction($resource); } } else { $this->doDeleteResourceAction($resource); } return $skipped; }
[ "protected", "function", "doDeleteResource", "(", "ResourceInterface", "$", "resource", ",", "$", "soft", ")", "{", "$", "skipped", "=", "false", ";", "$", "object", "=", "$", "resource", "->", "getRealData", "(", ")", ";", "if", "(", "$", "object", "instanceof", "SoftDeletableInterface", ")", "{", "if", "(", "$", "soft", ")", "{", "if", "(", "$", "object", "->", "isDeleted", "(", ")", ")", "{", "$", "skipped", "=", "true", ";", "}", "else", "{", "$", "this", "->", "doDeleteResourceAction", "(", "$", "resource", ")", ";", "}", "}", "else", "{", "if", "(", "!", "$", "object", "->", "isDeleted", "(", ")", ")", "{", "$", "object", "->", "setDeletedAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "}", "$", "this", "->", "doDeleteResourceAction", "(", "$", "resource", ")", ";", "}", "}", "else", "{", "$", "this", "->", "doDeleteResourceAction", "(", "$", "resource", ")", ";", "}", "return", "$", "skipped", ";", "}" ]
Do delete a resource. @param ResourceInterface $resource The resource @param bool $soft The soft deletable @throws @return bool Check if the resource is skipped or deleted
[ "Do", "delete", "a", "resource", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L286-L309
38,017
fxpio/fxp-resource
Domain/Domain.php
Domain.doDeleteResourceAction
protected function doDeleteResourceAction(ResourceInterface $resource): void { try { $this->om->remove($resource->getRealData()); } catch (\Exception $e) { DomainUtil::injectErrorMessage($this->translator, $resource, $e, $this->debug); } }
php
protected function doDeleteResourceAction(ResourceInterface $resource): void { try { $this->om->remove($resource->getRealData()); } catch (\Exception $e) { DomainUtil::injectErrorMessage($this->translator, $resource, $e, $this->debug); } }
[ "protected", "function", "doDeleteResourceAction", "(", "ResourceInterface", "$", "resource", ")", ":", "void", "{", "try", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "resource", "->", "getRealData", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DomainUtil", "::", "injectErrorMessage", "(", "$", "this", "->", "translator", ",", "$", "resource", ",", "$", "e", ",", "$", "this", "->", "debug", ")", ";", "}", "}" ]
Real delete a entity in object manager. @param ResourceInterface $resource The resource
[ "Real", "delete", "a", "entity", "in", "object", "manager", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/Domain.php#L316-L323
38,018
hnhdigital-os/laravel-frontend-assets
src/GoogleMaps.php
GoogleMaps.loadExtensions
private function loadExtensions($extensions) { $extensions = Arr::wrap($extensions); foreach ($extensions as $extension) { $extension = 'ext'.$extension; if (method_exists($this, $extension)) { $this->$extension(); } } }
php
private function loadExtensions($extensions) { $extensions = Arr::wrap($extensions); foreach ($extensions as $extension) { $extension = 'ext'.$extension; if (method_exists($this, $extension)) { $this->$extension(); } } }
[ "private", "function", "loadExtensions", "(", "$", "extensions", ")", "{", "$", "extensions", "=", "Arr", "::", "wrap", "(", "$", "extensions", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "extension", "=", "'ext'", ".", "$", "extension", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "extension", ")", ")", "{", "$", "this", "->", "$", "extension", "(", ")", ";", "}", "}", "}" ]
Load requested extensions. @param string|array $extensions @return void
[ "Load", "requested", "extensions", "." ]
242f605bf0c052f4d82421a8b95f227d46162e34
https://github.com/hnhdigital-os/laravel-frontend-assets/blob/242f605bf0c052f4d82421a8b95f227d46162e34/src/GoogleMaps.php#L28-L39
38,019
larriereguichet/AdminBundle
src/Event/Subscriber/AdminSubscriber.php
AdminSubscriber.handleRequest
public function handleRequest(AdminEvent $event) { $actionName = $event->getRequest()->get('_action'); if (null === $actionName) { throw new Exception('The _action was not found in the request'); } $admin = $event->getAdmin(); $action = $this->actionFactory->create($actionName, $admin->getName(), $admin->getConfiguration()); $event->setAction($action); }
php
public function handleRequest(AdminEvent $event) { $actionName = $event->getRequest()->get('_action'); if (null === $actionName) { throw new Exception('The _action was not found in the request'); } $admin = $event->getAdmin(); $action = $this->actionFactory->create($actionName, $admin->getName(), $admin->getConfiguration()); $event->setAction($action); }
[ "public", "function", "handleRequest", "(", "AdminEvent", "$", "event", ")", "{", "$", "actionName", "=", "$", "event", "->", "getRequest", "(", ")", "->", "get", "(", "'_action'", ")", ";", "if", "(", "null", "===", "$", "actionName", ")", "{", "throw", "new", "Exception", "(", "'The _action was not found in the request'", ")", ";", "}", "$", "admin", "=", "$", "event", "->", "getAdmin", "(", ")", ";", "$", "action", "=", "$", "this", "->", "actionFactory", "->", "create", "(", "$", "actionName", ",", "$", "admin", "->", "getName", "(", ")", ",", "$", "admin", "->", "getConfiguration", "(", ")", ")", ";", "$", "event", "->", "setAction", "(", "$", "action", ")", ";", "}" ]
Define the current action according to the routing configuration. @param AdminEvent $event @throws Exception
[ "Define", "the", "current", "action", "according", "to", "the", "routing", "configuration", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/AdminSubscriber.php#L116-L127
38,020
larriereguichet/AdminBundle
src/Event/Subscriber/AdminSubscriber.php
AdminSubscriber.createView
public function createView(ViewEvent $event) { $admin = $event->getAdmin(); $action = $admin->getAction(); $menuEvent = new MenuEvent($admin->getAction()->getConfiguration()->getParameter('menus')); $this->eventDispatcher->dispatch(Events::MENU, $menuEvent); $formName = ''; // The form name is different according to the current action if ('edit' === $action->getName()) { $formName = 'entity'; } elseif ('create' === $action->getName()) { $formName = 'entity'; } elseif ('delete' === $action->getName()) { $formName = 'delete'; } if ($this->shouldRedirect($admin, $action, $formName, $event->getRequest(), $admin->getConfiguration())) { $url = $this->getRedirectionUrl( $admin, $action, $admin->getConfiguration(), $event->getRequest() ); $view = new RedirectView( $action->getName(), $admin->getName(), $action->getConfiguration(), $admin->getConfiguration() ); $view->setUrl($url); } else { $view = $this->viewFactory->create( $event->getRequest(), $action->getName(), $admin->getName(), $admin->getConfiguration(), $action->getConfiguration(), $admin->getEntities(), $admin->getForms() ); } $event->setView($view); }
php
public function createView(ViewEvent $event) { $admin = $event->getAdmin(); $action = $admin->getAction(); $menuEvent = new MenuEvent($admin->getAction()->getConfiguration()->getParameter('menus')); $this->eventDispatcher->dispatch(Events::MENU, $menuEvent); $formName = ''; // The form name is different according to the current action if ('edit' === $action->getName()) { $formName = 'entity'; } elseif ('create' === $action->getName()) { $formName = 'entity'; } elseif ('delete' === $action->getName()) { $formName = 'delete'; } if ($this->shouldRedirect($admin, $action, $formName, $event->getRequest(), $admin->getConfiguration())) { $url = $this->getRedirectionUrl( $admin, $action, $admin->getConfiguration(), $event->getRequest() ); $view = new RedirectView( $action->getName(), $admin->getName(), $action->getConfiguration(), $admin->getConfiguration() ); $view->setUrl($url); } else { $view = $this->viewFactory->create( $event->getRequest(), $action->getName(), $admin->getName(), $admin->getConfiguration(), $action->getConfiguration(), $admin->getEntities(), $admin->getForms() ); } $event->setView($view); }
[ "public", "function", "createView", "(", "ViewEvent", "$", "event", ")", "{", "$", "admin", "=", "$", "event", "->", "getAdmin", "(", ")", ";", "$", "action", "=", "$", "admin", "->", "getAction", "(", ")", ";", "$", "menuEvent", "=", "new", "MenuEvent", "(", "$", "admin", "->", "getAction", "(", ")", "->", "getConfiguration", "(", ")", "->", "getParameter", "(", "'menus'", ")", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Events", "::", "MENU", ",", "$", "menuEvent", ")", ";", "$", "formName", "=", "''", ";", "// The form name is different according to the current action", "if", "(", "'edit'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "formName", "=", "'entity'", ";", "}", "elseif", "(", "'create'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "formName", "=", "'entity'", ";", "}", "elseif", "(", "'delete'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "formName", "=", "'delete'", ";", "}", "if", "(", "$", "this", "->", "shouldRedirect", "(", "$", "admin", ",", "$", "action", ",", "$", "formName", ",", "$", "event", "->", "getRequest", "(", ")", ",", "$", "admin", "->", "getConfiguration", "(", ")", ")", ")", "{", "$", "url", "=", "$", "this", "->", "getRedirectionUrl", "(", "$", "admin", ",", "$", "action", ",", "$", "admin", "->", "getConfiguration", "(", ")", ",", "$", "event", "->", "getRequest", "(", ")", ")", ";", "$", "view", "=", "new", "RedirectView", "(", "$", "action", "->", "getName", "(", ")", ",", "$", "admin", "->", "getName", "(", ")", ",", "$", "action", "->", "getConfiguration", "(", ")", ",", "$", "admin", "->", "getConfiguration", "(", ")", ")", ";", "$", "view", "->", "setUrl", "(", "$", "url", ")", ";", "}", "else", "{", "$", "view", "=", "$", "this", "->", "viewFactory", "->", "create", "(", "$", "event", "->", "getRequest", "(", ")", ",", "$", "action", "->", "getName", "(", ")", ",", "$", "admin", "->", "getName", "(", ")", ",", "$", "admin", "->", "getConfiguration", "(", ")", ",", "$", "action", "->", "getConfiguration", "(", ")", ",", "$", "admin", "->", "getEntities", "(", ")", ",", "$", "admin", "->", "getForms", "(", ")", ")", ";", "}", "$", "event", "->", "setView", "(", "$", "view", ")", ";", "}" ]
Create a view using the view factory. @param ViewEvent $event
[ "Create", "a", "view", "using", "the", "view", "factory", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/AdminSubscriber.php#L134-L178
38,021
larriereguichet/AdminBundle
src/Event/Subscriber/AdminSubscriber.php
AdminSubscriber.loadEntities
public function loadEntities(EntityEvent $event) { $admin = $event->getAdmin(); $configuration = $admin->getConfiguration(); $actionConfiguration = $admin->getAction()->getConfiguration(); $dataProvider = $this->dataProviderFactory->get($configuration->getParameter('data_provider')); $strategy = $actionConfiguration->getParameter('load_strategy'); $class = $configuration->getParameter('entity'); if (LAGAdminBundle::LOAD_STRATEGY_NONE === $strategy) { return; } elseif (LAGAdminBundle::LOAD_STRATEGY_MULTIPLE === $strategy) { $entities = $dataProvider->getCollection($admin, $event->getFilters()); $event->setEntities($entities); } elseif (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $strategy) { $requirements = $actionConfiguration->getParameter('route_requirements'); $identifier = null; foreach ($requirements as $name => $requirement) { if (null !== $event->getRequest()->get($name)) { $identifier = $event->getRequest()->get($name); break; } } if (null === $identifier) { throw new Exception('Unable to find a identifier for the class "'.$class.'"'); } $entity = $dataProvider->get($admin, $identifier); $event->setEntities(new ArrayCollection([ $entity, ])); } }
php
public function loadEntities(EntityEvent $event) { $admin = $event->getAdmin(); $configuration = $admin->getConfiguration(); $actionConfiguration = $admin->getAction()->getConfiguration(); $dataProvider = $this->dataProviderFactory->get($configuration->getParameter('data_provider')); $strategy = $actionConfiguration->getParameter('load_strategy'); $class = $configuration->getParameter('entity'); if (LAGAdminBundle::LOAD_STRATEGY_NONE === $strategy) { return; } elseif (LAGAdminBundle::LOAD_STRATEGY_MULTIPLE === $strategy) { $entities = $dataProvider->getCollection($admin, $event->getFilters()); $event->setEntities($entities); } elseif (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $strategy) { $requirements = $actionConfiguration->getParameter('route_requirements'); $identifier = null; foreach ($requirements as $name => $requirement) { if (null !== $event->getRequest()->get($name)) { $identifier = $event->getRequest()->get($name); break; } } if (null === $identifier) { throw new Exception('Unable to find a identifier for the class "'.$class.'"'); } $entity = $dataProvider->get($admin, $identifier); $event->setEntities(new ArrayCollection([ $entity, ])); } }
[ "public", "function", "loadEntities", "(", "EntityEvent", "$", "event", ")", "{", "$", "admin", "=", "$", "event", "->", "getAdmin", "(", ")", ";", "$", "configuration", "=", "$", "admin", "->", "getConfiguration", "(", ")", ";", "$", "actionConfiguration", "=", "$", "admin", "->", "getAction", "(", ")", "->", "getConfiguration", "(", ")", ";", "$", "dataProvider", "=", "$", "this", "->", "dataProviderFactory", "->", "get", "(", "$", "configuration", "->", "getParameter", "(", "'data_provider'", ")", ")", ";", "$", "strategy", "=", "$", "actionConfiguration", "->", "getParameter", "(", "'load_strategy'", ")", ";", "$", "class", "=", "$", "configuration", "->", "getParameter", "(", "'entity'", ")", ";", "if", "(", "LAGAdminBundle", "::", "LOAD_STRATEGY_NONE", "===", "$", "strategy", ")", "{", "return", ";", "}", "elseif", "(", "LAGAdminBundle", "::", "LOAD_STRATEGY_MULTIPLE", "===", "$", "strategy", ")", "{", "$", "entities", "=", "$", "dataProvider", "->", "getCollection", "(", "$", "admin", ",", "$", "event", "->", "getFilters", "(", ")", ")", ";", "$", "event", "->", "setEntities", "(", "$", "entities", ")", ";", "}", "elseif", "(", "LAGAdminBundle", "::", "LOAD_STRATEGY_UNIQUE", "===", "$", "strategy", ")", "{", "$", "requirements", "=", "$", "actionConfiguration", "->", "getParameter", "(", "'route_requirements'", ")", ";", "$", "identifier", "=", "null", ";", "foreach", "(", "$", "requirements", "as", "$", "name", "=>", "$", "requirement", ")", "{", "if", "(", "null", "!==", "$", "event", "->", "getRequest", "(", ")", "->", "get", "(", "$", "name", ")", ")", "{", "$", "identifier", "=", "$", "event", "->", "getRequest", "(", ")", "->", "get", "(", "$", "name", ")", ";", "break", ";", "}", "}", "if", "(", "null", "===", "$", "identifier", ")", "{", "throw", "new", "Exception", "(", "'Unable to find a identifier for the class \"'", ".", "$", "class", ".", "'\"'", ")", ";", "}", "$", "entity", "=", "$", "dataProvider", "->", "get", "(", "$", "admin", ",", "$", "identifier", ")", ";", "$", "event", "->", "setEntities", "(", "new", "ArrayCollection", "(", "[", "$", "entity", ",", "]", ")", ")", ";", "}", "}" ]
Load entities into the event data to pass them to the Admin. @param EntityEvent $event @throws Exception
[ "Load", "entities", "into", "the", "event", "data", "to", "pass", "them", "to", "the", "Admin", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/AdminSubscriber.php#L187-L222
38,022
larriereguichet/AdminBundle
src/Event/Subscriber/AdminSubscriber.php
AdminSubscriber.getRedirectionUrl
private function getRedirectionUrl( AdminInterface $admin, ActionInterface $action, AdminConfiguration $configuration, Request $request ): string { if ('edit' === $action->getName()) { $routeName = RoutingLoader::generateRouteName( $admin->getName(), 'list', $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName); return $url; } // When the create form is submitted, the user should be redirected to the edit action after saving the form // data if ('create' === $action->getName()) { $targetAction = 'list'; $routeParameters = []; if (!$request->get('submit_and_redirect')) { $targetAction = 'edit'; $routeParameters = [ 'id' => $admin->getEntities()->first()->getId(), ]; } $routeName = RoutingLoader::generateRouteName( $admin->getName(), $targetAction, $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName, $routeParameters); return $url; } if ('delete' === $action->getName()) { $routeName = RoutingLoader::generateRouteName( $admin->getName(), 'list', $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName); return $url; } throw new Exception('Unable to generate an redirection url for the current action'); }
php
private function getRedirectionUrl( AdminInterface $admin, ActionInterface $action, AdminConfiguration $configuration, Request $request ): string { if ('edit' === $action->getName()) { $routeName = RoutingLoader::generateRouteName( $admin->getName(), 'list', $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName); return $url; } // When the create form is submitted, the user should be redirected to the edit action after saving the form // data if ('create' === $action->getName()) { $targetAction = 'list'; $routeParameters = []; if (!$request->get('submit_and_redirect')) { $targetAction = 'edit'; $routeParameters = [ 'id' => $admin->getEntities()->first()->getId(), ]; } $routeName = RoutingLoader::generateRouteName( $admin->getName(), $targetAction, $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName, $routeParameters); return $url; } if ('delete' === $action->getName()) { $routeName = RoutingLoader::generateRouteName( $admin->getName(), 'list', $configuration->get('routing_name_pattern') ); $url = $this->router->generate($routeName); return $url; } throw new Exception('Unable to generate an redirection url for the current action'); }
[ "private", "function", "getRedirectionUrl", "(", "AdminInterface", "$", "admin", ",", "ActionInterface", "$", "action", ",", "AdminConfiguration", "$", "configuration", ",", "Request", "$", "request", ")", ":", "string", "{", "if", "(", "'edit'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "routeName", "=", "RoutingLoader", "::", "generateRouteName", "(", "$", "admin", "->", "getName", "(", ")", ",", "'list'", ",", "$", "configuration", "->", "get", "(", "'routing_name_pattern'", ")", ")", ";", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ")", ";", "return", "$", "url", ";", "}", "// When the create form is submitted, the user should be redirected to the edit action after saving the form", "// data", "if", "(", "'create'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "targetAction", "=", "'list'", ";", "$", "routeParameters", "=", "[", "]", ";", "if", "(", "!", "$", "request", "->", "get", "(", "'submit_and_redirect'", ")", ")", "{", "$", "targetAction", "=", "'edit'", ";", "$", "routeParameters", "=", "[", "'id'", "=>", "$", "admin", "->", "getEntities", "(", ")", "->", "first", "(", ")", "->", "getId", "(", ")", ",", "]", ";", "}", "$", "routeName", "=", "RoutingLoader", "::", "generateRouteName", "(", "$", "admin", "->", "getName", "(", ")", ",", "$", "targetAction", ",", "$", "configuration", "->", "get", "(", "'routing_name_pattern'", ")", ")", ";", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ",", "$", "routeParameters", ")", ";", "return", "$", "url", ";", "}", "if", "(", "'delete'", "===", "$", "action", "->", "getName", "(", ")", ")", "{", "$", "routeName", "=", "RoutingLoader", "::", "generateRouteName", "(", "$", "admin", "->", "getName", "(", ")", ",", "'list'", ",", "$", "configuration", "->", "get", "(", "'routing_name_pattern'", ")", ")", ";", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ")", ";", "return", "$", "url", ";", "}", "throw", "new", "Exception", "(", "'Unable to generate an redirection url for the current action'", ")", ";", "}" ]
Return the url where the user should be redirected to. An exception will be thrown if no url can be generated. @param AdminInterface $admin @param ActionInterface $action @param AdminConfiguration $configuration @param Request $request @return string @throws Exception
[ "Return", "the", "url", "where", "the", "user", "should", "be", "redirected", "to", ".", "An", "exception", "will", "be", "thrown", "if", "no", "url", "can", "be", "generated", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Event/Subscriber/AdminSubscriber.php#L335-L386
38,023
larriereguichet/AdminBundle
src/Bridge/Doctrine/ORM/Helper/MetadataTrait.php
MetadataTrait.findMetadata
protected function findMetadata($class) { $metadata = null; try { // We could not use the hasMetadataFor() method as it is not working if the entity is not loaded. But // the getMetadataFor() method could throw an exception if the class is not found $metadata = $this->entityManager->getMetadataFactory()->getMetadataFor($class); } catch (Exception $exception) { // If an exception is raised, nothing to do. Extra data from metadata will be not used. } return $metadata; }
php
protected function findMetadata($class) { $metadata = null; try { // We could not use the hasMetadataFor() method as it is not working if the entity is not loaded. But // the getMetadataFor() method could throw an exception if the class is not found $metadata = $this->entityManager->getMetadataFactory()->getMetadataFor($class); } catch (Exception $exception) { // If an exception is raised, nothing to do. Extra data from metadata will be not used. } return $metadata; }
[ "protected", "function", "findMetadata", "(", "$", "class", ")", "{", "$", "metadata", "=", "null", ";", "try", "{", "// We could not use the hasMetadataFor() method as it is not working if the entity is not loaded. But", "// the getMetadataFor() method could throw an exception if the class is not found", "$", "metadata", "=", "$", "this", "->", "entityManager", "->", "getMetadataFactory", "(", ")", "->", "getMetadataFor", "(", "$", "class", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "// If an exception is raised, nothing to do. Extra data from metadata will be not used.", "}", "return", "$", "metadata", ";", "}" ]
Return the Doctrine metadata of the given class. @param $class @return ClassMetadata|null
[ "Return", "the", "Doctrine", "metadata", "of", "the", "given", "class", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Doctrine/ORM/Helper/MetadataTrait.php#L26-L39
38,024
larriereguichet/AdminBundle
src/Field/Helper/FieldConfigurationHelper.php
FieldConfigurationHelper.getActionField
private function getActionField(array $fields): ?string { $mapping = [ 'title', 'name', 'id', ]; foreach ($mapping as $name) { if (in_array($name, $fields)) { return $name; } } return null; }
php
private function getActionField(array $fields): ?string { $mapping = [ 'title', 'name', 'id', ]; foreach ($mapping as $name) { if (in_array($name, $fields)) { return $name; } } return null; }
[ "private", "function", "getActionField", "(", "array", "$", "fields", ")", ":", "?", "string", "{", "$", "mapping", "=", "[", "'title'", ",", "'name'", ",", "'id'", ",", "]", ";", "foreach", "(", "$", "mapping", "as", "$", "name", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "fields", ")", ")", "{", "return", "$", "name", ";", "}", "}", "return", "null", ";", "}" ]
Return the default action field if found. @param array $fields @return string|null
[ "Return", "the", "default", "action", "field", "if", "found", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Field/Helper/FieldConfigurationHelper.php#L260-L275
38,025
larriereguichet/AdminBundle
src/Utils/FormUtils.php
FormUtils.convertShortFormType
public static function convertShortFormType(?string $shortType): ?string { $mapping = [ 'choice' => ChoiceType::class, 'string' => TextType::class, 'entity' => EntityType::class, 'date' => DateType::class, 'datetime' => DateType::class, 'text' => TextareaType::class, 'number' => NumberType::class, 'float' => NumberType::class, 'integer' => IntegerType::class, 'smallint' => IntegerType::class, 'boolean' => CheckboxType::class, 'bigint' => NumberType::class, 'decimal' => NumberType::class, 'guid' => TextType::class, 'array' => TextareaType::class, 'simple_array' => TextareaType::class, 'json_array' => TextareaType::class, ]; $type = $shortType; if (key_exists($shortType, $mapping)) { $type = $mapping[$shortType]; } return $type; }
php
public static function convertShortFormType(?string $shortType): ?string { $mapping = [ 'choice' => ChoiceType::class, 'string' => TextType::class, 'entity' => EntityType::class, 'date' => DateType::class, 'datetime' => DateType::class, 'text' => TextareaType::class, 'number' => NumberType::class, 'float' => NumberType::class, 'integer' => IntegerType::class, 'smallint' => IntegerType::class, 'boolean' => CheckboxType::class, 'bigint' => NumberType::class, 'decimal' => NumberType::class, 'guid' => TextType::class, 'array' => TextareaType::class, 'simple_array' => TextareaType::class, 'json_array' => TextareaType::class, ]; $type = $shortType; if (key_exists($shortType, $mapping)) { $type = $mapping[$shortType]; } return $type; }
[ "public", "static", "function", "convertShortFormType", "(", "?", "string", "$", "shortType", ")", ":", "?", "string", "{", "$", "mapping", "=", "[", "'choice'", "=>", "ChoiceType", "::", "class", ",", "'string'", "=>", "TextType", "::", "class", ",", "'entity'", "=>", "EntityType", "::", "class", ",", "'date'", "=>", "DateType", "::", "class", ",", "'datetime'", "=>", "DateType", "::", "class", ",", "'text'", "=>", "TextareaType", "::", "class", ",", "'number'", "=>", "NumberType", "::", "class", ",", "'float'", "=>", "NumberType", "::", "class", ",", "'integer'", "=>", "IntegerType", "::", "class", ",", "'smallint'", "=>", "IntegerType", "::", "class", ",", "'boolean'", "=>", "CheckboxType", "::", "class", ",", "'bigint'", "=>", "NumberType", "::", "class", ",", "'decimal'", "=>", "NumberType", "::", "class", ",", "'guid'", "=>", "TextType", "::", "class", ",", "'array'", "=>", "TextareaType", "::", "class", ",", "'simple_array'", "=>", "TextareaType", "::", "class", ",", "'json_array'", "=>", "TextareaType", "::", "class", ",", "]", ";", "$", "type", "=", "$", "shortType", ";", "if", "(", "key_exists", "(", "$", "shortType", ",", "$", "mapping", ")", ")", "{", "$", "type", "=", "$", "mapping", "[", "$", "shortType", "]", ";", "}", "return", "$", "type", ";", "}" ]
Convert a shortcut type into its class type. @param string|null $shortType @return string|null
[ "Convert", "a", "shortcut", "type", "into", "its", "class", "type", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Utils/FormUtils.php#L23-L51
38,026
larriereguichet/AdminBundle
src/Bridge/Twig/Extension/MenuExtension.php
MenuExtension.getMenu
public function getMenu(string $name, ViewInterface $view = null) { $menu = $this->menuFactory->getMenu($name); return $this->environment->render($menu->get('template'), [ 'menu' => $menu, 'admin' => $view, ]); }
php
public function getMenu(string $name, ViewInterface $view = null) { $menu = $this->menuFactory->getMenu($name); return $this->environment->render($menu->get('template'), [ 'menu' => $menu, 'admin' => $view, ]); }
[ "public", "function", "getMenu", "(", "string", "$", "name", ",", "ViewInterface", "$", "view", "=", "null", ")", "{", "$", "menu", "=", "$", "this", "->", "menuFactory", "->", "getMenu", "(", "$", "name", ")", ";", "return", "$", "this", "->", "environment", "->", "render", "(", "$", "menu", "->", "get", "(", "'template'", ")", ",", "[", "'menu'", "=>", "$", "menu", ",", "'admin'", "=>", "$", "view", ",", "]", ")", ";", "}" ]
Render a menu according to given name. @param string $name @param ViewInterface|null $view @return string
[ "Render", "a", "menu", "according", "to", "given", "name", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Twig/Extension/MenuExtension.php#L45-L53
38,027
yawik/cv
src/Repository/Cv.php
Cv.findDraft
public function findDraft($user) { if ($user instanceof UserInterface) { $user = $user->getId(); } return $this->findOneDraftBy(['user' => $user]); }
php
public function findDraft($user) { if ($user instanceof UserInterface) { $user = $user->getId(); } return $this->findOneDraftBy(['user' => $user]); }
[ "public", "function", "findDraft", "(", "$", "user", ")", "{", "if", "(", "$", "user", "instanceof", "UserInterface", ")", "{", "$", "user", "=", "$", "user", "->", "getId", "(", ")", ";", "}", "return", "$", "this", "->", "findOneDraftBy", "(", "[", "'user'", "=>", "$", "user", "]", ")", ";", "}" ]
Look for an drafted Document of a given user @param $user @return CvEntity|null
[ "Look", "for", "an", "drafted", "Document", "of", "a", "given", "user" ]
a3c57c060d3f1c353c3e8ef3542b77147d4ec012
https://github.com/yawik/cv/blob/a3c57c060d3f1c353c3e8ef3542b77147d4ec012/src/Repository/Cv.php#L28-L35
38,028
systemson/common
src/Validator/Validator.php
Validator.isString
protected function isString(...$args) { foreach ($args as $arg) { if (!is_string($arg) || $arg === '') { return false; } } return true; }
php
protected function isString(...$args) { foreach ($args as $arg) { if (!is_string($arg) || $arg === '') { return false; } } return true; }
[ "protected", "function", "isString", "(", "...", "$", "args", ")", "{", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "!", "is_string", "(", "$", "arg", ")", "||", "$", "arg", "===", "''", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the specified argument is a valid string. @param string $arg The argument to validate. @return bool True if the specified argument is valid. False if it does not.
[ "Checks", "if", "the", "specified", "argument", "is", "a", "valid", "string", "." ]
00333341bbdba6cd1e4cdb7561f7e17bc756935e
https://github.com/systemson/common/blob/00333341bbdba6cd1e4cdb7561f7e17bc756935e/src/Validator/Validator.php#L21-L30
38,029
systemson/common
src/Validator/Validator.php
Validator.isIterable
protected function isIterable(...$args) { foreach ($args as $arg) { if (!is_array($arg) && !$arg instanceof \IteratorAggregate) { return false; } } return true; }
php
protected function isIterable(...$args) { foreach ($args as $arg) { if (!is_array($arg) && !$arg instanceof \IteratorAggregate) { return false; } } return true; }
[ "protected", "function", "isIterable", "(", "...", "$", "args", ")", "{", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "!", "is_array", "(", "$", "arg", ")", "&&", "!", "$", "arg", "instanceof", "\\", "IteratorAggregate", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the specified argument is a valid iterable. @todo After updating to 7.1 validate with is_iterable(). @param array|object $arg The argument to validate. @return bool True if the specified argument is valid. False if it does not.
[ "Checks", "if", "the", "specified", "argument", "is", "a", "valid", "iterable", "." ]
00333341bbdba6cd1e4cdb7561f7e17bc756935e
https://github.com/systemson/common/blob/00333341bbdba6cd1e4cdb7561f7e17bc756935e/src/Validator/Validator.php#L59-L68
38,030
systemson/common
src/Validator/Validator.php
Validator.isCallable
protected function isCallable($arg, $method = null) { if (is_callable($arg) || is_callable([$arg, $method]) || $this->isClass($arg)) { return true; } return false; }
php
protected function isCallable($arg, $method = null) { if (is_callable($arg) || is_callable([$arg, $method]) || $this->isClass($arg)) { return true; } return false; }
[ "protected", "function", "isCallable", "(", "$", "arg", ",", "$", "method", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "arg", ")", "||", "is_callable", "(", "[", "$", "arg", ",", "$", "method", "]", ")", "||", "$", "this", "->", "isClass", "(", "$", "arg", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the specified argument is a valid callable. @param mixed $arg The argument to validate. @return bool True if the specified argument is valid. False if it does not.
[ "Checks", "if", "the", "specified", "argument", "is", "a", "valid", "callable", "." ]
00333341bbdba6cd1e4cdb7561f7e17bc756935e
https://github.com/systemson/common/blob/00333341bbdba6cd1e4cdb7561f7e17bc756935e/src/Validator/Validator.php#L77-L84
38,031
systemson/common
src/Validator/Validator.php
Validator.isClass
protected function isClass(...$args) { foreach ($args as $arg) { if (!$this->isString($arg) || !class_exists($arg)) { return false; } } return true; }
php
protected function isClass(...$args) { foreach ($args as $arg) { if (!$this->isString($arg) || !class_exists($arg)) { return false; } } return true; }
[ "protected", "function", "isClass", "(", "...", "$", "args", ")", "{", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "!", "$", "this", "->", "isString", "(", "$", "arg", ")", "||", "!", "class_exists", "(", "$", "arg", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the specified argument is a valid class. @param mixed $arg The argument to validate. @return bool True if the specified argument is valid. False if it does not.
[ "Checks", "if", "the", "specified", "argument", "is", "a", "valid", "class", "." ]
00333341bbdba6cd1e4cdb7561f7e17bc756935e
https://github.com/systemson/common/blob/00333341bbdba6cd1e4cdb7561f7e17bc756935e/src/Validator/Validator.php#L93-L102
38,032
ajcastro/fk-adder
src/FkConfig.php
FkConfig.buildFkConfig
public static function buildFkConfig() { $config = require Config::get('fk_adder.fk_datatypes_path'); return collect($config)->map(function ($value, $fk) { list($datatype, $referenceTable) = (explode(',', $value.',')); return new Fluent([ 'datatype' => trim($datatype), 'referenceTable' => trim($referenceTable ?: BaseFk::guessReferenceTable($fk)), ]); }); }
php
public static function buildFkConfig() { $config = require Config::get('fk_adder.fk_datatypes_path'); return collect($config)->map(function ($value, $fk) { list($datatype, $referenceTable) = (explode(',', $value.',')); return new Fluent([ 'datatype' => trim($datatype), 'referenceTable' => trim($referenceTable ?: BaseFk::guessReferenceTable($fk)), ]); }); }
[ "public", "static", "function", "buildFkConfig", "(", ")", "{", "$", "config", "=", "require", "Config", "::", "get", "(", "'fk_adder.fk_datatypes_path'", ")", ";", "return", "collect", "(", "$", "config", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "fk", ")", "{", "list", "(", "$", "datatype", ",", "$", "referenceTable", ")", "=", "(", "explode", "(", "','", ",", "$", "value", ".", "','", ")", ")", ";", "return", "new", "Fluent", "(", "[", "'datatype'", "=>", "trim", "(", "$", "datatype", ")", ",", "'referenceTable'", "=>", "trim", "(", "$", "referenceTable", "?", ":", "BaseFk", "::", "guessReferenceTable", "(", "$", "fk", ")", ")", ",", "]", ")", ";", "}", ")", ";", "}" ]
Build fk config array. @return collect
[ "Build", "fk", "config", "array", "." ]
a79200d8333e1bf897c9069c3a1b575af868b188
https://github.com/ajcastro/fk-adder/blob/a79200d8333e1bf897c9069c3a1b575af868b188/src/FkConfig.php#L22-L34
38,033
fxpio/fxp-resource
ResourceUtil.php
ResourceUtil.convertObjectsToResourceList
public static function convertObjectsToResourceList(array $objects, $requireClass, $allowForm = true) { $list = new ResourceList(); foreach ($objects as $i => $object) { static::validateObjectResource($object, $requireClass, $i, $allowForm); $list->add(new ResourceItem((object) $object)); } return $list; }
php
public static function convertObjectsToResourceList(array $objects, $requireClass, $allowForm = true) { $list = new ResourceList(); foreach ($objects as $i => $object) { static::validateObjectResource($object, $requireClass, $i, $allowForm); $list->add(new ResourceItem((object) $object)); } return $list; }
[ "public", "static", "function", "convertObjectsToResourceList", "(", "array", "$", "objects", ",", "$", "requireClass", ",", "$", "allowForm", "=", "true", ")", "{", "$", "list", "=", "new", "ResourceList", "(", ")", ";", "foreach", "(", "$", "objects", "as", "$", "i", "=>", "$", "object", ")", "{", "static", "::", "validateObjectResource", "(", "$", "object", ",", "$", "requireClass", ",", "$", "i", ",", "$", "allowForm", ")", ";", "$", "list", "->", "add", "(", "new", "ResourceItem", "(", "(", "object", ")", "$", "object", ")", ")", ";", "}", "return", "$", "list", ";", "}" ]
Convert the object data of resource to resource list. @param FormInterface[]|object[] $objects The resource object instance or form of object instance @param string $requireClass The require class name @param bool $allowForm Check if the form is allowed @throws InvalidResourceException When the instance object in the list is not an instance of the required class @return ResourceList
[ "Convert", "the", "object", "data", "of", "resource", "to", "resource", "list", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/ResourceUtil.php#L36-L46
38,034
fxpio/fxp-resource
ResourceUtil.php
ResourceUtil.validateObjectResource
public static function validateObjectResource($object, $requireClass, $i, $allowForm = true): void { if ($allowForm && $object instanceof FormInterface) { $object = $object->getData(); } if (!\is_object($object) || !$object instanceof $requireClass) { throw new UnexpectedTypeException($object, $requireClass, $i); } }
php
public static function validateObjectResource($object, $requireClass, $i, $allowForm = true): void { if ($allowForm && $object instanceof FormInterface) { $object = $object->getData(); } if (!\is_object($object) || !$object instanceof $requireClass) { throw new UnexpectedTypeException($object, $requireClass, $i); } }
[ "public", "static", "function", "validateObjectResource", "(", "$", "object", ",", "$", "requireClass", ",", "$", "i", ",", "$", "allowForm", "=", "true", ")", ":", "void", "{", "if", "(", "$", "allowForm", "&&", "$", "object", "instanceof", "FormInterface", ")", "{", "$", "object", "=", "$", "object", "->", "getData", "(", ")", ";", "}", "if", "(", "!", "\\", "is_object", "(", "$", "object", ")", "||", "!", "$", "object", "instanceof", "$", "requireClass", ")", "{", "throw", "new", "UnexpectedTypeException", "(", "$", "object", ",", "$", "requireClass", ",", "$", "i", ")", ";", "}", "}" ]
Validate the resource object. @param FormInterface|mixed $object The resource object or form of resource object @param string $requireClass The required class @param int $i The position of the object in the list @param bool $allowForm Check if the form is allowed @throws UnexpectedTypeException When the object parameter is not an object or a form instance @throws InvalidResourceException When the object in form is not an object @throws InvalidResourceException When the object instance is not an instance of the required class
[ "Validate", "the", "resource", "object", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/ResourceUtil.php#L60-L69
38,035
larriereguichet/AdminBundle
src/Factory/AdminFactory.php
AdminFactory.supports
public function supports(Request $request) { $routeParameters = $request->get('_route_params'); if (!is_array($routeParameters)) { return false; } if (!key_exists(LAGAdminBundle::REQUEST_PARAMETER_ADMIN, $routeParameters) || !key_exists(LAGAdminBundle::REQUEST_PARAMETER_ACTION, $routeParameters) ) { return false; } if (!$this->resourceCollection->has($routeParameters[LAGAdminBundle::REQUEST_PARAMETER_ADMIN])) { return false; } return true; }
php
public function supports(Request $request) { $routeParameters = $request->get('_route_params'); if (!is_array($routeParameters)) { return false; } if (!key_exists(LAGAdminBundle::REQUEST_PARAMETER_ADMIN, $routeParameters) || !key_exists(LAGAdminBundle::REQUEST_PARAMETER_ACTION, $routeParameters) ) { return false; } if (!$this->resourceCollection->has($routeParameters[LAGAdminBundle::REQUEST_PARAMETER_ADMIN])) { return false; } return true; }
[ "public", "function", "supports", "(", "Request", "$", "request", ")", "{", "$", "routeParameters", "=", "$", "request", "->", "get", "(", "'_route_params'", ")", ";", "if", "(", "!", "is_array", "(", "$", "routeParameters", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "key_exists", "(", "LAGAdminBundle", "::", "REQUEST_PARAMETER_ADMIN", ",", "$", "routeParameters", ")", "||", "!", "key_exists", "(", "LAGAdminBundle", "::", "REQUEST_PARAMETER_ACTION", ",", "$", "routeParameters", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "resourceCollection", "->", "has", "(", "$", "routeParameters", "[", "LAGAdminBundle", "::", "REQUEST_PARAMETER_ADMIN", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Return true if the current Request is supported. Supported means that the Request has the required valid parameters to get an admin from the registry. @param Request $request @return bool
[ "Return", "true", "if", "the", "current", "Request", "is", "supported", ".", "Supported", "means", "that", "the", "Request", "has", "the", "required", "valid", "parameters", "to", "get", "an", "admin", "from", "the", "registry", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Factory/AdminFactory.php#L95-L114
38,036
larriereguichet/AdminBundle
src/Bridge/Twig/Extension/AdminExtension.php
AdminExtension.getMenuAction
public function getMenuAction(MenuItemConfiguration $configuration, ViewInterface $view = null): string { if ($configuration->getParameter('url')) { return $configuration->getParameter('url'); } $routeName = $configuration->getParameter('route'); if ($configuration->getParameter('admin')) { $routeName = RoutingLoader::generateRouteName( $configuration->getParameter('admin'), $configuration->getParameter('action'), $this ->applicationConfigurationStorage ->getConfiguration() ->getParameter('routing_name_pattern') ); } // Map the potential parameters to the entity $routeParameters = []; $configuredParameters = $configuration->getParameter('parameters'); if (0 !== count($configuredParameters)) { if (null === $view) { throw new Exception('A view should be provided if the menu item route requires parameters'); } if (!$view->getEntities() instanceof Collection) { throw new Exception( 'Entities returned by the view should be a instance of "'.Collection::class.'" to be used in menu action' ); } if (1 !== $view->getEntities()->count()) { throw new Exception('You can not map route parameters if multiple entities are loaded'); } $entity = $view->getEntities()->first(); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($configuredParameters as $name => $requirements) { $routeParameters[$name] = $accessor->getValue($entity, $name); } } return $this->router->generate($routeName, $routeParameters); }
php
public function getMenuAction(MenuItemConfiguration $configuration, ViewInterface $view = null): string { if ($configuration->getParameter('url')) { return $configuration->getParameter('url'); } $routeName = $configuration->getParameter('route'); if ($configuration->getParameter('admin')) { $routeName = RoutingLoader::generateRouteName( $configuration->getParameter('admin'), $configuration->getParameter('action'), $this ->applicationConfigurationStorage ->getConfiguration() ->getParameter('routing_name_pattern') ); } // Map the potential parameters to the entity $routeParameters = []; $configuredParameters = $configuration->getParameter('parameters'); if (0 !== count($configuredParameters)) { if (null === $view) { throw new Exception('A view should be provided if the menu item route requires parameters'); } if (!$view->getEntities() instanceof Collection) { throw new Exception( 'Entities returned by the view should be a instance of "'.Collection::class.'" to be used in menu action' ); } if (1 !== $view->getEntities()->count()) { throw new Exception('You can not map route parameters if multiple entities are loaded'); } $entity = $view->getEntities()->first(); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($configuredParameters as $name => $requirements) { $routeParameters[$name] = $accessor->getValue($entity, $name); } } return $this->router->generate($routeName, $routeParameters); }
[ "public", "function", "getMenuAction", "(", "MenuItemConfiguration", "$", "configuration", ",", "ViewInterface", "$", "view", "=", "null", ")", ":", "string", "{", "if", "(", "$", "configuration", "->", "getParameter", "(", "'url'", ")", ")", "{", "return", "$", "configuration", "->", "getParameter", "(", "'url'", ")", ";", "}", "$", "routeName", "=", "$", "configuration", "->", "getParameter", "(", "'route'", ")", ";", "if", "(", "$", "configuration", "->", "getParameter", "(", "'admin'", ")", ")", "{", "$", "routeName", "=", "RoutingLoader", "::", "generateRouteName", "(", "$", "configuration", "->", "getParameter", "(", "'admin'", ")", ",", "$", "configuration", "->", "getParameter", "(", "'action'", ")", ",", "$", "this", "->", "applicationConfigurationStorage", "->", "getConfiguration", "(", ")", "->", "getParameter", "(", "'routing_name_pattern'", ")", ")", ";", "}", "// Map the potential parameters to the entity", "$", "routeParameters", "=", "[", "]", ";", "$", "configuredParameters", "=", "$", "configuration", "->", "getParameter", "(", "'parameters'", ")", ";", "if", "(", "0", "!==", "count", "(", "$", "configuredParameters", ")", ")", "{", "if", "(", "null", "===", "$", "view", ")", "{", "throw", "new", "Exception", "(", "'A view should be provided if the menu item route requires parameters'", ")", ";", "}", "if", "(", "!", "$", "view", "->", "getEntities", "(", ")", "instanceof", "Collection", ")", "{", "throw", "new", "Exception", "(", "'Entities returned by the view should be a instance of \"'", ".", "Collection", "::", "class", ".", "'\" to be used in menu action'", ")", ";", "}", "if", "(", "1", "!==", "$", "view", "->", "getEntities", "(", ")", "->", "count", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'You can not map route parameters if multiple entities are loaded'", ")", ";", "}", "$", "entity", "=", "$", "view", "->", "getEntities", "(", ")", "->", "first", "(", ")", ";", "$", "accessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "foreach", "(", "$", "configuredParameters", "as", "$", "name", "=>", "$", "requirements", ")", "{", "$", "routeParameters", "[", "$", "name", "]", "=", "$", "accessor", "->", "getValue", "(", "$", "entity", ",", "$", "name", ")", ";", "}", "}", "return", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ",", "$", "routeParameters", ")", ";", "}" ]
Return the url of an menu item. @param MenuItemConfiguration $configuration @param ViewInterface $view @return string @throws Exception
[ "Return", "the", "url", "of", "an", "menu", "item", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Twig/Extension/AdminExtension.php#L80-L124
38,037
larriereguichet/AdminBundle
src/Bridge/Twig/Extension/AdminExtension.php
AdminExtension.getAdminUrl
public function getAdminUrl(ViewInterface $view, string $actionName, $entity = null) { if (!$this->isAdminActionAllowed($view, $actionName)) { throw new Exception('The action "'.$actionName.'" is not allowed for the admin "'.$view->getName().'"'); } $configuration = $view->getAdminConfiguration(); $parameters = []; $routeName = RoutingLoader::generateRouteName( $view->getName(), $actionName, $configuration->getParameter('routing_name_pattern') ); if (null !== $entity) { $accessor = PropertyAccess::createPropertyAccessor(); $actionConfiguration = $this->configurationFactory->createActionConfiguration( $actionName, $configuration->getParameter('actions')[$actionName], $view->getName(), $view->getAdminConfiguration() ); foreach ($actionConfiguration->getParameter('route_requirements') as $name => $requirements) { $parameters[$name] = $accessor->getValue($entity, $name); } } return $this->router->generate($routeName, $parameters); }
php
public function getAdminUrl(ViewInterface $view, string $actionName, $entity = null) { if (!$this->isAdminActionAllowed($view, $actionName)) { throw new Exception('The action "'.$actionName.'" is not allowed for the admin "'.$view->getName().'"'); } $configuration = $view->getAdminConfiguration(); $parameters = []; $routeName = RoutingLoader::generateRouteName( $view->getName(), $actionName, $configuration->getParameter('routing_name_pattern') ); if (null !== $entity) { $accessor = PropertyAccess::createPropertyAccessor(); $actionConfiguration = $this->configurationFactory->createActionConfiguration( $actionName, $configuration->getParameter('actions')[$actionName], $view->getName(), $view->getAdminConfiguration() ); foreach ($actionConfiguration->getParameter('route_requirements') as $name => $requirements) { $parameters[$name] = $accessor->getValue($entity, $name); } } return $this->router->generate($routeName, $parameters); }
[ "public", "function", "getAdminUrl", "(", "ViewInterface", "$", "view", ",", "string", "$", "actionName", ",", "$", "entity", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isAdminActionAllowed", "(", "$", "view", ",", "$", "actionName", ")", ")", "{", "throw", "new", "Exception", "(", "'The action \"'", ".", "$", "actionName", ".", "'\" is not allowed for the admin \"'", ".", "$", "view", "->", "getName", "(", ")", ".", "'\"'", ")", ";", "}", "$", "configuration", "=", "$", "view", "->", "getAdminConfiguration", "(", ")", ";", "$", "parameters", "=", "[", "]", ";", "$", "routeName", "=", "RoutingLoader", "::", "generateRouteName", "(", "$", "view", "->", "getName", "(", ")", ",", "$", "actionName", ",", "$", "configuration", "->", "getParameter", "(", "'routing_name_pattern'", ")", ")", ";", "if", "(", "null", "!==", "$", "entity", ")", "{", "$", "accessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "$", "actionConfiguration", "=", "$", "this", "->", "configurationFactory", "->", "createActionConfiguration", "(", "$", "actionName", ",", "$", "configuration", "->", "getParameter", "(", "'actions'", ")", "[", "$", "actionName", "]", ",", "$", "view", "->", "getName", "(", ")", ",", "$", "view", "->", "getAdminConfiguration", "(", ")", ")", ";", "foreach", "(", "$", "actionConfiguration", "->", "getParameter", "(", "'route_requirements'", ")", "as", "$", "name", "=>", "$", "requirements", ")", "{", "$", "parameters", "[", "$", "name", "]", "=", "$", "accessor", "->", "getValue", "(", "$", "entity", ",", "$", "name", ")", ";", "}", "}", "return", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ",", "$", "parameters", ")", ";", "}" ]
Return the url of an Admin action. @param ViewInterface $view @param string $actionName @param mixed|null $entity @return string @throws Exception
[ "Return", "the", "url", "of", "an", "Admin", "action", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Twig/Extension/AdminExtension.php#L137-L165
38,038
larriereguichet/AdminBundle
src/Bridge/Twig/Extension/AdminExtension.php
AdminExtension.isAdminActionAllowed
public function isAdminActionAllowed(ViewInterface $view, string $actionName) { $configuration = $view->getAdminConfiguration(); return key_exists($actionName, $configuration->getParameter('actions')); }
php
public function isAdminActionAllowed(ViewInterface $view, string $actionName) { $configuration = $view->getAdminConfiguration(); return key_exists($actionName, $configuration->getParameter('actions')); }
[ "public", "function", "isAdminActionAllowed", "(", "ViewInterface", "$", "view", ",", "string", "$", "actionName", ")", "{", "$", "configuration", "=", "$", "view", "->", "getAdminConfiguration", "(", ")", ";", "return", "key_exists", "(", "$", "actionName", ",", "$", "configuration", "->", "getParameter", "(", "'actions'", ")", ")", ";", "}" ]
Return true if the given action is allowed for the given Admin. @param ViewInterface $view @param string $actionName @return bool
[ "Return", "true", "if", "the", "given", "action", "is", "allowed", "for", "the", "given", "Admin", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Bridge/Twig/Extension/AdminExtension.php#L175-L180
38,039
larriereguichet/AdminBundle
src/Routing/RoutingLoader.php
RoutingLoader.load
public function load($routingResource, $type = null) { if ($this->loaded) { throw new RuntimeException('Do not add the Admin "extra" loader twice'); } $routes = new RouteCollection(); foreach ($this->resourceCollection->all() as $name => $resource) { $configuration = $this ->configurationFactory ->createAdminConfiguration( $resource->getName(), $resource->getConfiguration(), $this->applicationConfiguration ) ; foreach ($configuration->getParameter('actions') as $actionName => $actionData) { $actionConfiguration = $this ->configurationFactory ->createActionConfiguration($actionName, $actionData, $name, $configuration) ; $route = new Route( $actionConfiguration->getParameter('route_path'), $actionConfiguration->getParameter('route_defaults'), $actionConfiguration->getParameter('route_requirements') ); $routes->add($actionConfiguration->getParameter('route'), $route); } if ($this->applicationConfiguration->getParameter('enable_homepage')) { $route = new Route('/', ['_controller' => HomeAction::class], []); $routes->add('lag.admin.homepage', $route); } } return $routes; }
php
public function load($routingResource, $type = null) { if ($this->loaded) { throw new RuntimeException('Do not add the Admin "extra" loader twice'); } $routes = new RouteCollection(); foreach ($this->resourceCollection->all() as $name => $resource) { $configuration = $this ->configurationFactory ->createAdminConfiguration( $resource->getName(), $resource->getConfiguration(), $this->applicationConfiguration ) ; foreach ($configuration->getParameter('actions') as $actionName => $actionData) { $actionConfiguration = $this ->configurationFactory ->createActionConfiguration($actionName, $actionData, $name, $configuration) ; $route = new Route( $actionConfiguration->getParameter('route_path'), $actionConfiguration->getParameter('route_defaults'), $actionConfiguration->getParameter('route_requirements') ); $routes->add($actionConfiguration->getParameter('route'), $route); } if ($this->applicationConfiguration->getParameter('enable_homepage')) { $route = new Route('/', ['_controller' => HomeAction::class], []); $routes->add('lag.admin.homepage', $route); } } return $routes; }
[ "public", "function", "load", "(", "$", "routingResource", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "this", "->", "loaded", ")", "{", "throw", "new", "RuntimeException", "(", "'Do not add the Admin \"extra\" loader twice'", ")", ";", "}", "$", "routes", "=", "new", "RouteCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "resourceCollection", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "resource", ")", "{", "$", "configuration", "=", "$", "this", "->", "configurationFactory", "->", "createAdminConfiguration", "(", "$", "resource", "->", "getName", "(", ")", ",", "$", "resource", "->", "getConfiguration", "(", ")", ",", "$", "this", "->", "applicationConfiguration", ")", ";", "foreach", "(", "$", "configuration", "->", "getParameter", "(", "'actions'", ")", "as", "$", "actionName", "=>", "$", "actionData", ")", "{", "$", "actionConfiguration", "=", "$", "this", "->", "configurationFactory", "->", "createActionConfiguration", "(", "$", "actionName", ",", "$", "actionData", ",", "$", "name", ",", "$", "configuration", ")", ";", "$", "route", "=", "new", "Route", "(", "$", "actionConfiguration", "->", "getParameter", "(", "'route_path'", ")", ",", "$", "actionConfiguration", "->", "getParameter", "(", "'route_defaults'", ")", ",", "$", "actionConfiguration", "->", "getParameter", "(", "'route_requirements'", ")", ")", ";", "$", "routes", "->", "add", "(", "$", "actionConfiguration", "->", "getParameter", "(", "'route'", ")", ",", "$", "route", ")", ";", "}", "if", "(", "$", "this", "->", "applicationConfiguration", "->", "getParameter", "(", "'enable_homepage'", ")", ")", "{", "$", "route", "=", "new", "Route", "(", "'/'", ",", "[", "'_controller'", "=>", "HomeAction", "::", "class", "]", ",", "[", "]", ")", ";", "$", "routes", "->", "add", "(", "'lag.admin.homepage'", ",", "$", "route", ")", ";", "}", "}", "return", "$", "routes", ";", "}" ]
Load the Admin's route. @param mixed $routingResource @param string $type @return RouteCollection @throws Exception
[ "Load", "the", "Admin", "s", "route", "." ]
794991d72b3f50b70de424be7a89c3307f9eecc1
https://github.com/larriereguichet/AdminBundle/blob/794991d72b3f50b70de424be7a89c3307f9eecc1/src/Routing/RoutingLoader.php#L104-L141
38,040
hnhdigital-os/laravel-frontend-assets
src/FontAwesome.php
FontAwesome.version4
private function version4($version = false) { if (!env('APP_CDN', true)) { FrontendAsset::add('vendor/font-awesome/css/font-awesome.min.css'); return; } $version = FrontendAsset::version(class_basename(__CLASS__), $version); FrontendAsset::add('https://maxcdn.bootstrapcdn.com/font-awesome/'.$version.'/css/font-awesome.min.css'); }
php
private function version4($version = false) { if (!env('APP_CDN', true)) { FrontendAsset::add('vendor/font-awesome/css/font-awesome.min.css'); return; } $version = FrontendAsset::version(class_basename(__CLASS__), $version); FrontendAsset::add('https://maxcdn.bootstrapcdn.com/font-awesome/'.$version.'/css/font-awesome.min.css'); }
[ "private", "function", "version4", "(", "$", "version", "=", "false", ")", "{", "if", "(", "!", "env", "(", "'APP_CDN'", ",", "true", ")", ")", "{", "FrontendAsset", "::", "add", "(", "'vendor/font-awesome/css/font-awesome.min.css'", ")", ";", "return", ";", "}", "$", "version", "=", "FrontendAsset", "::", "version", "(", "class_basename", "(", "__CLASS__", ")", ",", "$", "version", ")", ";", "FrontendAsset", "::", "add", "(", "'https://maxcdn.bootstrapcdn.com/font-awesome/'", ".", "$", "version", ".", "'/css/font-awesome.min.css'", ")", ";", "}" ]
Using version 4. @return void @SuppressWarnings(PHPMD.BooleanArgumentFlag)
[ "Using", "version", "4", "." ]
242f605bf0c052f4d82421a8b95f227d46162e34
https://github.com/hnhdigital-os/laravel-frontend-assets/blob/242f605bf0c052f4d82421a8b95f227d46162e34/src/FontAwesome.php#L36-L46
38,041
ajcastro/fk-adder
src/Fk.php
Fk.add
public function add($fk, $column = null, $keyName = null, $onDelete = null, $onUpdate = null) { $baseFk = $this->baseFk($fk); $column = $column ?: $baseFk->defaultColumn(); static::$foreignKeys[] = [ 'column' => $column ?: $this->column, 'key_name' => $keyName ?: $this->keyName, 'table' => $this->table->getTable(), 'reference_table' => $baseFk->referenceTable(), 'primary_key' => $baseFk->primaryKey, 'on_delete' => $onDelete ?: $this->onDelete ?: $baseFk->onDelete, 'on_update' => $onUpdate ?: $this->onUpdate ?: $baseFk->onUpdate, ]; return $baseFk->createFkColumn($column); }
php
public function add($fk, $column = null, $keyName = null, $onDelete = null, $onUpdate = null) { $baseFk = $this->baseFk($fk); $column = $column ?: $baseFk->defaultColumn(); static::$foreignKeys[] = [ 'column' => $column ?: $this->column, 'key_name' => $keyName ?: $this->keyName, 'table' => $this->table->getTable(), 'reference_table' => $baseFk->referenceTable(), 'primary_key' => $baseFk->primaryKey, 'on_delete' => $onDelete ?: $this->onDelete ?: $baseFk->onDelete, 'on_update' => $onUpdate ?: $this->onUpdate ?: $baseFk->onUpdate, ]; return $baseFk->createFkColumn($column); }
[ "public", "function", "add", "(", "$", "fk", ",", "$", "column", "=", "null", ",", "$", "keyName", "=", "null", ",", "$", "onDelete", "=", "null", ",", "$", "onUpdate", "=", "null", ")", "{", "$", "baseFk", "=", "$", "this", "->", "baseFk", "(", "$", "fk", ")", ";", "$", "column", "=", "$", "column", "?", ":", "$", "baseFk", "->", "defaultColumn", "(", ")", ";", "static", "::", "$", "foreignKeys", "[", "]", "=", "[", "'column'", "=>", "$", "column", "?", ":", "$", "this", "->", "column", ",", "'key_name'", "=>", "$", "keyName", "?", ":", "$", "this", "->", "keyName", ",", "'table'", "=>", "$", "this", "->", "table", "->", "getTable", "(", ")", ",", "'reference_table'", "=>", "$", "baseFk", "->", "referenceTable", "(", ")", ",", "'primary_key'", "=>", "$", "baseFk", "->", "primaryKey", ",", "'on_delete'", "=>", "$", "onDelete", "?", ":", "$", "this", "->", "onDelete", "?", ":", "$", "baseFk", "->", "onDelete", ",", "'on_update'", "=>", "$", "onUpdate", "?", ":", "$", "this", "->", "onUpdate", "?", ":", "$", "baseFk", "->", "onUpdate", ",", "]", ";", "return", "$", "baseFk", "->", "createFkColumn", "(", "$", "column", ")", ";", "}" ]
Add a foreign key to table and defer its foreign key creation. @param string $fk @param string $column @param string $keyName @param string $onDelete @param string $onUpdate @return \Illuminate\Support\Fluent
[ "Add", "a", "foreign", "key", "to", "table", "and", "defer", "its", "foreign", "key", "creation", "." ]
a79200d8333e1bf897c9069c3a1b575af868b188
https://github.com/ajcastro/fk-adder/blob/a79200d8333e1bf897c9069c3a1b575af868b188/src/Fk.php#L113-L130
38,042
ajcastro/fk-adder
src/Fk.php
Fk.migrate
public static function migrate() { foreach (static::$foreignKeys as $foreignKey) { Schema::table($foreignKey['table'], function (Blueprint $table) use ($foreignKey) { $table->foreign($foreignKey['column'], $foreignKey['key_name']) ->references($foreignKey['primary_key']) ->on($foreignKey['reference_table']) ->onDelete($foreignKey['on_delete']) ->onUpdate($foreignKey['on_update']); }); } static::$foreignKeys = []; }
php
public static function migrate() { foreach (static::$foreignKeys as $foreignKey) { Schema::table($foreignKey['table'], function (Blueprint $table) use ($foreignKey) { $table->foreign($foreignKey['column'], $foreignKey['key_name']) ->references($foreignKey['primary_key']) ->on($foreignKey['reference_table']) ->onDelete($foreignKey['on_delete']) ->onUpdate($foreignKey['on_update']); }); } static::$foreignKeys = []; }
[ "public", "static", "function", "migrate", "(", ")", "{", "foreach", "(", "static", "::", "$", "foreignKeys", "as", "$", "foreignKey", ")", "{", "Schema", "::", "table", "(", "$", "foreignKey", "[", "'table'", "]", ",", "function", "(", "Blueprint", "$", "table", ")", "use", "(", "$", "foreignKey", ")", "{", "$", "table", "->", "foreign", "(", "$", "foreignKey", "[", "'column'", "]", ",", "$", "foreignKey", "[", "'key_name'", "]", ")", "->", "references", "(", "$", "foreignKey", "[", "'primary_key'", "]", ")", "->", "on", "(", "$", "foreignKey", "[", "'reference_table'", "]", ")", "->", "onDelete", "(", "$", "foreignKey", "[", "'on_delete'", "]", ")", "->", "onUpdate", "(", "$", "foreignKey", "[", "'on_update'", "]", ")", ";", "}", ")", ";", "}", "static", "::", "$", "foreignKeys", "=", "[", "]", ";", "}" ]
Migrate creation of foreign keys base from the fk calls. @return void
[ "Migrate", "creation", "of", "foreign", "keys", "base", "from", "the", "fk", "calls", "." ]
a79200d8333e1bf897c9069c3a1b575af868b188
https://github.com/ajcastro/fk-adder/blob/a79200d8333e1bf897c9069c3a1b575af868b188/src/Fk.php#L137-L150
38,043
ajcastro/fk-adder
src/Fk.php
Fk.baseFk
public function baseFk($fk) { if ($fkConfig = FkConfig::get($fk)) { return new BaseFk($this->table, $fk, $fkConfig['datatype'], $fkConfig['referenceTable']); } $class = Config::get('fk_adder.fk_namespace').'\\'.studly_case($fk); return new $class($this->table); }
php
public function baseFk($fk) { if ($fkConfig = FkConfig::get($fk)) { return new BaseFk($this->table, $fk, $fkConfig['datatype'], $fkConfig['referenceTable']); } $class = Config::get('fk_adder.fk_namespace').'\\'.studly_case($fk); return new $class($this->table); }
[ "public", "function", "baseFk", "(", "$", "fk", ")", "{", "if", "(", "$", "fkConfig", "=", "FkConfig", "::", "get", "(", "$", "fk", ")", ")", "{", "return", "new", "BaseFk", "(", "$", "this", "->", "table", ",", "$", "fk", ",", "$", "fkConfig", "[", "'datatype'", "]", ",", "$", "fkConfig", "[", "'referenceTable'", "]", ")", ";", "}", "$", "class", "=", "Config", "::", "get", "(", "'fk_adder.fk_namespace'", ")", ".", "'\\\\'", ".", "studly_case", "(", "$", "fk", ")", ";", "return", "new", "$", "class", "(", "$", "this", "->", "table", ")", ";", "}" ]
Return the baseFk for foreign key column creation. @param string $fk @return \FkAdder\BaseFk
[ "Return", "the", "baseFk", "for", "foreign", "key", "column", "creation", "." ]
a79200d8333e1bf897c9069c3a1b575af868b188
https://github.com/ajcastro/fk-adder/blob/a79200d8333e1bf897c9069c3a1b575af868b188/src/Fk.php#L168-L177
38,044
fxpio/fxp-resource
Domain/AbstractDomain.php
AbstractDomain.disableFilters
protected function disableFilters() { $previous = SqlFilterUtil::findFilters($this->om, $this->disableFilters); SqlFilterUtil::disableFilters($this->om, $previous); return $previous; }
php
protected function disableFilters() { $previous = SqlFilterUtil::findFilters($this->om, $this->disableFilters); SqlFilterUtil::disableFilters($this->om, $previous); return $previous; }
[ "protected", "function", "disableFilters", "(", ")", "{", "$", "previous", "=", "SqlFilterUtil", "::", "findFilters", "(", "$", "this", "->", "om", ",", "$", "this", "->", "disableFilters", ")", ";", "SqlFilterUtil", "::", "disableFilters", "(", "$", "this", "->", "om", ",", "$", "previous", ")", ";", "return", "$", "previous", ";", "}" ]
Disable the doctrine filters. @return array The previous values of filters
[ "Disable", "the", "doctrine", "filters", "." ]
cb786bdc04c67d242591fbde6d0723f7d6834f35
https://github.com/fxpio/fxp-resource/blob/cb786bdc04c67d242591fbde6d0723f7d6834f35/Domain/AbstractDomain.php#L259-L265
38,045
reisraff/phulp
src/Collection.php
Collection.checkType
protected function checkType($item) { $type = $this->getItemType($item); if (! $this->type) { $this->type = $type; return true; } if ($this->type != $type) { return false; } return true; }
php
protected function checkType($item) { $type = $this->getItemType($item); if (! $this->type) { $this->type = $type; return true; } if ($this->type != $type) { return false; } return true; }
[ "protected", "function", "checkType", "(", "$", "item", ")", "{", "$", "type", "=", "$", "this", "->", "getItemType", "(", "$", "item", ")", ";", "if", "(", "!", "$", "this", "->", "type", ")", "{", "$", "this", "->", "type", "=", "$", "type", ";", "return", "true", ";", "}", "if", "(", "$", "this", "->", "type", "!=", "$", "type", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks the immutability of the elements type @return boolean
[ "Checks", "the", "immutability", "of", "the", "elements", "type" ]
5394ab3e20ef626b2399eb9c2a1b4601c232e58d
https://github.com/reisraff/phulp/blob/5394ab3e20ef626b2399eb9c2a1b4601c232e58d/src/Collection.php#L48-L62
38,046
reisraff/phulp
src/Source.php
Source.setDistFiles
public function setDistFiles(Collection $distFiles) { if ($distFiles->getType() !== DistFile::class) { throw new \UnexpectedValueException('The Collection is not of DistFile type'); } $this->distFiles = $distFiles; }
php
public function setDistFiles(Collection $distFiles) { if ($distFiles->getType() !== DistFile::class) { throw new \UnexpectedValueException('The Collection is not of DistFile type'); } $this->distFiles = $distFiles; }
[ "public", "function", "setDistFiles", "(", "Collection", "$", "distFiles", ")", "{", "if", "(", "$", "distFiles", "->", "getType", "(", ")", "!==", "DistFile", "::", "class", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'The Collection is not of DistFile type'", ")", ";", "}", "$", "this", "->", "distFiles", "=", "$", "distFiles", ";", "}" ]
Gets the value of distFiles. @param Collection|DistFile[] $distFiles @throws \UnexpectedValueException
[ "Gets", "the", "value", "of", "distFiles", "." ]
5394ab3e20ef626b2399eb9c2a1b4601c232e58d
https://github.com/reisraff/phulp/blob/5394ab3e20ef626b2399eb9c2a1b4601c232e58d/src/Source.php#L78-L85
38,047
reisraff/phulp
src/Output.php
Output.colorize
public static function colorize($string, $color) { if (isset(self::$colors[$color])) { return "\033[" . self::$colors[$color] . 'm' . $string . "\033[0m"; } return $string; }
php
public static function colorize($string, $color) { if (isset(self::$colors[$color])) { return "\033[" . self::$colors[$color] . 'm' . $string . "\033[0m"; } return $string; }
[ "public", "static", "function", "colorize", "(", "$", "string", ",", "$", "color", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "colors", "[", "$", "color", "]", ")", ")", "{", "return", "\"\\033[\"", ".", "self", "::", "$", "colors", "[", "$", "color", "]", ".", "'m'", ".", "$", "string", ".", "\"\\033[0m\"", ";", "}", "return", "$", "string", ";", "}" ]
This method is used to colorize some text @param string $string the text to be colorized @param string $color the color to colorize your @return string
[ "This", "method", "is", "used", "to", "colorize", "some", "text" ]
5394ab3e20ef626b2399eb9c2a1b4601c232e58d
https://github.com/reisraff/phulp/blob/5394ab3e20ef626b2399eb9c2a1b4601c232e58d/src/Output.php#L93-L100
38,048
schmittjoh/php-stubs
res/php/mysqli/mysqli.php
mysqli.real_connect
public function real_connect($host = NULL, $username = NULL, $passwd = NULL, $dbname = NULL, $port = NULL, $socket = NULL, $flags = NULL, $link, $host = NULL, $username = NULL, $passwd = NULL, $dbname = NULL, $port = NULL, $socket = NULL, $flags = NULL) { }
php
public function real_connect($host = NULL, $username = NULL, $passwd = NULL, $dbname = NULL, $port = NULL, $socket = NULL, $flags = NULL, $link, $host = NULL, $username = NULL, $passwd = NULL, $dbname = NULL, $port = NULL, $socket = NULL, $flags = NULL) { }
[ "public", "function", "real_connect", "(", "$", "host", "=", "NULL", ",", "$", "username", "=", "NULL", ",", "$", "passwd", "=", "NULL", ",", "$", "dbname", "=", "NULL", ",", "$", "port", "=", "NULL", ",", "$", "socket", "=", "NULL", ",", "$", "flags", "=", "NULL", ",", "$", "link", ",", "$", "host", "=", "NULL", ",", "$", "username", "=", "NULL", ",", "$", "passwd", "=", "NULL", ",", "$", "dbname", "=", "NULL", ",", "$", "port", "=", "NULL", ",", "$", "socket", "=", "NULL", ",", "$", "flags", "=", "NULL", ")", "{", "}" ]
Opens a connection to a mysql server @param string $host @param string $username @param string $passwd @param string $dbname @param int $port @param string $socket @param int $flags @param mysqli $link @param string $host @param string $username @param string $passwd @param string $dbname @param int $port @param string $socket @param int $flags @return bool
[ "Opens", "a", "connection", "to", "a", "mysql", "server" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/mysqli/mysqli.php#L528-L530
38,049
schmittjoh/php-stubs
res/php/mysqli/mysqli.php
mysqli.ssl_set
public function ssl_set($key, $cert, $ca, $capath, $cipher, $link, $key, $cert, $ca, $capath, $cipher) { }
php
public function ssl_set($key, $cert, $ca, $capath, $cipher, $link, $key, $cert, $ca, $capath, $cipher) { }
[ "public", "function", "ssl_set", "(", "$", "key", ",", "$", "cert", ",", "$", "ca", ",", "$", "capath", ",", "$", "cipher", ",", "$", "link", ",", "$", "key", ",", "$", "cert", ",", "$", "ca", ",", "$", "capath", ",", "$", "cipher", ")", "{", "}" ]
Used for establishing secure connections using SSL @param string $key @param string $cert @param string $ca @param string $capath @param string $cipher @param mysqli $link @param string $key @param string $cert @param string $ca @param string $capath @param string $cipher @return bool This function always returns true value. If SSL setup is incorrect will return an error when you attempt to connect.
[ "Used", "for", "establishing", "secure", "connections", "using", "SSL" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/mysqli/mysqli.php#L690-L692
38,050
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.arc
public function arc($x, $y, $radius, $angle1, $angle2, $context, $x, $y, $radius, $angle1, $angle2) { }
php
public function arc($x, $y, $radius, $angle1, $angle2, $context, $x, $y, $radius, $angle1, $angle2) { }
[ "public", "function", "arc", "(", "$", "x", ",", "$", "y", ",", "$", "radius", ",", "$", "angle1", ",", "$", "angle2", ",", "$", "context", ",", "$", "x", ",", "$", "y", ",", "$", "radius", ",", "$", "angle1", ",", "$", "angle2", ")", "{", "}" ]
Adds a circular arc @param float $x @param float $y @param float $radius @param float $angle1 @param float $angle2 @param CairoContext $context @param float $x @param float $y @param float $radius @param float $angle1 @param float $angle2 @return void
[ "Adds", "a", "circular", "arc" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L45-L47
38,051
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.arcNegative
public function arcNegative($x, $y, $radius, $angle1, $angle2, $context, $x, $y, $radius, $angle1, $angle2) { }
php
public function arcNegative($x, $y, $radius, $angle1, $angle2, $context, $x, $y, $radius, $angle1, $angle2) { }
[ "public", "function", "arcNegative", "(", "$", "x", ",", "$", "y", ",", "$", "radius", ",", "$", "angle1", ",", "$", "angle2", ",", "$", "context", ",", "$", "x", ",", "$", "y", ",", "$", "radius", ",", "$", "angle1", ",", "$", "angle2", ")", "{", "}" ]
Adds a negative arc @param float $x @param float $y @param float $radius @param float $angle1 @param float $angle2 @param CairoContext $context @param float $x @param float $y @param float $radius @param float $angle1 @param float $angle2 @return void
[ "Adds", "a", "negative", "arc" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L66-L68
38,052
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.curveTo
public function curveTo($x1, $y1, $x2, $y2, $x3, $y3, $context, $x1, $y1, $x2, $y2, $x3, $y3) { }
php
public function curveTo($x1, $y1, $x2, $y2, $x3, $y3, $context, $x1, $y1, $x2, $y2, $x3, $y3) { }
[ "public", "function", "curveTo", "(", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "x3", ",", "$", "y3", ",", "$", "context", ",", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "x3", ",", "$", "y3", ")", "{", "}" ]
Adds a curve @param float $x1 @param float $y1 @param float $x2 @param float $y2 @param float $x3 @param float $y3 @param CairoContext $context @param float $x1 @param float $y1 @param float $x2 @param float $y2 @param float $x3 @param float $y3 @return void
[ "Adds", "a", "curve" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L177-L179
38,053
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.maskSurface
public function maskSurface($surface, $x = NULL, $y = NULL, $context, $surface, $x = NULL, $y = NULL) { }
php
public function maskSurface($surface, $x = NULL, $y = NULL, $context, $surface, $x = NULL, $y = NULL) { }
[ "public", "function", "maskSurface", "(", "$", "surface", ",", "$", "x", "=", "NULL", ",", "$", "y", "=", "NULL", ",", "$", "context", ",", "$", "surface", ",", "$", "x", "=", "NULL", ",", "$", "y", "=", "NULL", ")", "{", "}" ]
The maskSurface purpose @param string $surface @param string $x @param string $y @param CairoContext $context @param CairoSurface $surface @param string $x @param string $y @return void Description...
[ "The", "maskSurface", "purpose" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L570-L572
38,054
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.rectangle
public function rectangle($x, $y, $width, $height, $context, $x, $y, $width, $height) { }
php
public function rectangle($x, $y, $width, $height, $context, $x, $y, $width, $height) { }
[ "public", "function", "rectangle", "(", "$", "x", ",", "$", "y", ",", "$", "width", ",", "$", "height", ",", "$", "context", ",", "$", "x", ",", "$", "y", ",", "$", "width", ",", "$", "height", ")", "{", "}" ]
The rectangle purpose @param string $x @param string $y @param string $width @param string $height @param CairoContext $context @param string $x @param string $y @param string $width @param string $height @return void Description...
[ "The", "rectangle", "purpose" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L707-L709
38,055
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.relCurveTo
public function relCurveTo($x1, $y1, $x2, $y2, $x3, $y3, $context, $x1, $y1, $x2, $y2, $x3, $y3) { }
php
public function relCurveTo($x1, $y1, $x2, $y2, $x3, $y3, $context, $x1, $y1, $x2, $y2, $x3, $y3) { }
[ "public", "function", "relCurveTo", "(", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "x3", ",", "$", "y3", ",", "$", "context", ",", "$", "x1", ",", "$", "y1", ",", "$", "x2", ",", "$", "y2", ",", "$", "x3", ",", "$", "y3", ")", "{", "}" ]
The relCurveTo purpose @param string $x1 @param string $y1 @param string $x2 @param string $y2 @param string $x3 @param string $y3 @param CairoContext $context @param string $x1 @param string $y1 @param string $x2 @param string $y2 @param string $x3 @param string $y3 @return void Description...
[ "The", "relCurveTo", "purpose" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L730-L732
38,056
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.selectFontFace
public function selectFontFace($family, $slant = NULL, $weight = NULL, $context, $family, $slant = NULL, $weight = NULL) { }
php
public function selectFontFace($family, $slant = NULL, $weight = NULL, $context, $family, $slant = NULL, $weight = NULL) { }
[ "public", "function", "selectFontFace", "(", "$", "family", ",", "$", "slant", "=", "NULL", ",", "$", "weight", "=", "NULL", ",", "$", "context", ",", "$", "family", ",", "$", "slant", "=", "NULL", ",", "$", "weight", "=", "NULL", ")", "{", "}" ]
The selectFontFace purpose @param string $family @param string $slant @param string $weight @param CairoContext $context @param string $family @param string $slant @param string $weight @return void Description...
[ "The", "selectFontFace", "purpose" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L838-L840
38,057
schmittjoh/php-stubs
res/php/cairo/cairocontext.php
CairoContext.setSourceSurface
public function setSourceSurface($surface, $x = NULL, $y = NULL, $context, $surface, $x = NULL, $y = NULL) { }
php
public function setSourceSurface($surface, $x = NULL, $y = NULL, $context, $surface, $x = NULL, $y = NULL) { }
[ "public", "function", "setSourceSurface", "(", "$", "surface", ",", "$", "x", "=", "NULL", ",", "$", "y", "=", "NULL", ",", "$", "context", ",", "$", "surface", ",", "$", "x", "=", "NULL", ",", "$", "y", "=", "NULL", ")", "{", "}" ]
The setSourceSurface purpose @param string $surface @param string $x @param string $y @param CairoContext $context @param CairoSurface $surface @param string $x @param string $y @return void Description...
[ "The", "setSourceSurface", "purpose" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/cairo/cairocontext.php#L1083-L1085
38,058
schmittjoh/php-stubs
res/php/intl/dateformatter.php
IntlDateFormatter.create
public function create($locale, $datetype, $timetype, $timezone = NULL, $calendar = NULL, $pattern = NULL, $locale, $datetype, $timetype, $timezone = NULL, $calendar = NULL, $pattern = NULL) { }
php
public function create($locale, $datetype, $timetype, $timezone = NULL, $calendar = NULL, $pattern = NULL, $locale, $datetype, $timetype, $timezone = NULL, $calendar = NULL, $pattern = NULL) { }
[ "public", "function", "create", "(", "$", "locale", ",", "$", "datetype", ",", "$", "timetype", ",", "$", "timezone", "=", "NULL", ",", "$", "calendar", "=", "NULL", ",", "$", "pattern", "=", "NULL", ",", "$", "locale", ",", "$", "datetype", ",", "$", "timetype", ",", "$", "timezone", "=", "NULL", ",", "$", "calendar", "=", "NULL", ",", "$", "pattern", "=", "NULL", ")", "{", "}" ]
Create a date formatter @param string $locale @param int $datetype @param int $timetype @param string $timezone @param int $calendar @param string $pattern @param string $locale @param int $datetype @param int $timetype @param string $timezone @param int $calendar @param string $pattern @return IntlDateFormatter
[ "Create", "a", "date", "formatter" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/intl/dateformatter.php#L32-L34
38,059
schmittjoh/php-stubs
res/php/mysqli/mysqli_stmt.php
mysqli_stmt.bind_param
public function bind_param($types, &$var1, &$_ = NULL, $stmt, $types, &$var1, &$_ = NULL) { }
php
public function bind_param($types, &$var1, &$_ = NULL, $stmt, $types, &$var1, &$_ = NULL) { }
[ "public", "function", "bind_param", "(", "$", "types", ",", "&", "$", "var1", ",", "&", "$", "_", "=", "NULL", ",", "$", "stmt", ",", "$", "types", ",", "&", "$", "var1", ",", "&", "$", "_", "=", "NULL", ")", "{", "}" ]
Binds variables to a prepared statement as parameters @phpstub-variable-parameters @param string $types @param mixed $var1 @param mixed $_ @param mysqli_stmt $stmt @param string $types @param mixed $var1 @param mixed $_ @return bool
[ "Binds", "variables", "to", "a", "prepared", "statement", "as", "parameters" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/mysqli/mysqli_stmt.php#L157-L159
38,060
schmittjoh/php-stubs
res/php/haru/harudoc.php
HaruDoc.setInfoDateAttr
public function setInfoDateAttr($type, $year, $month, $day, $hour, $min, $sec, $ind, $off_hour, $off_min) { }
php
public function setInfoDateAttr($type, $year, $month, $day, $hour, $min, $sec, $ind, $off_hour, $off_min) { }
[ "public", "function", "setInfoDateAttr", "(", "$", "type", ",", "$", "year", ",", "$", "month", ",", "$", "day", ",", "$", "hour", ",", "$", "min", ",", "$", "sec", ",", "$", "ind", ",", "$", "off_hour", ",", "$", "off_min", ")", "{", "}" ]
Set the datetime info attributes of the document @param int $type @param int $year @param int $month @param int $day @param int $hour @param int $min @param int $sec @param string $ind @param int $off_hour @param int $off_min @return bool Returns true on success.
[ "Set", "the", "datetime", "info", "attributes", "of", "the", "document" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/haru/harudoc.php#L342-L344
38,061
schmittjoh/php-stubs
src/PHPStubs/TypeRefiner.php
TypeRefiner.inferArrayElementTypeFromDesc
private function inferArrayElementTypeFromDesc($desc) { if (preg_match_all('#array\s+of\s+``([^`]+)``#', $desc, $matches)) { $types = array(); foreach ($matches[1] as $m) { $types[] = $m.'[]'; } return implode('|', $types); } return null; }
php
private function inferArrayElementTypeFromDesc($desc) { if (preg_match_all('#array\s+of\s+``([^`]+)``#', $desc, $matches)) { $types = array(); foreach ($matches[1] as $m) { $types[] = $m.'[]'; } return implode('|', $types); } return null; }
[ "private", "function", "inferArrayElementTypeFromDesc", "(", "$", "desc", ")", "{", "if", "(", "preg_match_all", "(", "'#array\\s+of\\s+``([^`]+)``#'", ",", "$", "desc", ",", "$", "matches", ")", ")", "{", "$", "types", "=", "array", "(", ")", ";", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "m", ")", "{", "$", "types", "[", "]", "=", "$", "m", ".", "'[]'", ";", "}", "return", "implode", "(", "'|'", ",", "$", "types", ")", ";", "}", "return", "null", ";", "}" ]
Infers the element type of an array from the description. @param string $desc @return string|null
[ "Infers", "the", "element", "type", "of", "an", "array", "from", "the", "description", "." ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/src/PHPStubs/TypeRefiner.php#L289-L301
38,062
schmittjoh/php-stubs
res/php/datetime/datetimezone.php
DateTimeZone.getTransitions
public function getTransitions($timestamp_begin = NULL, $timestamp_end = NULL, $object, $timestamp_begin = NULL, $timestamp_end = NULL) { }
php
public function getTransitions($timestamp_begin = NULL, $timestamp_end = NULL, $object, $timestamp_begin = NULL, $timestamp_end = NULL) { }
[ "public", "function", "getTransitions", "(", "$", "timestamp_begin", "=", "NULL", ",", "$", "timestamp_end", "=", "NULL", ",", "$", "object", ",", "$", "timestamp_begin", "=", "NULL", ",", "$", "timestamp_end", "=", "NULL", ")", "{", "}" ]
Returns all transitions for the timezone @param int $timestamp_begin @param int $timestamp_end @param DateTimeZone $object @param int $timestamp_begin @param int $timestamp_end @return array Returns numerically indexed array containing associative array with all transitions on success.
[ "Returns", "all", "transitions", "for", "the", "timezone" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/datetime/datetimezone.php#L80-L82
38,063
schmittjoh/php-stubs
res/php/memcache/memcache.php
Memcache.addServer
public function addServer($host, $port = 11211, $persistent = NULL, $weight = NULL, $timeout = NULL, $retry_interval = NULL, $status = NULL, $failure_callback = NULL, $timeoutms = NULL) { }
php
public function addServer($host, $port = 11211, $persistent = NULL, $weight = NULL, $timeout = NULL, $retry_interval = NULL, $status = NULL, $failure_callback = NULL, $timeoutms = NULL) { }
[ "public", "function", "addServer", "(", "$", "host", ",", "$", "port", "=", "11211", ",", "$", "persistent", "=", "NULL", ",", "$", "weight", "=", "NULL", ",", "$", "timeout", "=", "NULL", ",", "$", "retry_interval", "=", "NULL", ",", "$", "status", "=", "NULL", ",", "$", "failure_callback", "=", "NULL", ",", "$", "timeoutms", "=", "NULL", ")", "{", "}" ]
Add a memcached server to connection pool @param string $host @param int $port @param bool $persistent @param int $weight @param int $timeout @param int $retry_interval @param bool $status @param callable $failure_callback @param int $timeoutms @return bool
[ "Add", "a", "memcached", "server", "to", "connection", "pool" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/memcache/memcache.php#L37-L39
38,064
schmittjoh/php-stubs
res/php/memcache/memcache.php
Memcache.setServerParams
public function setServerParams($host, $port = 11211, $timeout = NULL, $retry_interval = false, $status = NULL, $failure_callback = NULL) { }
php
public function setServerParams($host, $port = 11211, $timeout = NULL, $retry_interval = false, $status = NULL, $failure_callback = NULL) { }
[ "public", "function", "setServerParams", "(", "$", "host", ",", "$", "port", "=", "11211", ",", "$", "timeout", "=", "NULL", ",", "$", "retry_interval", "=", "false", ",", "$", "status", "=", "NULL", ",", "$", "failure_callback", "=", "NULL", ")", "{", "}" ]
Changes server parameters and status at runtime @param string $host @param int $port @param int $timeout @param int $retry_interval @param bool $status @param callable $failure_callback @return bool
[ "Changes", "server", "parameters", "and", "status", "at", "runtime" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/memcache/memcache.php#L238-L240
38,065
schmittjoh/php-stubs
res/php/datetime/datetime.php
DateTime.setTime
public function setTime($hour, $minute, $second = false, $object, $hour, $minute, $second = false) { }
php
public function setTime($hour, $minute, $second = false, $object, $hour, $minute, $second = false) { }
[ "public", "function", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", "=", "false", ",", "$", "object", ",", "$", "hour", ",", "$", "minute", ",", "$", "second", "=", "false", ")", "{", "}" ]
Sets the time @param int $hour @param int $minute @param int $second @param DateTime $object @param int $hour @param int $minute @param int $second @return DateTime
[ "Sets", "the", "time" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/datetime/datetime.php#L215-L217
38,066
schmittjoh/php-stubs
src/PHPStubs/Generator.php
Generator.getConstantValue
private function getConstantValue(\CG\Generator\PhpConstant $constant) { if (null !== $value = $constant->getValue()) { return $value; } if ($constant->hasAttribute('type')) { switch ($constant->getAttribute('type')) { case 'int': case 'integer': return 0; case 'double': case 'float': return 0.1; case 'bool': case 'boolean': return true; case 'string': return 'dummy'; case 'int/float/bool/enum': case '': return null; default: throw new \RuntimeException(sprintf('Unknown constant type "%s".', $constant->getAttribute('type'))); } } return null; }
php
private function getConstantValue(\CG\Generator\PhpConstant $constant) { if (null !== $value = $constant->getValue()) { return $value; } if ($constant->hasAttribute('type')) { switch ($constant->getAttribute('type')) { case 'int': case 'integer': return 0; case 'double': case 'float': return 0.1; case 'bool': case 'boolean': return true; case 'string': return 'dummy'; case 'int/float/bool/enum': case '': return null; default: throw new \RuntimeException(sprintf('Unknown constant type "%s".', $constant->getAttribute('type'))); } } return null; }
[ "private", "function", "getConstantValue", "(", "\\", "CG", "\\", "Generator", "\\", "PhpConstant", "$", "constant", ")", "{", "if", "(", "null", "!==", "$", "value", "=", "$", "constant", "->", "getValue", "(", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "constant", "->", "hasAttribute", "(", "'type'", ")", ")", "{", "switch", "(", "$", "constant", "->", "getAttribute", "(", "'type'", ")", ")", "{", "case", "'int'", ":", "case", "'integer'", ":", "return", "0", ";", "case", "'double'", ":", "case", "'float'", ":", "return", "0.1", ";", "case", "'bool'", ":", "case", "'boolean'", ":", "return", "true", ";", "case", "'string'", ":", "return", "'dummy'", ";", "case", "'int/float/bool/enum'", ":", "case", "''", ":", "return", "null", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Unknown constant type \"%s\".'", ",", "$", "constant", "->", "getAttribute", "(", "'type'", ")", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns the value of a constant, or makes up an arbitrary value that matches the type of the constant. The reasoning behind generating an arbitrary value is that for type inference, the actual value is not important as long as we can infer the correct type. For other types of data flow analysis it might be interesting though; we can re-visit it then. @param \CG\Generator\PhpConstant $constant @return int|real|boolean|string|null
[ "Returns", "the", "value", "of", "a", "constant", "or", "makes", "up", "an", "arbitrary", "value", "that", "matches", "the", "type", "of", "the", "constant", "." ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/src/PHPStubs/Generator.php#L111-L144
38,067
schmittjoh/php-stubs
res/php/ming/swfshape.php
SWFShape.addFill
public function addFill($red, $green, $blue, $alpha = 255, $bitmap, $flags = NULL, $gradient, $flags = NULL) { }
php
public function addFill($red, $green, $blue, $alpha = 255, $bitmap, $flags = NULL, $gradient, $flags = NULL) { }
[ "public", "function", "addFill", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ",", "$", "alpha", "=", "255", ",", "$", "bitmap", ",", "$", "flags", "=", "NULL", ",", "$", "gradient", ",", "$", "flags", "=", "NULL", ")", "{", "}" ]
Adds a solid fill to the shape @param int $red @param int $green @param int $blue @param int $alpha @param SWFBitmap $bitmap @param int $flags @param SWFGradient $gradient @param int $flags @return SWFFill
[ "Adds", "a", "solid", "fill", "to", "the", "shape" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/ming/swfshape.php#L27-L29
38,068
schmittjoh/php-stubs
res/php/tidy/tidy.php
tidy.parseFile
public function parseFile($filename, $config = NULL, $encoding = NULL, $use_include_path = false, $filename, $config = NULL, $encoding = NULL, $use_include_path = false) { }
php
public function parseFile($filename, $config = NULL, $encoding = NULL, $use_include_path = false, $filename, $config = NULL, $encoding = NULL, $use_include_path = false) { }
[ "public", "function", "parseFile", "(", "$", "filename", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "use_include_path", "=", "false", ",", "$", "filename", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "use_include_path", "=", "false", ")", "{", "}" ]
Parse markup in file or URI @param string $filename @param mixed $config @param string $encoding @param bool $use_include_path @param string $filename @param mixed $config @param string $encoding @param bool $use_include_path @return tidy
[ "Parse", "markup", "in", "file", "or", "URI" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/tidy/tidy.php#L196-L198
38,069
schmittjoh/php-stubs
res/php/tidy/tidy.php
tidy.parseString
public function parseString($input, $config = NULL, $encoding = NULL, $input, $config = NULL, $encoding = NULL) { }
php
public function parseString($input, $config = NULL, $encoding = NULL, $input, $config = NULL, $encoding = NULL) { }
[ "public", "function", "parseString", "(", "$", "input", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "input", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ")", "{", "}" ]
Parse a document stored in a string @param string $input @param mixed $config @param string $encoding @param string $input @param mixed $config @param string $encoding @return tidy Returns a new ``tidy`` instance.
[ "Parse", "a", "document", "stored", "in", "a", "string" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/tidy/tidy.php#L212-L214
38,070
schmittjoh/php-stubs
res/php/tidy/tidy.php
tidy.repairFile
public function repairFile($filename, $config = NULL, $encoding = NULL, $use_include_path = false, $filename, $config = NULL, $encoding = NULL, $use_include_path = false) { }
php
public function repairFile($filename, $config = NULL, $encoding = NULL, $use_include_path = false, $filename, $config = NULL, $encoding = NULL, $use_include_path = false) { }
[ "public", "function", "repairFile", "(", "$", "filename", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "use_include_path", "=", "false", ",", "$", "filename", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "use_include_path", "=", "false", ")", "{", "}" ]
Repair a file and return it as a string @param string $filename @param mixed $config @param string $encoding @param bool $use_include_path @param string $filename @param mixed $config @param string $encoding @param bool $use_include_path @return string Returns the repaired contents as a string.
[ "Repair", "a", "file", "and", "return", "it", "as", "a", "string" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/tidy/tidy.php#L230-L232
38,071
schmittjoh/php-stubs
res/php/tidy/tidy.php
tidy.repairString
public function repairString($data, $config = NULL, $encoding = NULL, $data, $config = NULL, $encoding = NULL) { }
php
public function repairString($data, $config = NULL, $encoding = NULL, $data, $config = NULL, $encoding = NULL) { }
[ "public", "function", "repairString", "(", "$", "data", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ",", "$", "data", ",", "$", "config", "=", "NULL", ",", "$", "encoding", "=", "NULL", ")", "{", "}" ]
Repair a string using an optionally provided configuration file @param string $data @param mixed $config @param string $encoding @param string $data @param mixed $config @param string $encoding @return string Returns the repaired string.
[ "Repair", "a", "string", "using", "an", "optionally", "provided", "configuration", "file" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/tidy/tidy.php#L246-L248
38,072
schmittjoh/php-stubs
res/php/intl/locale.php
Locale.lookup
public function lookup($langtag, $locale, $canonicalize = false, $default = NULL, $langtag, $locale, $canonicalize = false, $default = NULL) { }
php
public function lookup($langtag, $locale, $canonicalize = false, $default = NULL, $langtag, $locale, $canonicalize = false, $default = NULL) { }
[ "public", "function", "lookup", "(", "$", "langtag", ",", "$", "locale", ",", "$", "canonicalize", "=", "false", ",", "$", "default", "=", "NULL", ",", "$", "langtag", ",", "$", "locale", ",", "$", "canonicalize", "=", "false", ",", "$", "default", "=", "NULL", ")", "{", "}" ]
Searches the language tag list for the best match to the language @param array $langtag @param string $locale @param bool $canonicalize @param string $default @param array $langtag @param string $locale @param bool $canonicalize @param string $default @return string The closest matching language tag or default value.
[ "Searches", "the", "language", "tag", "list", "for", "the", "best", "match", "to", "the", "language" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/intl/locale.php#L215-L217
38,073
schmittjoh/php-stubs
res/php/intl/numberformatter.php
NumberFormatter.parse
public function parse($value, $type = NULL, &$position = NULL, $fmt, $value, $type = NULL, &$position = NULL) { }
php
public function parse($value, $type = NULL, &$position = NULL, $fmt, $value, $type = NULL, &$position = NULL) { }
[ "public", "function", "parse", "(", "$", "value", ",", "$", "type", "=", "NULL", ",", "&", "$", "position", "=", "NULL", ",", "$", "fmt", ",", "$", "value", ",", "$", "type", "=", "NULL", ",", "&", "$", "position", "=", "NULL", ")", "{", "}" ]
Parse a number @param string $value @param int $type @param int $position @param NumberFormatter $fmt @param string $value @param int $type @param int $position @return mixed The value of the parsed number or false on error.
[ "Parse", "a", "number" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/intl/numberformatter.php#L224-L226
38,074
schmittjoh/php-stubs
res/php/intl/numberformatter.php
NumberFormatter.parseCurrency
public function parseCurrency($value, &$currency, &$position = NULL, $fmt, $value, &$currency, &$position = NULL) { }
php
public function parseCurrency($value, &$currency, &$position = NULL, $fmt, $value, &$currency, &$position = NULL) { }
[ "public", "function", "parseCurrency", "(", "$", "value", ",", "&", "$", "currency", ",", "&", "$", "position", "=", "NULL", ",", "$", "fmt", ",", "$", "value", ",", "&", "$", "currency", ",", "&", "$", "position", "=", "NULL", ")", "{", "}" ]
Parse a currency number @param string $value @param string $currency @param int $position @param NumberFormatter $fmt @param string $value @param string $currency @param int $position @return float The parsed numeric value or false on error.
[ "Parse", "a", "currency", "number" ]
df0ec337be4baabc76dcdf696855df061f84306d
https://github.com/schmittjoh/php-stubs/blob/df0ec337be4baabc76dcdf696855df061f84306d/res/php/intl/numberformatter.php#L241-L243
38,075
andreausu/CodiceFiscale
src/CodiceFiscale/Checker.php
Checker.resetProperties
private function resetProperties() { $this->isValid = false; $this->sex = null; $this->countryBirth = null; $this->dayBirth = null; $this->monthBirth = null; $this->yearBirth = null; $this->error = null; }
php
private function resetProperties() { $this->isValid = false; $this->sex = null; $this->countryBirth = null; $this->dayBirth = null; $this->monthBirth = null; $this->yearBirth = null; $this->error = null; }
[ "private", "function", "resetProperties", "(", ")", "{", "$", "this", "->", "isValid", "=", "false", ";", "$", "this", "->", "sex", "=", "null", ";", "$", "this", "->", "countryBirth", "=", "null", ";", "$", "this", "->", "dayBirth", "=", "null", ";", "$", "this", "->", "monthBirth", "=", "null", ";", "$", "this", "->", "yearBirth", "=", "null", ";", "$", "this", "->", "error", "=", "null", ";", "}" ]
Reset Class Properties @return void
[ "Reset", "Class", "Properties" ]
92a9a9accd388744813043683cff5652838956dc
https://github.com/andreausu/CodiceFiscale/blob/92a9a9accd388744813043683cff5652838956dc/src/CodiceFiscale/Checker.php#L268-L277
38,076
sheadawson/silverstripe-quickaddnew
code/extensions/QuickAddNewExtension.php
QuickAddNewExtension.useAddNew
public function useAddNew( $class, $sourceCallback, FieldList $fields = null, RequiredFields $required = null, $isFrontend = false ) { if (!is_callable($sourceCallback)) { throw new Exception( 'the useAddNew method must be passed a callable $sourceCallback parameter, ' . gettype($sourceCallback) . ' passed.' ); } // if the user can't create this object type, don't modify the form if (!singleton($class)->canCreate()) { return $this->owner; } Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::javascript(QUICKADDNEW_MODULE . '/javascript/quickaddnew.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(QUICKADDNEW_MODULE . '/css/quickaddnew.css'); Requirements::add_i18n_javascript(QUICKADDNEW_MODULE . '/javascript/lang'); if (!$fields) { if (singleton($class)->hasMethod('getAddNewFields')) { $fields = singleton($class)->getAddNewFields(); } else { $fields = singleton($class)->getCMSFields(); } } if (!$required) { if (singleton($class)->hasMethod('getAddNewValidator')) { $required = singleton($class)->getAddNewValidator(); } } $this->owner->addExtraClass('quickaddnew-field'); $this->addNewEnabled = true; $this->sourceCallback = $sourceCallback; $this->isFrontend = $isFrontend; $this->addNewClass = $class; $this->addNewFields = $fields; $this->addNewRequiredFields = $required; return $this->owner; }
php
public function useAddNew( $class, $sourceCallback, FieldList $fields = null, RequiredFields $required = null, $isFrontend = false ) { if (!is_callable($sourceCallback)) { throw new Exception( 'the useAddNew method must be passed a callable $sourceCallback parameter, ' . gettype($sourceCallback) . ' passed.' ); } // if the user can't create this object type, don't modify the form if (!singleton($class)->canCreate()) { return $this->owner; } Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js'); Requirements::javascript(QUICKADDNEW_MODULE . '/javascript/quickaddnew.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(QUICKADDNEW_MODULE . '/css/quickaddnew.css'); Requirements::add_i18n_javascript(QUICKADDNEW_MODULE . '/javascript/lang'); if (!$fields) { if (singleton($class)->hasMethod('getAddNewFields')) { $fields = singleton($class)->getAddNewFields(); } else { $fields = singleton($class)->getCMSFields(); } } if (!$required) { if (singleton($class)->hasMethod('getAddNewValidator')) { $required = singleton($class)->getAddNewValidator(); } } $this->owner->addExtraClass('quickaddnew-field'); $this->addNewEnabled = true; $this->sourceCallback = $sourceCallback; $this->isFrontend = $isFrontend; $this->addNewClass = $class; $this->addNewFields = $fields; $this->addNewRequiredFields = $required; return $this->owner; }
[ "public", "function", "useAddNew", "(", "$", "class", ",", "$", "sourceCallback", ",", "FieldList", "$", "fields", "=", "null", ",", "RequiredFields", "$", "required", "=", "null", ",", "$", "isFrontend", "=", "false", ")", "{", "if", "(", "!", "is_callable", "(", "$", "sourceCallback", ")", ")", "{", "throw", "new", "Exception", "(", "'the useAddNew method must be passed a callable $sourceCallback parameter, '", ".", "gettype", "(", "$", "sourceCallback", ")", ".", "' passed.'", ")", ";", "}", "// if the user can't create this object type, don't modify the form", "if", "(", "!", "singleton", "(", "$", "class", ")", "->", "canCreate", "(", ")", ")", "{", "return", "$", "this", "->", "owner", ";", "}", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "'/jquery/jquery.js'", ")", ";", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "'/jquery-entwine/dist/jquery.entwine-dist.js'", ")", ";", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "'/jquery-ui/jquery-ui.js'", ")", ";", "Requirements", "::", "javascript", "(", "QUICKADDNEW_MODULE", ".", "'/javascript/quickaddnew.js'", ")", ";", "Requirements", "::", "css", "(", "THIRDPARTY_DIR", ".", "'/jquery-ui-themes/smoothness/jquery-ui.css'", ")", ";", "Requirements", "::", "css", "(", "QUICKADDNEW_MODULE", ".", "'/css/quickaddnew.css'", ")", ";", "Requirements", "::", "add_i18n_javascript", "(", "QUICKADDNEW_MODULE", ".", "'/javascript/lang'", ")", ";", "if", "(", "!", "$", "fields", ")", "{", "if", "(", "singleton", "(", "$", "class", ")", "->", "hasMethod", "(", "'getAddNewFields'", ")", ")", "{", "$", "fields", "=", "singleton", "(", "$", "class", ")", "->", "getAddNewFields", "(", ")", ";", "}", "else", "{", "$", "fields", "=", "singleton", "(", "$", "class", ")", "->", "getCMSFields", "(", ")", ";", "}", "}", "if", "(", "!", "$", "required", ")", "{", "if", "(", "singleton", "(", "$", "class", ")", "->", "hasMethod", "(", "'getAddNewValidator'", ")", ")", "{", "$", "required", "=", "singleton", "(", "$", "class", ")", "->", "getAddNewValidator", "(", ")", ";", "}", "}", "$", "this", "->", "owner", "->", "addExtraClass", "(", "'quickaddnew-field'", ")", ";", "$", "this", "->", "addNewEnabled", "=", "true", ";", "$", "this", "->", "sourceCallback", "=", "$", "sourceCallback", ";", "$", "this", "->", "isFrontend", "=", "$", "isFrontend", ";", "$", "this", "->", "addNewClass", "=", "$", "class", ";", "$", "this", "->", "addNewFields", "=", "$", "fields", ";", "$", "this", "->", "addNewRequiredFields", "=", "$", "required", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Tell this form field to apply the add new UI and fucntionality @param string $class - the class name of the object being managed on the relationship @param Function $sourceCallback - the function called to repopulate the field's source array @param FieldList $fields - Fields to create the object via dialog form - defaults to the object's getAddNewFields() method @param RequiredFields $required - to create the validator for the dialog form @param Boolean $isFrontend - If this is set to true, the css classes for the CMS ui will not be set of the form elements this also opens the opportunity to manipulate the form for Frontend uses via an extension @return FormField $this->owner
[ "Tell", "this", "form", "field", "to", "apply", "the", "add", "new", "UI", "and", "fucntionality" ]
fb969e1707954c85bd433a35b43dac981b774f45
https://github.com/sheadawson/silverstripe-quickaddnew/blob/fb969e1707954c85bd433a35b43dac981b774f45/code/extensions/QuickAddNewExtension.php#L63-L112
38,077
sheadawson/silverstripe-quickaddnew
code/extensions/QuickAddNewExtension.php
QuickAddNewExtension.AddNewForm
public function AddNewForm() { $action = FormAction::create('doAddNew', _t('QUICKADDNEW.Add', 'Add'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $actions = FieldList::create($action); $form = Form::create($this->owner, 'AddNewForm', $this->addNewFields, $actions, $this->addNewRequiredFields); $this->owner->extend('updateQuickAddNewForm', $form); return $form; }
php
public function AddNewForm() { $action = FormAction::create('doAddNew', _t('QUICKADDNEW.Add', 'Add'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $actions = FieldList::create($action); $form = Form::create($this->owner, 'AddNewForm', $this->addNewFields, $actions, $this->addNewRequiredFields); $this->owner->extend('updateQuickAddNewForm', $form); return $form; }
[ "public", "function", "AddNewForm", "(", ")", "{", "$", "action", "=", "FormAction", "::", "create", "(", "'doAddNew'", ",", "_t", "(", "'QUICKADDNEW.Add'", ",", "'Add'", ")", ")", "->", "setUseButtonTag", "(", "'true'", ")", ";", "if", "(", "!", "$", "this", "->", "isFrontend", ")", "{", "$", "action", "->", "addExtraClass", "(", "'ss-ui-action-constructive'", ")", "->", "setAttribute", "(", "'data-icon'", ",", "'accept'", ")", ";", "}", "$", "actions", "=", "FieldList", "::", "create", "(", "$", "action", ")", ";", "$", "form", "=", "Form", "::", "create", "(", "$", "this", "->", "owner", ",", "'AddNewForm'", ",", "$", "this", "->", "addNewFields", ",", "$", "actions", ",", "$", "this", "->", "addNewRequiredFields", ")", ";", "$", "this", "->", "owner", "->", "extend", "(", "'updateQuickAddNewForm'", ",", "$", "form", ")", ";", "return", "$", "form", ";", "}" ]
The AddNewForm for the dialog window @return Form
[ "The", "AddNewForm", "for", "the", "dialog", "window" ]
fb969e1707954c85bd433a35b43dac981b774f45
https://github.com/sheadawson/silverstripe-quickaddnew/blob/fb969e1707954c85bd433a35b43dac981b774f45/code/extensions/QuickAddNewExtension.php#L147-L161
38,078
sheadawson/silverstripe-quickaddnew
code/extensions/QuickAddNewExtension.php
QuickAddNewExtension.doAddNew
public function doAddNew($data, $form) { $obj = Object::create($this->addNewClass); if (!$obj->canCreate()) { return Security::permissionFailure(Controller::curr(), "You don't have permission to create this object"); } $form->saveInto($obj); try { $obj->write(); } catch (Exception $e) { $form->setMessage($e->getMessage(), 'error'); return $form->forTemplate(); } $callback = $this->sourceCallback; $items = $callback($obj); $this->owner->setSource($items); // if this field is a multiselect field, we add the new Object ID to the existing // options that are selected on the field then set that as the value // otherwise we just set the new Object ID as the value if (isset($data['existing'])) { $existing = $data['existing']; $value = explode(',', $existing); $value[] = $obj->ID; } else { $value = $obj->ID; } $this->owner->setValue($value); // NOTE(Jake): Below line causes cyclic issues, I assume it's not necessary. //$this->owner->setForm($form); return $this->owner->FieldHolder(); }
php
public function doAddNew($data, $form) { $obj = Object::create($this->addNewClass); if (!$obj->canCreate()) { return Security::permissionFailure(Controller::curr(), "You don't have permission to create this object"); } $form->saveInto($obj); try { $obj->write(); } catch (Exception $e) { $form->setMessage($e->getMessage(), 'error'); return $form->forTemplate(); } $callback = $this->sourceCallback; $items = $callback($obj); $this->owner->setSource($items); // if this field is a multiselect field, we add the new Object ID to the existing // options that are selected on the field then set that as the value // otherwise we just set the new Object ID as the value if (isset($data['existing'])) { $existing = $data['existing']; $value = explode(',', $existing); $value[] = $obj->ID; } else { $value = $obj->ID; } $this->owner->setValue($value); // NOTE(Jake): Below line causes cyclic issues, I assume it's not necessary. //$this->owner->setForm($form); return $this->owner->FieldHolder(); }
[ "public", "function", "doAddNew", "(", "$", "data", ",", "$", "form", ")", "{", "$", "obj", "=", "Object", "::", "create", "(", "$", "this", "->", "addNewClass", ")", ";", "if", "(", "!", "$", "obj", "->", "canCreate", "(", ")", ")", "{", "return", "Security", "::", "permissionFailure", "(", "Controller", "::", "curr", "(", ")", ",", "\"You don't have permission to create this object\"", ")", ";", "}", "$", "form", "->", "saveInto", "(", "$", "obj", ")", ";", "try", "{", "$", "obj", "->", "write", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "form", "->", "setMessage", "(", "$", "e", "->", "getMessage", "(", ")", ",", "'error'", ")", ";", "return", "$", "form", "->", "forTemplate", "(", ")", ";", "}", "$", "callback", "=", "$", "this", "->", "sourceCallback", ";", "$", "items", "=", "$", "callback", "(", "$", "obj", ")", ";", "$", "this", "->", "owner", "->", "setSource", "(", "$", "items", ")", ";", "// if this field is a multiselect field, we add the new Object ID to the existing", "// options that are selected on the field then set that as the value", "// otherwise we just set the new Object ID as the value", "if", "(", "isset", "(", "$", "data", "[", "'existing'", "]", ")", ")", "{", "$", "existing", "=", "$", "data", "[", "'existing'", "]", ";", "$", "value", "=", "explode", "(", "','", ",", "$", "existing", ")", ";", "$", "value", "[", "]", "=", "$", "obj", "->", "ID", ";", "}", "else", "{", "$", "value", "=", "$", "obj", "->", "ID", ";", "}", "$", "this", "->", "owner", "->", "setValue", "(", "$", "value", ")", ";", "// NOTE(Jake): Below line causes cyclic issues, I assume it's not necessary.", "//$this->owner->setForm($form);", "return", "$", "this", "->", "owner", "->", "FieldHolder", "(", ")", ";", "}" ]
Handles adding the new object Returns the updated FieldHolder of this form to replace the existing one @return string
[ "Handles", "adding", "the", "new", "object", "Returns", "the", "updated", "FieldHolder", "of", "this", "form", "to", "replace", "the", "existing", "one" ]
fb969e1707954c85bd433a35b43dac981b774f45
https://github.com/sheadawson/silverstripe-quickaddnew/blob/fb969e1707954c85bd433a35b43dac981b774f45/code/extensions/QuickAddNewExtension.php#L181-L215
38,079
gizburdt/cuztom
src/Fields/Field.php
Field.output
public function output($value = null) { $value = is_null($value) ? $this->value : $value; return $this->isRepeatable() ? $this->outputRepeatable().$this->getExplanation() : $this->outputInput($value).$this->getExplanation(); }
php
public function output($value = null) { $value = is_null($value) ? $this->value : $value; return $this->isRepeatable() ? $this->outputRepeatable().$this->getExplanation() : $this->outputInput($value).$this->getExplanation(); }
[ "public", "function", "output", "(", "$", "value", "=", "null", ")", "{", "$", "value", "=", "is_null", "(", "$", "value", ")", "?", "$", "this", "->", "value", ":", "$", "value", ";", "return", "$", "this", "->", "isRepeatable", "(", ")", "?", "$", "this", "->", "outputRepeatable", "(", ")", ".", "$", "this", "->", "getExplanation", "(", ")", ":", "$", "this", "->", "outputInput", "(", "$", "value", ")", ".", "$", "this", "->", "getExplanation", "(", ")", ";", "}" ]
Output based on type. @param string|array $value @param string $value @return string
[ "Output", "based", "on", "type", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L129-L136
38,080
gizburdt/cuztom
src/Fields/Field.php
Field.outputInput
public function outputInput($value = null, $view = null) { $view = $view ? $view : $this->getView(); return Cuztom::view('fields/'.$view, [ 'field' => $this, 'value' => $value, ]); }
php
public function outputInput($value = null, $view = null) { $view = $view ? $view : $this->getView(); return Cuztom::view('fields/'.$view, [ 'field' => $this, 'value' => $value, ]); }
[ "public", "function", "outputInput", "(", "$", "value", "=", "null", ",", "$", "view", "=", "null", ")", "{", "$", "view", "=", "$", "view", "?", "$", "view", ":", "$", "this", "->", "getView", "(", ")", ";", "return", "Cuztom", "::", "view", "(", "'fields/'", ".", "$", "view", ",", "[", "'field'", "=>", "$", "this", ",", "'value'", "=>", "$", "value", ",", "]", ")", ";", "}" ]
Output field. @param string|array $value @param string $view @return string
[ "Output", "field", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L145-L153
38,081
gizburdt/cuztom
src/Fields/Field.php
Field.save
public function save($object, $values) { $value = isset($values[$this->id]) ? apply_filters('cuztom_field_save_value', $this->parseValue($values[$this->id]), $this) : false; // Do do_action('cuztom_field_save', $this); // Save to respective content-type switch ($this->metaType) { case 'user': return (bool) update_user_meta($object, $this->id, $value); case 'term': return (bool) update_term_meta($object, $this->id, $value); case 'post': return (bool) update_post_meta($object, $this->id, $value); } // Default return false; }
php
public function save($object, $values) { $value = isset($values[$this->id]) ? apply_filters('cuztom_field_save_value', $this->parseValue($values[$this->id]), $this) : false; // Do do_action('cuztom_field_save', $this); // Save to respective content-type switch ($this->metaType) { case 'user': return (bool) update_user_meta($object, $this->id, $value); case 'term': return (bool) update_term_meta($object, $this->id, $value); case 'post': return (bool) update_post_meta($object, $this->id, $value); } // Default return false; }
[ "public", "function", "save", "(", "$", "object", ",", "$", "values", ")", "{", "$", "value", "=", "isset", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", "?", "apply_filters", "(", "'cuztom_field_save_value'", ",", "$", "this", "->", "parseValue", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", ",", "$", "this", ")", ":", "false", ";", "// Do", "do_action", "(", "'cuztom_field_save'", ",", "$", "this", ")", ";", "// Save to respective content-type", "switch", "(", "$", "this", "->", "metaType", ")", "{", "case", "'user'", ":", "return", "(", "bool", ")", "update_user_meta", "(", "$", "object", ",", "$", "this", "->", "id", ",", "$", "value", ")", ";", "case", "'term'", ":", "return", "(", "bool", ")", "update_term_meta", "(", "$", "object", ",", "$", "this", "->", "id", ",", "$", "value", ")", ";", "case", "'post'", ":", "return", "(", "bool", ")", "update_post_meta", "(", "$", "object", ",", "$", "this", "->", "id", ",", "$", "value", ")", ";", "}", "// Default", "return", "false", ";", "}" ]
Save meta. @param int $object @param mixed $value @return bool
[ "Save", "meta", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L199-L220
38,082
gizburdt/cuztom
src/Fields/Field.php
Field.getId
public function getId($extra = null) { $id = $this->beforeId.$this->id.$this->afterId; if (! Cuztom::isEmpty($extra)) { $id = $id.'_'.$extra; } return apply_filters('cuztom_field_id', $id, $this, $extra); }
php
public function getId($extra = null) { $id = $this->beforeId.$this->id.$this->afterId; if (! Cuztom::isEmpty($extra)) { $id = $id.'_'.$extra; } return apply_filters('cuztom_field_id', $id, $this, $extra); }
[ "public", "function", "getId", "(", "$", "extra", "=", "null", ")", "{", "$", "id", "=", "$", "this", "->", "beforeId", ".", "$", "this", "->", "id", ".", "$", "this", "->", "afterId", ";", "if", "(", "!", "Cuztom", "::", "isEmpty", "(", "$", "extra", ")", ")", "{", "$", "id", "=", "$", "id", ".", "'_'", ".", "$", "extra", ";", "}", "return", "apply_filters", "(", "'cuztom_field_id'", ",", "$", "id", ",", "$", "this", ",", "$", "extra", ")", ";", "}" ]
Get the complete id. @return string
[ "Get", "the", "complete", "id", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L247-L256
38,083
gizburdt/cuztom
src/Fields/Field.php
Field.getCssClass
public function getCssClass($extra = null) { $class = 'cuztom-input '.$this->css_class; if (! Cuztom::isEmpty($extra)) { $class = $class.' '.$extra; } return apply_filters('cuztom_field_css_class', $class, $this, $extra); }
php
public function getCssClass($extra = null) { $class = 'cuztom-input '.$this->css_class; if (! Cuztom::isEmpty($extra)) { $class = $class.' '.$extra; } return apply_filters('cuztom_field_css_class', $class, $this, $extra); }
[ "public", "function", "getCssClass", "(", "$", "extra", "=", "null", ")", "{", "$", "class", "=", "'cuztom-input '", ".", "$", "this", "->", "css_class", ";", "if", "(", "!", "Cuztom", "::", "isEmpty", "(", "$", "extra", ")", ")", "{", "$", "class", "=", "$", "class", ".", "' '", ".", "$", "extra", ";", "}", "return", "apply_filters", "(", "'cuztom_field_css_class'", ",", "$", "class", ",", "$", "this", ",", "$", "extra", ")", ";", "}" ]
Get the fields css classes. @param array $extra @return string
[ "Get", "the", "fields", "css", "classes", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L274-L283
38,084
gizburdt/cuztom
src/Fields/Field.php
Field.getDataAttributes
public function getDataAttributes($extra = []) { $output = ''; foreach (array_merge($this->html_attributes, $extra) as $attribute => $value) { if (! is_null($value)) { $output .= $attribute.'="'.$value.'"'; } elseif (! $value && isset($this->args[Cuztom::uglify($attribute)])) { $output .= $attribute.'="'.$this->args[Cuztom::uglify($attribute)].'"'; } } return apply_filters('cuztom_field_html_attributes', $output, $this, $extra); }
php
public function getDataAttributes($extra = []) { $output = ''; foreach (array_merge($this->html_attributes, $extra) as $attribute => $value) { if (! is_null($value)) { $output .= $attribute.'="'.$value.'"'; } elseif (! $value && isset($this->args[Cuztom::uglify($attribute)])) { $output .= $attribute.'="'.$this->args[Cuztom::uglify($attribute)].'"'; } } return apply_filters('cuztom_field_html_attributes', $output, $this, $extra); }
[ "public", "function", "getDataAttributes", "(", "$", "extra", "=", "[", "]", ")", "{", "$", "output", "=", "''", ";", "foreach", "(", "array_merge", "(", "$", "this", "->", "html_attributes", ",", "$", "extra", ")", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "output", ".=", "$", "attribute", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "elseif", "(", "!", "$", "value", "&&", "isset", "(", "$", "this", "->", "args", "[", "Cuztom", "::", "uglify", "(", "$", "attribute", ")", "]", ")", ")", "{", "$", "output", ".=", "$", "attribute", ".", "'=\"'", ".", "$", "this", "->", "args", "[", "Cuztom", "::", "uglify", "(", "$", "attribute", ")", "]", ".", "'\"'", ";", "}", "}", "return", "apply_filters", "(", "'cuztom_field_html_attributes'", ",", "$", "output", ",", "$", "this", ",", "$", "extra", ")", ";", "}" ]
Outputs the fields data attributes. @param array $extra @return string
[ "Outputs", "the", "fields", "data", "attributes", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L315-L328
38,085
gizburdt/cuztom
src/Fields/Field.php
Field.outputColumnContent
public function outputColumnContent($id) { $meta = get_post_meta($id, $this->id, true); if (! empty($meta) && $this->isRepeatable()) { echo implode($meta, ', '); } else { echo $meta; } }
php
public function outputColumnContent($id) { $meta = get_post_meta($id, $this->id, true); if (! empty($meta) && $this->isRepeatable()) { echo implode($meta, ', '); } else { echo $meta; } }
[ "public", "function", "outputColumnContent", "(", "$", "id", ")", "{", "$", "meta", "=", "get_post_meta", "(", "$", "id", ",", "$", "this", "->", "id", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "meta", ")", "&&", "$", "this", "->", "isRepeatable", "(", ")", ")", "{", "echo", "implode", "(", "$", "meta", ",", "', '", ")", ";", "}", "else", "{", "echo", "$", "meta", ";", "}", "}" ]
Outputs the fields column content. @param int $id
[ "Outputs", "the", "fields", "column", "content", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L335-L344
38,086
gizburdt/cuztom
src/Fields/Field.php
Field.substractValue
public function substractValue($values) { if (isset($values[$this->id]) && ! Cuztom::isEmpty($values[$this->id])) { if (is_array($values[$this->id])) { $value = isset($values[$this->id][0]) ? maybe_unserialize($values[$this->id][0]) : null; } else { $value = maybe_unserialize($values[$this->id]); } } else { $value = $this->default_value; } return apply_filters('cuztom_field_value', $value, $this); }
php
public function substractValue($values) { if (isset($values[$this->id]) && ! Cuztom::isEmpty($values[$this->id])) { if (is_array($values[$this->id])) { $value = isset($values[$this->id][0]) ? maybe_unserialize($values[$this->id][0]) : null; } else { $value = maybe_unserialize($values[$this->id]); } } else { $value = $this->default_value; } return apply_filters('cuztom_field_value', $value, $this); }
[ "public", "function", "substractValue", "(", "$", "values", ")", "{", "if", "(", "isset", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", "&&", "!", "Cuztom", "::", "isEmpty", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", ")", "{", "$", "value", "=", "isset", "(", "$", "values", "[", "$", "this", "->", "id", "]", "[", "0", "]", ")", "?", "maybe_unserialize", "(", "$", "values", "[", "$", "this", "->", "id", "]", "[", "0", "]", ")", ":", "null", ";", "}", "else", "{", "$", "value", "=", "maybe_unserialize", "(", "$", "values", "[", "$", "this", "->", "id", "]", ")", ";", "}", "}", "else", "{", "$", "value", "=", "$", "this", "->", "default_value", ";", "}", "return", "apply_filters", "(", "'cuztom_field_value'", ",", "$", "value", ",", "$", "this", ")", ";", "}" ]
Substract value of field from values array. @param array $values @return string
[ "Substract", "value", "of", "field", "from", "values", "array", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L393-L406
38,087
gizburdt/cuztom
src/Fields/Field.php
Field.create
public static function create($args, $values) { $type = is_array($args) ? $args['type'] : $args; $class = str_replace(' ', '', ucwords(str_replace('_', ' ', $type))); $class = "Gizburdt\\Cuztom\\Fields\\$class"; if (class_exists($class)) { $field = new $class($args, $values); Cuztom::addField($field); return $field; } return false; }
php
public static function create($args, $values) { $type = is_array($args) ? $args['type'] : $args; $class = str_replace(' ', '', ucwords(str_replace('_', ' ', $type))); $class = "Gizburdt\\Cuztom\\Fields\\$class"; if (class_exists($class)) { $field = new $class($args, $values); Cuztom::addField($field); return $field; } return false; }
[ "public", "static", "function", "create", "(", "$", "args", ",", "$", "values", ")", "{", "$", "type", "=", "is_array", "(", "$", "args", ")", "?", "$", "args", "[", "'type'", "]", ":", "$", "args", ";", "$", "class", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "type", ")", ")", ")", ";", "$", "class", "=", "\"Gizburdt\\\\Cuztom\\\\Fields\\\\$class\"", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "field", "=", "new", "$", "class", "(", "$", "args", ",", "$", "values", ")", ";", "Cuztom", "::", "addField", "(", "$", "field", ")", ";", "return", "$", "field", ";", "}", "return", "false", ";", "}" ]
Creates and returns a field object. @param array $args @return object|bool
[ "Creates", "and", "returns", "a", "field", "object", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Fields/Field.php#L414-L429
38,088
gizburdt/cuztom
src/Cuztom.php
Cuztom.run
public static function run() { if (! isset(self::$instance)) { self::$instance = new self(); self::$instance->setup(); self::$instance->execute(); self::$instance->hooks(); self::$instance->ajax(); } return self::$instance; }
php
public static function run() { if (! isset(self::$instance)) { self::$instance = new self(); self::$instance->setup(); self::$instance->execute(); self::$instance->hooks(); self::$instance->ajax(); } return self::$instance; }
[ "public", "static", "function", "run", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", ")", ";", "self", "::", "$", "instance", "->", "setup", "(", ")", ";", "self", "::", "$", "instance", "->", "execute", "(", ")", ";", "self", "::", "$", "instance", "->", "hooks", "(", ")", ";", "self", "::", "$", "instance", "->", "ajax", "(", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Public function to set the instance. @return object
[ "Public", "function", "to", "set", "the", "instance", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L76-L88
38,089
gizburdt/cuztom
src/Cuztom.php
Cuztom.setup
private function setup() { self::$version = '3.1.7'; self::$src = dirname(__FILE__); self::$dir = dirname(dirname(__FILE__)); self::$url = $this->getCuztomUrl(self::$src); // Do do_action('cuztom_setup'); }
php
private function setup() { self::$version = '3.1.7'; self::$src = dirname(__FILE__); self::$dir = dirname(dirname(__FILE__)); self::$url = $this->getCuztomUrl(self::$src); // Do do_action('cuztom_setup'); }
[ "private", "function", "setup", "(", ")", "{", "self", "::", "$", "version", "=", "'3.1.7'", ";", "self", "::", "$", "src", "=", "dirname", "(", "__FILE__", ")", ";", "self", "::", "$", "dir", "=", "dirname", "(", "dirname", "(", "__FILE__", ")", ")", ";", "self", "::", "$", "url", "=", "$", "this", "->", "getCuztomUrl", "(", "self", "::", "$", "src", ")", ";", "// Do", "do_action", "(", "'cuztom_setup'", ")", ";", "}" ]
Setup all the constants.
[ "Setup", "all", "the", "constants", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L93-L102
38,090
gizburdt/cuztom
src/Cuztom.php
Cuztom.registerStyles
public function registerStyles() { wp_register_style( 'cuztom-jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css', false, self::$version, 'screen' ); wp_register_style( 'cuztom', self::$url.'/assets/css/cuztom.min.css', false, self::$version, 'screen' ); // Do do_action('cuztom_register_styles'); }
php
public function registerStyles() { wp_register_style( 'cuztom-jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css', false, self::$version, 'screen' ); wp_register_style( 'cuztom', self::$url.'/assets/css/cuztom.min.css', false, self::$version, 'screen' ); // Do do_action('cuztom_register_styles'); }
[ "public", "function", "registerStyles", "(", ")", "{", "wp_register_style", "(", "'cuztom-jquery-ui'", ",", "'//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css'", ",", "false", ",", "self", "::", "$", "version", ",", "'screen'", ")", ";", "wp_register_style", "(", "'cuztom'", ",", "self", "::", "$", "url", ".", "'/assets/css/cuztom.min.css'", ",", "false", ",", "self", "::", "$", "version", ",", "'screen'", ")", ";", "// Do", "do_action", "(", "'cuztom_register_styles'", ")", ";", "}" ]
Registers styles.
[ "Registers", "styles", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L145-L165
38,091
gizburdt/cuztom
src/Cuztom.php
Cuztom.getCuztomUrl
public function getCuztomUrl($path = __FILE__, $url = []) { // Retun URL if defined if (defined('CUZTOM_URL')) { return CUZTOM_URL; } // Base vars $path = dirname($path); $path = str_replace('\\', '/', $path); $expath = explode('/', $path); $current = $expath[count($expath) - 1]; // Push to path array array_push($url, $current); // Check for current if (preg_match('/content|app/', $current)) { $path = ''; $directories = array_reverse($url); foreach ($directories as $dir) { if (! preg_match('/content|app/', $dir)) { $path = $path.'/'.$dir; } } return apply_filters('cuztom_url', WP_CONTENT_URL.$path); } else { return $this->getCuztomUrl($path, $url); } }
php
public function getCuztomUrl($path = __FILE__, $url = []) { // Retun URL if defined if (defined('CUZTOM_URL')) { return CUZTOM_URL; } // Base vars $path = dirname($path); $path = str_replace('\\', '/', $path); $expath = explode('/', $path); $current = $expath[count($expath) - 1]; // Push to path array array_push($url, $current); // Check for current if (preg_match('/content|app/', $current)) { $path = ''; $directories = array_reverse($url); foreach ($directories as $dir) { if (! preg_match('/content|app/', $dir)) { $path = $path.'/'.$dir; } } return apply_filters('cuztom_url', WP_CONTENT_URL.$path); } else { return $this->getCuztomUrl($path, $url); } }
[ "public", "function", "getCuztomUrl", "(", "$", "path", "=", "__FILE__", ",", "$", "url", "=", "[", "]", ")", "{", "// Retun URL if defined", "if", "(", "defined", "(", "'CUZTOM_URL'", ")", ")", "{", "return", "CUZTOM_URL", ";", "}", "// Base vars", "$", "path", "=", "dirname", "(", "$", "path", ")", ";", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ";", "$", "expath", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "$", "current", "=", "$", "expath", "[", "count", "(", "$", "expath", ")", "-", "1", "]", ";", "// Push to path array", "array_push", "(", "$", "url", ",", "$", "current", ")", ";", "// Check for current", "if", "(", "preg_match", "(", "'/content|app/'", ",", "$", "current", ")", ")", "{", "$", "path", "=", "''", ";", "$", "directories", "=", "array_reverse", "(", "$", "url", ")", ";", "foreach", "(", "$", "directories", "as", "$", "dir", ")", "{", "if", "(", "!", "preg_match", "(", "'/content|app/'", ",", "$", "dir", ")", ")", "{", "$", "path", "=", "$", "path", ".", "'/'", ".", "$", "dir", ";", "}", "}", "return", "apply_filters", "(", "'cuztom_url'", ",", "WP_CONTENT_URL", ".", "$", "path", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getCuztomUrl", "(", "$", "path", ",", "$", "url", ")", ";", "}", "}" ]
Recursive method to determine the path to the Cuztom folder. @param string $path @param array $url @return string
[ "Recursive", "method", "to", "determine", "the", "path", "to", "the", "Cuztom", "folder", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L245-L276
38,092
gizburdt/cuztom
src/Cuztom.php
Cuztom.getBox
public static function getBox($box) { return isset(self::$data[$box]) ? self::$data[$box] : null; }
php
public static function getBox($box) { return isset(self::$data[$box]) ? self::$data[$box] : null; }
[ "public", "static", "function", "getBox", "(", "$", "box", ")", "{", "return", "isset", "(", "self", "::", "$", "data", "[", "$", "box", "]", ")", "?", "self", "::", "$", "data", "[", "$", "box", "]", ":", "null", ";", "}" ]
Get a box from data. @param string $box @return object
[ "Get", "a", "box", "from", "data", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L284-L287
38,093
gizburdt/cuztom
src/Cuztom.php
Cuztom.pluralize
public static function pluralize($string) { $specials = apply_filters('cuztom_plural', [ ['/(quiz)$/i', '$1zes'], ['/^(ox)$/i', '$1en'], ['/([m|l])ouse$/i', '$1ice'], ['/(matr|vert|ind)ix|ex$/i', '$1ices'], ['/(x|ch|ss|sh)$/i', '$1es'], ['/([^aeiouy]|qu)y$/i', '$1ies'], ['/([^aeiouy]|qu)ies$/i', '$1y'], ['/(hive)$/i', '$1s'], ['/(?:([^f])fe|([lr])f)$/i', '$1$2ves'], ['/sis$/i', 'ses'], ['/([ti])um$/i', '$1a'], ['/(buffal|tomat)o$/i', '$1oes'], ['/(bu)s$/i', '$1ses'], ['/(alias|status)$/i', '$1es'], ['/(octop|vir)us$/i', '$1i'], ['/(ax|test)is$/i', '$1es'], ['/s$/i', 's'], ['/$/', 's'], ]); $irregular = apply_filters('cuztom_irregular', [ ['move', 'moves'], ['sex', 'sexes'], ['child', 'children'], ['man', 'men'], ['person', 'people'], ]); $uncountable = apply_filters('cuztom_uncountable', [ 'sheep', 'fish', 'series', 'species', 'money', 'rice', 'information', 'equipment', 'pokemon', ]); // Save time if string in uncountable if (in_array(strtolower($string), $uncountable)) { return apply_filters('cuztom_pluralize', $string, 'uncountable'); } // Check for irregular words foreach ($irregular as $noun) { if (strtolower($string) == $noun[0]) { return apply_filters('cuztom_pluralize', ucwords($noun[1]), 'irregular'); } } // Check for plural forms foreach ($specials as $pattern) { if (preg_match($pattern[0], $string)) { return apply_filters( 'cuztom_pluralize', ucwords(preg_replace($pattern[0], $pattern[1], $string)), 'special' ); } } // Return if noting found return apply_filters('cuztom_pluralize', $string, null); }
php
public static function pluralize($string) { $specials = apply_filters('cuztom_plural', [ ['/(quiz)$/i', '$1zes'], ['/^(ox)$/i', '$1en'], ['/([m|l])ouse$/i', '$1ice'], ['/(matr|vert|ind)ix|ex$/i', '$1ices'], ['/(x|ch|ss|sh)$/i', '$1es'], ['/([^aeiouy]|qu)y$/i', '$1ies'], ['/([^aeiouy]|qu)ies$/i', '$1y'], ['/(hive)$/i', '$1s'], ['/(?:([^f])fe|([lr])f)$/i', '$1$2ves'], ['/sis$/i', 'ses'], ['/([ti])um$/i', '$1a'], ['/(buffal|tomat)o$/i', '$1oes'], ['/(bu)s$/i', '$1ses'], ['/(alias|status)$/i', '$1es'], ['/(octop|vir)us$/i', '$1i'], ['/(ax|test)is$/i', '$1es'], ['/s$/i', 's'], ['/$/', 's'], ]); $irregular = apply_filters('cuztom_irregular', [ ['move', 'moves'], ['sex', 'sexes'], ['child', 'children'], ['man', 'men'], ['person', 'people'], ]); $uncountable = apply_filters('cuztom_uncountable', [ 'sheep', 'fish', 'series', 'species', 'money', 'rice', 'information', 'equipment', 'pokemon', ]); // Save time if string in uncountable if (in_array(strtolower($string), $uncountable)) { return apply_filters('cuztom_pluralize', $string, 'uncountable'); } // Check for irregular words foreach ($irregular as $noun) { if (strtolower($string) == $noun[0]) { return apply_filters('cuztom_pluralize', ucwords($noun[1]), 'irregular'); } } // Check for plural forms foreach ($specials as $pattern) { if (preg_match($pattern[0], $string)) { return apply_filters( 'cuztom_pluralize', ucwords(preg_replace($pattern[0], $pattern[1], $string)), 'special' ); } } // Return if noting found return apply_filters('cuztom_pluralize', $string, null); }
[ "public", "static", "function", "pluralize", "(", "$", "string", ")", "{", "$", "specials", "=", "apply_filters", "(", "'cuztom_plural'", ",", "[", "[", "'/(quiz)$/i'", ",", "'$1zes'", "]", ",", "[", "'/^(ox)$/i'", ",", "'$1en'", "]", ",", "[", "'/([m|l])ouse$/i'", ",", "'$1ice'", "]", ",", "[", "'/(matr|vert|ind)ix|ex$/i'", ",", "'$1ices'", "]", ",", "[", "'/(x|ch|ss|sh)$/i'", ",", "'$1es'", "]", ",", "[", "'/([^aeiouy]|qu)y$/i'", ",", "'$1ies'", "]", ",", "[", "'/([^aeiouy]|qu)ies$/i'", ",", "'$1y'", "]", ",", "[", "'/(hive)$/i'", ",", "'$1s'", "]", ",", "[", "'/(?:([^f])fe|([lr])f)$/i'", ",", "'$1$2ves'", "]", ",", "[", "'/sis$/i'", ",", "'ses'", "]", ",", "[", "'/([ti])um$/i'", ",", "'$1a'", "]", ",", "[", "'/(buffal|tomat)o$/i'", ",", "'$1oes'", "]", ",", "[", "'/(bu)s$/i'", ",", "'$1ses'", "]", ",", "[", "'/(alias|status)$/i'", ",", "'$1es'", "]", ",", "[", "'/(octop|vir)us$/i'", ",", "'$1i'", "]", ",", "[", "'/(ax|test)is$/i'", ",", "'$1es'", "]", ",", "[", "'/s$/i'", ",", "'s'", "]", ",", "[", "'/$/'", ",", "'s'", "]", ",", "]", ")", ";", "$", "irregular", "=", "apply_filters", "(", "'cuztom_irregular'", ",", "[", "[", "'move'", ",", "'moves'", "]", ",", "[", "'sex'", ",", "'sexes'", "]", ",", "[", "'child'", ",", "'children'", "]", ",", "[", "'man'", ",", "'men'", "]", ",", "[", "'person'", ",", "'people'", "]", ",", "]", ")", ";", "$", "uncountable", "=", "apply_filters", "(", "'cuztom_uncountable'", ",", "[", "'sheep'", ",", "'fish'", ",", "'series'", ",", "'species'", ",", "'money'", ",", "'rice'", ",", "'information'", ",", "'equipment'", ",", "'pokemon'", ",", "]", ")", ";", "// Save time if string in uncountable", "if", "(", "in_array", "(", "strtolower", "(", "$", "string", ")", ",", "$", "uncountable", ")", ")", "{", "return", "apply_filters", "(", "'cuztom_pluralize'", ",", "$", "string", ",", "'uncountable'", ")", ";", "}", "// Check for irregular words", "foreach", "(", "$", "irregular", "as", "$", "noun", ")", "{", "if", "(", "strtolower", "(", "$", "string", ")", "==", "$", "noun", "[", "0", "]", ")", "{", "return", "apply_filters", "(", "'cuztom_pluralize'", ",", "ucwords", "(", "$", "noun", "[", "1", "]", ")", ",", "'irregular'", ")", ";", "}", "}", "// Check for plural forms", "foreach", "(", "$", "specials", "as", "$", "pattern", ")", "{", "if", "(", "preg_match", "(", "$", "pattern", "[", "0", "]", ",", "$", "string", ")", ")", "{", "return", "apply_filters", "(", "'cuztom_pluralize'", ",", "ucwords", "(", "preg_replace", "(", "$", "pattern", "[", "0", "]", ",", "$", "pattern", "[", "1", "]", ",", "$", "string", ")", ")", ",", "'special'", ")", ";", "}", "}", "// Return if noting found", "return", "apply_filters", "(", "'cuztom_pluralize'", ",", "$", "string", ",", "null", ")", ";", "}" ]
Makes a word plural. @param string $string @return string
[ "Makes", "a", "word", "plural", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L358-L426
38,094
gizburdt/cuztom
src/Cuztom.php
Cuztom.view
public static function view($view, $variables = []) { extract($variables); ob_start(); include dirname(dirname(__FILE__)).'/resources/views/'.$view.'.php'; return ob_get_clean(); }
php
public static function view($view, $variables = []) { extract($variables); ob_start(); include dirname(dirname(__FILE__)).'/resources/views/'.$view.'.php'; return ob_get_clean(); }
[ "public", "static", "function", "view", "(", "$", "view", ",", "$", "variables", "=", "[", "]", ")", "{", "extract", "(", "$", "variables", ")", ";", "ob_start", "(", ")", ";", "include", "dirname", "(", "dirname", "(", "__FILE__", ")", ")", ".", "'/resources/views/'", ".", "$", "view", ".", "'.php'", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Include view file. @param string $view @param array $variables
[ "Include", "view", "file", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L445-L454
38,095
gizburdt/cuztom
src/Cuztom.php
Cuztom.isEmpty
public static function isEmpty($input, $result = true) { if (is_array($input) && count($input)) { foreach ($input as $value) { $result = $result && self::isEmpty($value); } return $result; } return empty($input); }
php
public static function isEmpty($input, $result = true) { if (is_array($input) && count($input)) { foreach ($input as $value) { $result = $result && self::isEmpty($value); } return $result; } return empty($input); }
[ "public", "static", "function", "isEmpty", "(", "$", "input", ",", "$", "result", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "input", ")", "&&", "count", "(", "$", "input", ")", ")", "{", "foreach", "(", "$", "input", "as", "$", "value", ")", "{", "$", "result", "=", "$", "result", "&&", "self", "::", "isEmpty", "(", "$", "value", ")", ";", "}", "return", "$", "result", ";", "}", "return", "empty", "(", "$", "input", ")", ";", "}" ]
Check if variable is empty. @param string|array $input @param bool $result @return bool
[ "Check", "if", "variable", "is", "empty", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L463-L474
38,096
gizburdt/cuztom
src/Cuztom.php
Cuztom.isReservedTerm
public static function isReservedTerm($term) { if (! in_array($term, apply_filters('cuztom_reserved_terms', self::$reserved))) { return false; } return new \WP_Error('cuztom_reserved_term_used', __('Use of a reserved term.', 'cuztom')); }
php
public static function isReservedTerm($term) { if (! in_array($term, apply_filters('cuztom_reserved_terms', self::$reserved))) { return false; } return new \WP_Error('cuztom_reserved_term_used', __('Use of a reserved term.', 'cuztom')); }
[ "public", "static", "function", "isReservedTerm", "(", "$", "term", ")", "{", "if", "(", "!", "in_array", "(", "$", "term", ",", "apply_filters", "(", "'cuztom_reserved_terms'", ",", "self", "::", "$", "reserved", ")", ")", ")", "{", "return", "false", ";", "}", "return", "new", "\\", "WP_Error", "(", "'cuztom_reserved_term_used'", ",", "__", "(", "'Use of a reserved term.'", ",", "'cuztom'", ")", ")", ";", "}" ]
Check if the term is reserved by Wordpress. @param string $term @return bool
[ "Check", "if", "the", "term", "is", "reserved", "by", "Wordpress", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Cuztom.php#L536-L543
38,097
gizburdt/cuztom
src/Meta/User.php
User.saveUser
public function saveUser($id) { if (! Guard::verifyNonce('cuztom_nonce', 'cuztom_meta')) { return; } // Filter $values = apply_filters('cuztom_user_save_values', (new Request($_POST))->getAll(), $this); // Do do_action('cuztom_user_save', $this); parent::save($id, $values); }
php
public function saveUser($id) { if (! Guard::verifyNonce('cuztom_nonce', 'cuztom_meta')) { return; } // Filter $values = apply_filters('cuztom_user_save_values', (new Request($_POST))->getAll(), $this); // Do do_action('cuztom_user_save', $this); parent::save($id, $values); }
[ "public", "function", "saveUser", "(", "$", "id", ")", "{", "if", "(", "!", "Guard", "::", "verifyNonce", "(", "'cuztom_nonce'", ",", "'cuztom_meta'", ")", ")", "{", "return", ";", "}", "// Filter", "$", "values", "=", "apply_filters", "(", "'cuztom_user_save_values'", ",", "(", "new", "Request", "(", "$", "_POST", ")", ")", "->", "getAll", "(", ")", ",", "$", "this", ")", ";", "// Do", "do_action", "(", "'cuztom_user_save'", ",", "$", "this", ")", ";", "parent", "::", "save", "(", "$", "id", ",", "$", "values", ")", ";", "}" ]
Hooks into the save hook for the user meta. @param int $id
[ "Hooks", "into", "the", "save", "hook", "for", "the", "user", "meta", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Meta/User.php#L84-L97
38,098
gizburdt/cuztom
src/Meta/Meta.php
Meta.save
public function save($object, $values) { if (Cuztom::isEmpty($values)) { return; } // Filter $values = apply_filters('cuztom_meta_values', $values, $this); // Do do_action('cuztom_meta_save', $this); foreach ($this->data as $id => $field) { $field->save($object, $values); } }
php
public function save($object, $values) { if (Cuztom::isEmpty($values)) { return; } // Filter $values = apply_filters('cuztom_meta_values', $values, $this); // Do do_action('cuztom_meta_save', $this); foreach ($this->data as $id => $field) { $field->save($object, $values); } }
[ "public", "function", "save", "(", "$", "object", ",", "$", "values", ")", "{", "if", "(", "Cuztom", "::", "isEmpty", "(", "$", "values", ")", ")", "{", "return", ";", "}", "// Filter", "$", "values", "=", "apply_filters", "(", "'cuztom_meta_values'", ",", "$", "values", ",", "$", "this", ")", ";", "// Do", "do_action", "(", "'cuztom_meta_save'", ",", "$", "this", ")", ";", "foreach", "(", "$", "this", "->", "data", "as", "$", "id", "=>", "$", "field", ")", "{", "$", "field", "->", "save", "(", "$", "object", ",", "$", "values", ")", ";", "}", "}" ]
Normal save method to save all the fields in a metabox. @param int $object Object ID @param array $values Array of values
[ "Normal", "save", "method", "to", "save", "all", "the", "fields", "in", "a", "metabox", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Meta/Meta.php#L129-L144
38,099
gizburdt/cuztom
src/Meta/Meta.php
Meta.searchField
protected function searchField($search) { foreach ($this->data as $field) { if (method_exists($field, 'getField') && $find = $field->getField($search)) { return $find; } } }
php
protected function searchField($search) { foreach ($this->data as $field) { if (method_exists($field, 'getField') && $find = $field->getField($search)) { return $find; } } }
[ "protected", "function", "searchField", "(", "$", "search", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "field", ")", "{", "if", "(", "method_exists", "(", "$", "field", ",", "'getField'", ")", "&&", "$", "find", "=", "$", "field", "->", "getField", "(", "$", "search", ")", ")", "{", "return", "$", "find", ";", "}", "}", "}" ]
Search for a field. @param string $search @return
[ "Search", "for", "a", "field", "." ]
440afc5b9b65302dab2138c97974883ede90fbce
https://github.com/gizburdt/cuztom/blob/440afc5b9b65302dab2138c97974883ede90fbce/src/Meta/Meta.php#L165-L172