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
partition
stringclasses
1 value
webeweb/core-bundle
EventListener/KernelEventListener.php
KernelEventListener.handleRedirectResponseException
protected function handleRedirectResponseException(GetResponseForExceptionEvent $event, RedirectResponseException $ex) { if (null !== $ex->getRedirectUrl()) { $event->setResponse(new RedirectResponse($ex->getRedirectUrl())); } return $event; }
php
protected function handleRedirectResponseException(GetResponseForExceptionEvent $event, RedirectResponseException $ex) { if (null !== $ex->getRedirectUrl()) { $event->setResponse(new RedirectResponse($ex->getRedirectUrl())); } return $event; }
[ "protected", "function", "handleRedirectResponseException", "(", "GetResponseForExceptionEvent", "$", "event", ",", "RedirectResponseException", "$", "ex", ")", "{", "if", "(", "null", "!==", "$", "ex", "->", "getRedirectUrl", "(", ")", ")", "{", "$", "event", "...
Handle a redirect response exception. @param GetResponseForExceptionEvent $event The event. @param RedirectResponseException $ex The exception. @return GetResponseForExceptionEvent Returns the event.
[ "Handle", "a", "redirect", "response", "exception", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/EventListener/KernelEventListener.php#L98-L103
train
webeweb/core-bundle
EventListener/KernelEventListener.php
KernelEventListener.onKernelException
public function onKernelException(GetResponseForExceptionEvent $event) { $ex = $event->getException(); // Handle the exception. if (true === ($ex instanceof BadUserRoleException)) { $this->handleBadUserRoleException($event, $ex); } if (true === ($ex instanceof RedirectResponseException)) { $this->handleRedirectResponseException($event, $ex); } return $event; }
php
public function onKernelException(GetResponseForExceptionEvent $event) { $ex = $event->getException(); // Handle the exception. if (true === ($ex instanceof BadUserRoleException)) { $this->handleBadUserRoleException($event, $ex); } if (true === ($ex instanceof RedirectResponseException)) { $this->handleRedirectResponseException($event, $ex); } return $event; }
[ "public", "function", "onKernelException", "(", "GetResponseForExceptionEvent", "$", "event", ")", "{", "$", "ex", "=", "$", "event", "->", "getException", "(", ")", ";", "// Handle the exception.", "if", "(", "true", "===", "(", "$", "ex", "instanceof", "BadU...
On kernel exception. @param GetResponseForExceptionEvent $event The event. @return GetResponseForExceptionEvent Returns the event.
[ "On", "kernel", "exception", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/EventListener/KernelEventListener.php#L111-L124
train
webeweb/core-bundle
EventListener/KernelEventListener.php
KernelEventListener.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { $this->setRequest($event->getRequest()); // Register the theme providers. $this->getThemeManager()->addGlobal(); return $event; }
php
public function onKernelRequest(GetResponseEvent $event) { $this->setRequest($event->getRequest()); // Register the theme providers. $this->getThemeManager()->addGlobal(); return $event; }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "this", "->", "setRequest", "(", "$", "event", "->", "getRequest", "(", ")", ")", ";", "// Register the theme providers.", "$", "this", "->", "getThemeManager", "(", ...
On kernel request. @param GetResponseEvent $event The event. @return GetResponseEvent Returns the event.
[ "On", "kernel", "request", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/EventListener/KernelEventListener.php#L132-L140
train
phptuts/StarterBundleForSymfony
src/Security/Provider/RefreshTokenProvider.php
RefreshTokenProvider.loadUserByUsername
public function loadUserByUsername($username) { $user = $this->userService->findUserByValidRefreshToken($username); if (empty($user)) { throw new UsernameNotFoundException('No user found with refresh token provided.'); } // This adds time to the refresh token. $this->userService->updateUserRefreshToken($user); return $user; }
php
public function loadUserByUsername($username) { $user = $this->userService->findUserByValidRefreshToken($username); if (empty($user)) { throw new UsernameNotFoundException('No user found with refresh token provided.'); } // This adds time to the refresh token. $this->userService->updateUserRefreshToken($user); return $user; }
[ "public", "function", "loadUserByUsername", "(", "$", "username", ")", "{", "$", "user", "=", "$", "this", "->", "userService", "->", "findUserByValidRefreshToken", "(", "$", "username", ")", ";", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "thr...
See if the refresh token is valid and if it is it return the user otherwise we throw the UsernameNotFoundException @param string $username the refresh token @return BaseUser
[ "See", "if", "the", "refresh", "token", "is", "valid", "and", "if", "it", "is", "it", "return", "the", "user", "otherwise", "we", "throw", "the", "UsernameNotFoundException" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/RefreshTokenProvider.php#L24-L36
train
reliv/Rcm
admin/src/Factory/AdminNavigationFactory.php
AdminNavigationFactory.shouldShowInNavigation
protected function shouldShowInNavigation(&$page) { if (isset($page['rcmOnly']) && $page['rcmOnly'] && empty($this->page) ) { return false; } if (isset($page['acl']) && is_array($page['acl']) && !empty($page['acl']['resource']) ) { $privilege = null; if (!empty($page['acl']['privilege'])) { $privilege = $page['acl']['privilege']; } $resource = $page['acl']['resource']; $resource = str_replace( [ ':siteId', ':pageName' ], [ $this->currentSite->getSiteId(), $this->page->getName() ], $resource ); if (!empty($this->page)) { $resource = str_replace( [ ':siteId', ':pageName' ], [ $this->currentSite->getSiteId(), $this->page->getName() ], $resource ); } else { $resource = str_replace( [':siteId'], [$this->currentSite->getSiteId()], $resource ); } if (!$this->isAllowed->__invoke( GetPsrRequest::invoke(), $resource, $privilege ) ) { return false; } } return true; }
php
protected function shouldShowInNavigation(&$page) { if (isset($page['rcmOnly']) && $page['rcmOnly'] && empty($this->page) ) { return false; } if (isset($page['acl']) && is_array($page['acl']) && !empty($page['acl']['resource']) ) { $privilege = null; if (!empty($page['acl']['privilege'])) { $privilege = $page['acl']['privilege']; } $resource = $page['acl']['resource']; $resource = str_replace( [ ':siteId', ':pageName' ], [ $this->currentSite->getSiteId(), $this->page->getName() ], $resource ); if (!empty($this->page)) { $resource = str_replace( [ ':siteId', ':pageName' ], [ $this->currentSite->getSiteId(), $this->page->getName() ], $resource ); } else { $resource = str_replace( [':siteId'], [$this->currentSite->getSiteId()], $resource ); } if (!$this->isAllowed->__invoke( GetPsrRequest::invoke(), $resource, $privilege ) ) { return false; } } return true; }
[ "protected", "function", "shouldShowInNavigation", "(", "&", "$", "page", ")", "{", "if", "(", "isset", "(", "$", "page", "[", "'rcmOnly'", "]", ")", "&&", "$", "page", "[", "'rcmOnly'", "]", "&&", "empty", "(", "$", "this", "->", "page", ")", ")", ...
Should link be shown in nav bar? @param $page @return bool
[ "Should", "link", "be", "shown", "in", "nav", "bar?" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Factory/AdminNavigationFactory.php#L175-L237
train
reliv/Rcm
admin/src/Factory/AdminNavigationFactory.php
AdminNavigationFactory.updatePlaceHolders
protected function updatePlaceHolders(&$item, $key, $revisionNumber) { if (empty($this->page)) { return; } $find = [ ':rcmPageName', ':rcmPageType', ':rcmPageRevision' ]; $replace = [ $this->page->getName(), $this->page->getPageType(), $revisionNumber, ]; $item = str_replace($find, $replace, $item); }
php
protected function updatePlaceHolders(&$item, $key, $revisionNumber) { if (empty($this->page)) { return; } $find = [ ':rcmPageName', ':rcmPageType', ':rcmPageRevision' ]; $replace = [ $this->page->getName(), $this->page->getPageType(), $revisionNumber, ]; $item = str_replace($find, $replace, $item); }
[ "protected", "function", "updatePlaceHolders", "(", "&", "$", "item", ",", "$", "key", ",", "$", "revisionNumber", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "page", ")", ")", "{", "return", ";", "}", "$", "find", "=", "[", "':rcmPageName'...
Update config place holders with correct data @param $item @param $key @param $revisionNumber @return void
[ "Update", "config", "place", "holders", "with", "correct", "data" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Factory/AdminNavigationFactory.php#L375-L395
train
dadajuice/zephyrus
src/Zephyrus/Database/Filterable.php
Filterable.applyFilter
public function applyFilter(string $defaultSort = "", string $defaultOrder = "") { $this->filter = new Filter(RequestFactory::read(), $defaultSort, $defaultOrder); }
php
public function applyFilter(string $defaultSort = "", string $defaultOrder = "") { $this->filter = new Filter(RequestFactory::read(), $defaultSort, $defaultOrder); }
[ "public", "function", "applyFilter", "(", "string", "$", "defaultSort", "=", "\"\"", ",", "string", "$", "defaultOrder", "=", "\"\"", ")", "{", "$", "this", "->", "filter", "=", "new", "Filter", "(", "RequestFactory", "::", "read", "(", ")", ",", "$", ...
Creates the filter according to the request. @param string $defaultSort @param string $defaultOrder
[ "Creates", "the", "filter", "according", "to", "the", "request", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Database/Filterable.php#L27-L30
train
reliv/Rcm
admin/src/Service/PageMutationService.php
PageMutationService.createNewPage
public function createNewPage($user, int $siteId, string $name, string $pageType, $data) { if (empty($user)) { throw new TrackingException('A valid user is required in ' . get_class($this)); } $validatedData = $data; $pageData = [ 'name' => $name, 'siteId' => $siteId, 'pageTitle' => $validatedData['pageTitle'], 'pageType' => $pageType, // "n" means "normal" 'siteLayoutOverride' => ( isset($validatedData['siteLayoutOverride']) ? $validatedData['siteLayoutOverride'] : null ), 'createdByUserId' => $user->getId(), 'createdReason' => 'New page in ' . get_class($this), 'author' => $user->getName(), ]; $createdPage = $this->pageRepo->createPage( $this->entityManager->find(Site::class, $siteId), $pageData ); $this->immuteblePageVersionRepo->createUnpublished( new PageLocator( $siteId, $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType()) ), $this->immutablePageContentFactory->__invoke( $createdPage->getPageTitle(), $createdPage->getDescription(), $createdPage->getKeywords(), $this->revisionRepo->find($createdPage->getStagedRevision())->getPluginWrappers()->toArray() ), $user->getId(), __CLASS__ . '::' . __FUNCTION__ ); return $createdPage; }
php
public function createNewPage($user, int $siteId, string $name, string $pageType, $data) { if (empty($user)) { throw new TrackingException('A valid user is required in ' . get_class($this)); } $validatedData = $data; $pageData = [ 'name' => $name, 'siteId' => $siteId, 'pageTitle' => $validatedData['pageTitle'], 'pageType' => $pageType, // "n" means "normal" 'siteLayoutOverride' => ( isset($validatedData['siteLayoutOverride']) ? $validatedData['siteLayoutOverride'] : null ), 'createdByUserId' => $user->getId(), 'createdReason' => 'New page in ' . get_class($this), 'author' => $user->getName(), ]; $createdPage = $this->pageRepo->createPage( $this->entityManager->find(Site::class, $siteId), $pageData ); $this->immuteblePageVersionRepo->createUnpublished( new PageLocator( $siteId, $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType()) ), $this->immutablePageContentFactory->__invoke( $createdPage->getPageTitle(), $createdPage->getDescription(), $createdPage->getKeywords(), $this->revisionRepo->find($createdPage->getStagedRevision())->getPluginWrappers()->toArray() ), $user->getId(), __CLASS__ . '::' . __FUNCTION__ ); return $createdPage; }
[ "public", "function", "createNewPage", "(", "$", "user", ",", "int", "$", "siteId", ",", "string", "$", "name", ",", "string", "$", "pageType", ",", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "throw", "new", "Tracki...
Creates a new page which starts out "staged" instead of "published". Note: This code was moved pretty mush as-is from "PageController" and that is why it is a bit messy. @param $user @param int $siteId @param string $name @param string $pageType @param $data @return Page @throws TrackingException @throws \Rcm\Exception\PageException
[ "Creates", "a", "new", "page", "which", "starts", "out", "staged", "instead", "of", "published", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Service/PageMutationService.php#L108-L148
train
reliv/Rcm
admin/src/Service/PageMutationService.php
PageMutationService.createNewPageFromTemplate
public function createNewPageFromTemplate($user, $data) { if (empty($user)) { throw new TrackingException('A valid user is required in ' . get_class($this)); } $validatedData = $data; /** @var \Rcm\Entity\Page $page */ $page = $this->pageRepo->findOneBy( [ 'pageId' => $validatedData['page-template'], 'pageType' => 't' ] ); if (empty($page)) { throw new PageNotFoundException( 'No template found for page id: ' . $validatedData['page-template'] ); } $pageData = [ 'name' => $validatedData['name'], 'pageTitle' => $validatedData['pageTitle'], 'pageType' => 'n', // "n" means "normal" 'createdByUserId' => $user->getId(), 'createdReason' => 'New page from template in ' . get_class($this), 'author' => $user->getName(), ]; $createdPage = $resultRevisionId = $this->pageRepo->copyPage( $this->currentSite, $page, $pageData ); $this->immuteblePageVersionRepo->createUnpublished( new PageLocator( $this->currentSite->getSiteId(), $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType()) ), $this->immutablePageContentFactory->__invoke( $createdPage->getPageTitle(), $createdPage->getDescription(), $createdPage->getKeywords(), $this->revisionRepo->find($resultRevisionId)->getPluginWrappers()->toArray() ), $user->getId(), __CLASS__ . '::' . __FUNCTION__ ); }
php
public function createNewPageFromTemplate($user, $data) { if (empty($user)) { throw new TrackingException('A valid user is required in ' . get_class($this)); } $validatedData = $data; /** @var \Rcm\Entity\Page $page */ $page = $this->pageRepo->findOneBy( [ 'pageId' => $validatedData['page-template'], 'pageType' => 't' ] ); if (empty($page)) { throw new PageNotFoundException( 'No template found for page id: ' . $validatedData['page-template'] ); } $pageData = [ 'name' => $validatedData['name'], 'pageTitle' => $validatedData['pageTitle'], 'pageType' => 'n', // "n" means "normal" 'createdByUserId' => $user->getId(), 'createdReason' => 'New page from template in ' . get_class($this), 'author' => $user->getName(), ]; $createdPage = $resultRevisionId = $this->pageRepo->copyPage( $this->currentSite, $page, $pageData ); $this->immuteblePageVersionRepo->createUnpublished( new PageLocator( $this->currentSite->getSiteId(), $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType()) ), $this->immutablePageContentFactory->__invoke( $createdPage->getPageTitle(), $createdPage->getDescription(), $createdPage->getKeywords(), $this->revisionRepo->find($resultRevisionId)->getPluginWrappers()->toArray() ), $user->getId(), __CLASS__ . '::' . __FUNCTION__ ); }
[ "public", "function", "createNewPageFromTemplate", "(", "$", "user", ",", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "throw", "new", "TrackingException", "(", "'A valid user is required in '", ".", "get_class", "(", "$", "thi...
Creates a new page from a template. The page starts out "staged" instead of "published". Note: This code was moved pretty mush as-is from "PageController" and that is why it is a bit messy. @return Response|ViewModel @throws TrackingException
[ "Creates", "a", "new", "page", "from", "a", "template", ".", "The", "page", "starts", "out", "staged", "instead", "of", "published", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Service/PageMutationService.php#L158-L208
train
reliv/Rcm
admin/src/Service/PageMutationService.php
PageMutationService.prepSaveData
protected function prepSaveData(&$data) { if (!is_array($data)) { $data = []; } ksort($data); $data['containers'] = []; $data['pageContainer'] = []; if (empty($data['plugins'])) { throw new InvalidArgumentException( 'Save Data missing plugins . Please make sure the data you\'re attempting to save is correctly formatted. ' ); } foreach ($data['plugins'] as &$plugin) { $this->cleanSaveData($plugin['saveData']); /* Patch for a Json Bug */ if (!empty($plugin['isSitewide']) && $plugin['isSitewide'] != 'false' && $plugin['isSitewide'] != '0' ) { $plugin['isSitewide'] = 1; } else { $plugin['isSitewide'] = 0; } if (empty($plugin['sitewideName'])) { $plugin['sitewideName'] = null; } $plugin['rank'] = (int)$plugin['rank']; $plugin['rowNumber'] = (int)$plugin['rowNumber']; $plugin['columnClass'] = (string)$plugin['columnClass']; $plugin['containerName'] = $plugin['containerId']; if ($plugin['containerType'] == 'layout') { $data['containers'][$plugin['containerId']][] = &$plugin; } else { $data['pageContainer'][] = &$plugin; } } }
php
protected function prepSaveData(&$data) { if (!is_array($data)) { $data = []; } ksort($data); $data['containers'] = []; $data['pageContainer'] = []; if (empty($data['plugins'])) { throw new InvalidArgumentException( 'Save Data missing plugins . Please make sure the data you\'re attempting to save is correctly formatted. ' ); } foreach ($data['plugins'] as &$plugin) { $this->cleanSaveData($plugin['saveData']); /* Patch for a Json Bug */ if (!empty($plugin['isSitewide']) && $plugin['isSitewide'] != 'false' && $plugin['isSitewide'] != '0' ) { $plugin['isSitewide'] = 1; } else { $plugin['isSitewide'] = 0; } if (empty($plugin['sitewideName'])) { $plugin['sitewideName'] = null; } $plugin['rank'] = (int)$plugin['rank']; $plugin['rowNumber'] = (int)$plugin['rowNumber']; $plugin['columnClass'] = (string)$plugin['columnClass']; $plugin['containerName'] = $plugin['containerId']; if ($plugin['containerType'] == 'layout') { $data['containers'][$plugin['containerId']][] = &$plugin; } else { $data['pageContainer'][] = &$plugin; } } }
[ "protected", "function", "prepSaveData", "(", "&", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "[", "]", ";", "}", "ksort", "(", "$", "data", ")", ";", "$", "data", "[", "'containers'", ...
Prep and validate data array to save @param $data @throws InvalidArgumentException
[ "Prep", "and", "validate", "data", "array", "to", "save" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Service/PageMutationService.php#L512-L560
train
reliv/Rcm
admin/src/Service/PageMutationService.php
PageMutationService.cleanSaveData
protected function cleanSaveData( &$data ) { if (empty($data)) { return; } if (is_array($data)) { ksort($data); foreach ($data as &$arrayData) { $this->cleanSaveData($arrayData); } return; } if (is_string($data)) { $data = trim( str_replace( [ "\n", "\t", "\r" ], "", $data ) ); } return; }
php
protected function cleanSaveData( &$data ) { if (empty($data)) { return; } if (is_array($data)) { ksort($data); foreach ($data as &$arrayData) { $this->cleanSaveData($arrayData); } return; } if (is_string($data)) { $data = trim( str_replace( [ "\n", "\t", "\r" ], "", $data ) ); } return; }
[ "protected", "function", "cleanSaveData", "(", "&", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", ";", "}", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "ksort", "(", "$", "data", ")", ";", "fo...
Save data clean up. @param $data
[ "Save", "data", "clean", "up", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Service/PageMutationService.php#L567-L599
train
laravelflare/flare
src/Flare/Providers/Edge/RouteServiceProvider.php
RouteServiceProvider.registerDefinedRoutes
protected function registerDefinedRoutes(Router $router) { $router->group( [ 'prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['flare'], ], function ($router) { \Flare::admin()->registerRoutes($router); $router->get('/', $this->adminController('getDashboard'))->name('dashboard'); } ); }
php
protected function registerDefinedRoutes(Router $router) { $router->group( [ 'prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['flare'], ], function ($router) { \Flare::admin()->registerRoutes($router); $router->get('/', $this->adminController('getDashboard'))->name('dashboard'); } ); }
[ "protected", "function", "registerDefinedRoutes", "(", "Router", "$", "router", ")", "{", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "\\", "Flare", "::", "config", "(", "'admin_url'", ")", ",", "'as'", "=>", "'flare::'", ",", "'middleware'", ...
Register the Defined Routes. This registers all the routes which have been defined by Admin sections defined in the Application's Flare Config (or in the runtime config if anotehr service provider has already started manipulating these dynamically). @param Router $router
[ "Register", "the", "Defined", "Routes", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Providers/Edge/RouteServiceProvider.php#L57-L70
train
laravelflare/flare
src/Flare/Providers/Edge/RouteServiceProvider.php
RouteServiceProvider.registerDefaultRoutes
protected function registerDefaultRoutes(Router $router) { $router->group( [ 'prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['web', 'flarebase'], ], function ($router) { // Logout route... $router->get('logout', $this->adminController('getLogout'))->name('logout'); if (\Flare::show('login')) { // Login request reoutes... $router->get('login', $this->adminController('getLogin'))->name('login'); $router->post('login', $this->adminController('postLogin'))->name('login'); // Password reset link request routes... $router->get('email', $this->adminController('getEmail'))->name('email'); $router->post('email', $this->adminController('postEmail'))->name('email'); // Password reset routes... $router->get('reset/{token}', $this->adminController('getReset'))->name('reset'); $router->post('reset', $this->adminController('postReset'))->name('reset'); } } ); }
php
protected function registerDefaultRoutes(Router $router) { $router->group( [ 'prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['web', 'flarebase'], ], function ($router) { // Logout route... $router->get('logout', $this->adminController('getLogout'))->name('logout'); if (\Flare::show('login')) { // Login request reoutes... $router->get('login', $this->adminController('getLogin'))->name('login'); $router->post('login', $this->adminController('postLogin'))->name('login'); // Password reset link request routes... $router->get('email', $this->adminController('getEmail'))->name('email'); $router->post('email', $this->adminController('postEmail'))->name('email'); // Password reset routes... $router->get('reset/{token}', $this->adminController('getReset'))->name('reset'); $router->post('reset', $this->adminController('postReset'))->name('reset'); } } ); }
[ "protected", "function", "registerDefaultRoutes", "(", "Router", "$", "router", ")", "{", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "\\", "Flare", "::", "config", "(", "'admin_url'", ")", ",", "'as'", "=>", "'flare::'", ",", "'middleware'", ...
Register the Default Routes. This registers all the default routes which are included with Flare. These consist of things which will probably be included with every application such as the login, logout and password reset forms. The login form can however be hidden by setting the 'show' config for 'login' to false. @param Router $router
[ "Register", "the", "Default", "Routes", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Providers/Edge/RouteServiceProvider.php#L85-L112
train
russsiq/bixbite
app/Models/Setting.php
Setting.langUpdate
public function langUpdate() { $path = skin_path('lang'.DS.$this->module->name).DS.app_locale().'.json'; $data = file_exists($path) ? json_decode(file_get_contents($path), true) : []; $data = array_filter(array_merge($data, [ $this->name => $this->title, $this->name.'#descr' => $this->attributes['descr'], 'section.' . $this->section => request('section_lang', __('section.' . $this->section)), 'legend.' . $this->fieldset => request('legend_lang', __('legend.' . $this->fieldset)), ])); ksort($data); $data = json_encode($data, JSON_UNESCAPED_UNICODE); if (JSON_ERROR_NONE !== json_last_error()) { throw new \RuntimeException(sprintf( 'Translation file `%s` contains an invalid JSON structure.', $path )); } file_put_contents($path, $data); return $this; }
php
public function langUpdate() { $path = skin_path('lang'.DS.$this->module->name).DS.app_locale().'.json'; $data = file_exists($path) ? json_decode(file_get_contents($path), true) : []; $data = array_filter(array_merge($data, [ $this->name => $this->title, $this->name.'#descr' => $this->attributes['descr'], 'section.' . $this->section => request('section_lang', __('section.' . $this->section)), 'legend.' . $this->fieldset => request('legend_lang', __('legend.' . $this->fieldset)), ])); ksort($data); $data = json_encode($data, JSON_UNESCAPED_UNICODE); if (JSON_ERROR_NONE !== json_last_error()) { throw new \RuntimeException(sprintf( 'Translation file `%s` contains an invalid JSON structure.', $path )); } file_put_contents($path, $data); return $this; }
[ "public", "function", "langUpdate", "(", ")", "{", "$", "path", "=", "skin_path", "(", "'lang'", ".", "DS", ".", "$", "this", "->", "module", "->", "name", ")", ".", "DS", ".", "app_locale", "(", ")", ".", "'.json'", ";", "$", "data", "=", "file_ex...
Update setting lang file with format json.
[ "Update", "setting", "lang", "file", "with", "format", "json", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Setting.php#L62-L87
train
russsiq/bixbite
app/Models/Setting.php
Setting.generate_page
public static function generate_page(Module $module, string $action) { $settings = static::query()->where('module_name', $module->name) ->where('action', $action)->get()->makeFormFields(); return [ 'module' => $module, 'sections' => $settings->pluck('section')->unique(), 'fieldsets' => $settings->pluck('fieldset')->unique(), 'fields' => $settings->groupBy(['section', 'fieldset']), ]; }
php
public static function generate_page(Module $module, string $action) { $settings = static::query()->where('module_name', $module->name) ->where('action', $action)->get()->makeFormFields(); return [ 'module' => $module, 'sections' => $settings->pluck('section')->unique(), 'fieldsets' => $settings->pluck('fieldset')->unique(), 'fields' => $settings->groupBy(['section', 'fieldset']), ]; }
[ "public", "static", "function", "generate_page", "(", "Module", "$", "module", ",", "string", "$", "action", ")", "{", "$", "settings", "=", "static", "::", "query", "(", ")", "->", "where", "(", "'module_name'", ",", "$", "module", "->", "name", ")", ...
Automatic config screen generator. @param \BBCMS\Models\Module $module @param string $action @return array
[ "Automatic", "config", "screen", "generator", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Setting.php#L124-L135
train
webeweb/core-bundle
Navigation/AbstractNavigationNode.php
AbstractNavigationNode.isDisplayable
public function isDisplayable() { $displayable = $this->enable && $this->visible; if (true === $displayable) { return true; } foreach ($this->getNodes() as $current) { if (false === ($current instanceof AbstractNavigationNode)) { continue; } if (true === $current->isDisplayable()) { return true; } } return $displayable; }
php
public function isDisplayable() { $displayable = $this->enable && $this->visible; if (true === $displayable) { return true; } foreach ($this->getNodes() as $current) { if (false === ($current instanceof AbstractNavigationNode)) { continue; } if (true === $current->isDisplayable()) { return true; } } return $displayable; }
[ "public", "function", "isDisplayable", "(", ")", "{", "$", "displayable", "=", "$", "this", "->", "enable", "&&", "$", "this", "->", "visible", ";", "if", "(", "true", "===", "$", "displayable", ")", "{", "return", "true", ";", "}", "foreach", "(", "...
Determines if the node is displayable. @return bool Returns true in case of success, false otherwise.
[ "Determines", "if", "the", "node", "is", "displayable", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/AbstractNavigationNode.php#L161-L175
train
phptuts/StarterBundleForSymfony
src/Security/Guard/StateLess/WebsiteGuard.php
WebsiteGuard.onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { $this->dispatcher->dispatch(self::WEBSItE_STATELESS_GUARD_AUTH_FAILED, new AuthFailedEvent($request, $exception)); return $this->removeAuthCookieFromResponse(new RedirectResponse($this->createLoginPath($request))); }
php
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { $this->dispatcher->dispatch(self::WEBSItE_STATELESS_GUARD_AUTH_FAILED, new AuthFailedEvent($request, $exception)); return $this->removeAuthCookieFromResponse(new RedirectResponse($this->createLoginPath($request))); }
[ "public", "function", "onAuthenticationFailure", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "exception", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "self", "::", "WEBSItE_STATELESS_GUARD_AUTH_FAILED", ",", "new", "Aut...
4b) If the response fails it will redirect the request to the login page with next_url for redirect purposes @param Request $request @param AuthenticationException $exception @return RedirectResponse|Response
[ "4b", ")", "If", "the", "response", "fails", "it", "will", "redirect", "the", "request", "to", "the", "login", "page", "with", "next_url", "for", "redirect", "purposes" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/WebsiteGuard.php#L57-L62
train
phptuts/StarterBundleForSymfony
src/Security/Guard/StateLess/WebsiteGuard.php
WebsiteGuard.start
public function start(Request $request, AuthenticationException $authException = null) { return new RedirectResponse($this->createLoginPath($request)); }
php
public function start(Request $request, AuthenticationException $authException = null) { return new RedirectResponse($this->createLoginPath($request)); }
[ "public", "function", "start", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "authException", "=", "null", ")", "{", "return", "new", "RedirectResponse", "(", "$", "this", "->", "createLoginPath", "(", "$", "request", ")", ")", ";", "}...
If the does not have credentials redirect the request to the login page with next_url for redirect purposes @param Request $request @param AuthenticationException|null $authException @return RedirectResponse
[ "If", "the", "does", "not", "have", "credentials", "redirect", "the", "request", "to", "the", "login", "page", "with", "next_url", "for", "redirect", "purposes" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/WebsiteGuard.php#L71-L74
train
phptuts/StarterBundleForSymfony
src/Security/Guard/StateLess/WebsiteGuard.php
WebsiteGuard.createLoginPath
protected function createLoginPath(Request $request) { $url = $this->loginPath; $url .= $this->appendNextUrl($request) ? '?'. self::NEXT_URL_PARAMETER . '=' . $request->getPathInfo() : ''; return $url; }
php
protected function createLoginPath(Request $request) { $url = $this->loginPath; $url .= $this->appendNextUrl($request) ? '?'. self::NEXT_URL_PARAMETER . '=' . $request->getPathInfo() : ''; return $url; }
[ "protected", "function", "createLoginPath", "(", "Request", "$", "request", ")", "{", "$", "url", "=", "$", "this", "->", "loginPath", ";", "$", "url", ".=", "$", "this", "->", "appendNextUrl", "(", "$", "request", ")", "?", "'?'", ".", "self", "::", ...
Returns the login path for the url and will append a next param @param Request $request @return string
[ "Returns", "the", "login", "path", "for", "the", "url", "and", "will", "append", "a", "next", "param" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/WebsiteGuard.php#L82-L88
train
phptuts/StarterBundleForSymfony
src/Security/Guard/StateLess/WebsiteGuard.php
WebsiteGuard.appendNextUrl
protected function appendNextUrl(Request $request) { return !empty($request->getPathInfo()) && strpos($request->getPathInfo(), $this->loginPath) == false; }
php
protected function appendNextUrl(Request $request) { return !empty($request->getPathInfo()) && strpos($request->getPathInfo(), $this->loginPath) == false; }
[ "protected", "function", "appendNextUrl", "(", "Request", "$", "request", ")", "{", "return", "!", "empty", "(", "$", "request", "->", "getPathInfo", "(", ")", ")", "&&", "strpos", "(", "$", "request", "->", "getPathInfo", "(", ")", ",", "$", "this", "...
Returns true if next url should be appended @param Request $request @return bool
[ "Returns", "true", "if", "next", "url", "should", "be", "appended" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/WebsiteGuard.php#L96-L99
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelTranslating.php
ModelTranslating.modelHasLanguage
public function modelHasLanguage($model, $key) { if ($this->isLanguage($key)) { return true; } if ($model->translations->get($key)) { return true; } return $this->model->language === $key; }
php
public function modelHasLanguage($model, $key) { if ($this->isLanguage($key)) { return true; } if ($model->translations->get($key)) { return true; } return $this->model->language === $key; }
[ "public", "function", "modelHasLanguage", "(", "$", "model", ",", "$", "key", ")", "{", "if", "(", "$", "this", "->", "isLanguage", "(", "$", "key", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "model", "->", "translations", "->", "ge...
Does the Model have the language created. @param Model $model @param string $key @return boolean
[ "Does", "the", "Model", "have", "the", "language", "created", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelTranslating.php#L35-L46
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelTranslating.php
ModelTranslating.routeToViewModelTranslation
public function routeToViewModelTranslation($key, $model) { if ($translation = $model->translations->get($key)) { return $this->currentUrl('view/'.$translation->id); } }
php
public function routeToViewModelTranslation($key, $model) { if ($translation = $model->translations->get($key)) { return $this->currentUrl('view/'.$translation->id); } }
[ "public", "function", "routeToViewModelTranslation", "(", "$", "key", ",", "$", "model", ")", "{", "if", "(", "$", "translation", "=", "$", "model", "->", "translations", "->", "get", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "curren...
Return route to Create Model Translation Page. @param string $key @param Model $model @return string
[ "Return", "route", "to", "Create", "Model", "Translation", "Page", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelTranslating.php#L85-L90
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelTranslating.php
ModelTranslating.applyTranslationFilter
protected function applyTranslationFilter() { if (!array_key_exists($lang = request()->get('lang'), $this->languages())) { return; } return $this->query->whereLanguage($lang); }
php
protected function applyTranslationFilter() { if (!array_key_exists($lang = request()->get('lang'), $this->languages())) { return; } return $this->query->whereLanguage($lang); }
[ "protected", "function", "applyTranslationFilter", "(", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "lang", "=", "request", "(", ")", "->", "get", "(", "'lang'", ")", ",", "$", "this", "->", "languages", "(", ")", ")", ")", "{", "return", ...
Applies the Translation Filter to the current query. @return void
[ "Applies", "the", "Translation", "Filter", "to", "the", "current", "query", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelTranslating.php#L97-L104
train
reliv/Rcm
core/src/Entity/Revision.php
Revision.getPluginWrappersByRow
public function getPluginWrappersByRow($refresh = false) { if ($this->pluginWrappers->count() < 1) { return []; } // Per request caching if (!empty($this->wrappersByRows) && !$refresh) { return $this->wrappersByRows; } $this->wrappersByRows = $this->orderPluginWrappersByRow( $this->pluginWrappers->toArray() ); return $this->wrappersByRows; }
php
public function getPluginWrappersByRow($refresh = false) { if ($this->pluginWrappers->count() < 1) { return []; } // Per request caching if (!empty($this->wrappersByRows) && !$refresh) { return $this->wrappersByRows; } $this->wrappersByRows = $this->orderPluginWrappersByRow( $this->pluginWrappers->toArray() ); return $this->wrappersByRows; }
[ "public", "function", "getPluginWrappersByRow", "(", "$", "refresh", "=", "false", ")", "{", "if", "(", "$", "this", "->", "pluginWrappers", "->", "count", "(", ")", "<", "1", ")", "{", "return", "[", "]", ";", "}", "// Per request caching", "if", "(", ...
Get Plugin Instances @return array
[ "Get", "Plugin", "Instances" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Revision.php#L345-L361
train
reliv/Rcm
core/src/Entity/Revision.php
Revision.getPluginWrapper
public function getPluginWrapper($instanceId) { if ($this->pluginWrappers->count() < 1) { return null; } /** @var PluginWrapper $pluginWrapper */ foreach ($this->pluginWrappers as $pluginWrapper) { if ($pluginWrapper->getInstance()->getInstanceId() == $instanceId) { return $pluginWrapper; } } return null; }
php
public function getPluginWrapper($instanceId) { if ($this->pluginWrappers->count() < 1) { return null; } /** @var PluginWrapper $pluginWrapper */ foreach ($this->pluginWrappers as $pluginWrapper) { if ($pluginWrapper->getInstance()->getInstanceId() == $instanceId) { return $pluginWrapper; } } return null; }
[ "public", "function", "getPluginWrapper", "(", "$", "instanceId", ")", "{", "if", "(", "$", "this", "->", "pluginWrappers", "->", "count", "(", ")", "<", "1", ")", "{", "return", "null", ";", "}", "/** @var PluginWrapper $pluginWrapper */", "foreach", "(", "...
Get Plugin Instance Wrapper by Instance Id @param integer $instanceId @return PluginWrapper
[ "Get", "Plugin", "Instance", "Wrapper", "by", "Instance", "Id" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Revision.php#L400-L414
train
reliv/Rcm
core/src/Entity/Revision.php
Revision.orderPluginWrappersByRow
public function orderPluginWrappersByRow($pluginWrappers) { $wrappersByRows = []; /** @var \Rcm\Entity\PluginWrapper $wrapper */ foreach ($pluginWrappers as $wrapper) { $rowNumber = $wrapper->getRowNumber(); if (!isset($wrappersByRows[$rowNumber])) { $wrappersByRows[$rowNumber] = []; } $wrappersByRows[$rowNumber][] = $wrapper; } ksort($wrappersByRows); return $wrappersByRows; }
php
public function orderPluginWrappersByRow($pluginWrappers) { $wrappersByRows = []; /** @var \Rcm\Entity\PluginWrapper $wrapper */ foreach ($pluginWrappers as $wrapper) { $rowNumber = $wrapper->getRowNumber(); if (!isset($wrappersByRows[$rowNumber])) { $wrappersByRows[$rowNumber] = []; } $wrappersByRows[$rowNumber][] = $wrapper; } ksort($wrappersByRows); return $wrappersByRows; }
[ "public", "function", "orderPluginWrappersByRow", "(", "$", "pluginWrappers", ")", "{", "$", "wrappersByRows", "=", "[", "]", ";", "/** @var \\Rcm\\Entity\\PluginWrapper $wrapper */", "foreach", "(", "$", "pluginWrappers", "as", "$", "wrapper", ")", "{", "$", "rowNu...
orderPluginWrappersByRow - Assumes we have ordered them by RenderOrder the DB join @param array $pluginWrappers @return array
[ "orderPluginWrappersByRow", "-", "Assumes", "we", "have", "ordered", "them", "by", "RenderOrder", "the", "DB", "join" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Revision.php#L495-L513
train
laravelflare/flare
src/Flare/FlareServiceProvider.php
FlareServiceProvider.registerBindings
protected function registerBindings() { $this->app->bind( \LaravelFlare\Flare\Contracts\Permissions\Permissionable::class, \Flare::config('permissions') ); }
php
protected function registerBindings() { $this->app->bind( \LaravelFlare\Flare\Contracts\Permissions\Permissionable::class, \Flare::config('permissions') ); }
[ "protected", "function", "registerBindings", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "\\", "LaravelFlare", "\\", "Flare", "\\", "Contracts", "\\", "Permissions", "\\", "Permissionable", "::", "class", ",", "\\", "Flare", "::", "config", ...
Register the Flare Bindings.
[ "Register", "the", "Flare", "Bindings", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/FlareServiceProvider.php#L93-L99
train
laravelflare/flare
src/Flare/FlareServiceProvider.php
FlareServiceProvider.publishAssets
protected function publishAssets() { $assets = []; foreach ($this->assets as $location => $asset) { $assets[$this->basePath($location)] = base_path($asset); } $this->publishes($assets); }
php
protected function publishAssets() { $assets = []; foreach ($this->assets as $location => $asset) { $assets[$this->basePath($location)] = base_path($asset); } $this->publishes($assets); }
[ "protected", "function", "publishAssets", "(", ")", "{", "$", "assets", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "assets", "as", "$", "location", "=>", "$", "asset", ")", "{", "$", "assets", "[", "$", "this", "->", "basePath", "(", "$...
Publishes the Flare Assets to the appropriate directories.
[ "Publishes", "the", "Flare", "Assets", "to", "the", "appropriate", "directories", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/FlareServiceProvider.php#L104-L113
train
laravelflare/flare
src/Flare/FlareServiceProvider.php
FlareServiceProvider.publishViews
protected function publishViews() { $this->loadViewsFrom($this->basePath('resources/views'), 'flare'); $this->publishes([ $this->basePath('resources/views') => base_path('resources/views/vendor/flare'), ]); }
php
protected function publishViews() { $this->loadViewsFrom($this->basePath('resources/views'), 'flare'); $this->publishes([ $this->basePath('resources/views') => base_path('resources/views/vendor/flare'), ]); }
[ "protected", "function", "publishViews", "(", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "$", "this", "->", "basePath", "(", "'resources/views'", ")", ",", "'flare'", ")", ";", "$", "this", "->", "publishes", "(", "[", "$", "this", "->", "basePat...
Publishes the Flare Views and defines the location they should be looked for in the application.
[ "Publishes", "the", "Flare", "Views", "and", "defines", "the", "location", "they", "should", "be", "looked", "for", "in", "the", "application", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/FlareServiceProvider.php#L139-L145
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.getManagedModel
public function getManagedModel() { if (!isset($this->managedModel) || $this->managedModel === null) { throw new ModelAdminException('You have a ModelAdmin which does not have a model assigned to it. ModelAdmins must include a model to manage.', 1); } return $this->managedModel; }
php
public function getManagedModel() { if (!isset($this->managedModel) || $this->managedModel === null) { throw new ModelAdminException('You have a ModelAdmin which does not have a model assigned to it. ModelAdmins must include a model to manage.', 1); } return $this->managedModel; }
[ "public", "function", "getManagedModel", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "managedModel", ")", "||", "$", "this", "->", "managedModel", "===", "null", ")", "{", "throw", "new", "ModelAdminException", "(", "'You have a ModelAdmi...
Returns the Managed Model Class. @return string
[ "Returns", "the", "Managed", "Model", "Class", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L146-L153
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.getEntityTitle
public function getEntityTitle() { if (!isset($this->entityTitle) || !$this->entityTitle) { return $this->getTitle(); } return $this->entityTitle; }
php
public function getEntityTitle() { if (!isset($this->entityTitle) || !$this->entityTitle) { return $this->getTitle(); } return $this->entityTitle; }
[ "public", "function", "getEntityTitle", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "entityTitle", ")", "||", "!", "$", "this", "->", "entityTitle", ")", "{", "return", "$", "this", "->", "getTitle", "(", ")", ";", "}", "return", ...
Get the Entity Title. @return string
[ "Get", "the", "Entity", "Title", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L170-L177
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.getPluralEntityTitle
public function getPluralEntityTitle() { if (!isset($this->pluralEntityTitle) || !$this->pluralEntityTitle) { return Str::plural($this->getEntityTitle()); } return $this->pluralEntityTitle; }
php
public function getPluralEntityTitle() { if (!isset($this->pluralEntityTitle) || !$this->pluralEntityTitle) { return Str::plural($this->getEntityTitle()); } return $this->pluralEntityTitle; }
[ "public", "function", "getPluralEntityTitle", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "pluralEntityTitle", ")", "||", "!", "$", "this", "->", "pluralEntityTitle", ")", "{", "return", "Str", "::", "plural", "(", "$", "this", "->", ...
Plural Entity Title. @return string
[ "Plural", "Entity", "Title", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L194-L201
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.getColumns
public function getColumns() { $columns = []; foreach ($this->columns as $field => $fieldTitle) { if (in_array($field, $this->model->getFillable())) { if (!$field) { $field = $fieldTitle; $fieldTitle = Str::title($fieldTitle); } $columns[$field] = $fieldTitle; continue; } // We can replace this with data_get() I believe. if (($methodBreaker = strpos($field, '.')) !== false) { $method = substr($field, 0, $methodBreaker); if (method_exists($this->model, $method)) { if (method_exists($this->model->$method(), $submethod = str_replace($method.'.', '', $field))) { $this->model->$method()->$submethod(); $columns[$field] = $fieldTitle; continue; } } } if (is_numeric($field)) { $field = $fieldTitle; $fieldTitle = Str::title($fieldTitle); } $columns[$field] = $fieldTitle; } if (count($columns)) { return $columns; } return [$this->model->getKeyName() => $this->model->getKeyName()]; }
php
public function getColumns() { $columns = []; foreach ($this->columns as $field => $fieldTitle) { if (in_array($field, $this->model->getFillable())) { if (!$field) { $field = $fieldTitle; $fieldTitle = Str::title($fieldTitle); } $columns[$field] = $fieldTitle; continue; } // We can replace this with data_get() I believe. if (($methodBreaker = strpos($field, '.')) !== false) { $method = substr($field, 0, $methodBreaker); if (method_exists($this->model, $method)) { if (method_exists($this->model->$method(), $submethod = str_replace($method.'.', '', $field))) { $this->model->$method()->$submethod(); $columns[$field] = $fieldTitle; continue; } } } if (is_numeric($field)) { $field = $fieldTitle; $fieldTitle = Str::title($fieldTitle); } $columns[$field] = $fieldTitle; } if (count($columns)) { return $columns; } return [$this->model->getKeyName() => $this->model->getKeyName()]; }
[ "public", "function", "getColumns", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "field", "=>", "$", "fieldTitle", ")", "{", "if", "(", "in_array", "(", "$", "field", ",", "$", "this", ...
Formats and returns the Columns. This is really gross, I'm removing it soon. @return
[ "Formats", "and", "returns", "the", "Columns", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L232-L272
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.getAttribute
public function getAttribute($key, $model = false) { if (!$key) { return; } if (!$model) { $model = $this->model; } $formattedKey = str_replace('.', '_', $key); if ($this->hasGetAccessor($formattedKey)) { $method = 'get'.Str::studly($formattedKey).'Attribute'; return $this->{$method}($model); } if ($this->hasGetAccessor($key)) { $method = 'get'.Str::studly($key).'Attribute'; return $this->{$method}($model); } if ($this->hasRelatedKey($key, $model)) { return $this->relatedKey($key, $model); } return $model->getAttribute($key); }
php
public function getAttribute($key, $model = false) { if (!$key) { return; } if (!$model) { $model = $this->model; } $formattedKey = str_replace('.', '_', $key); if ($this->hasGetAccessor($formattedKey)) { $method = 'get'.Str::studly($formattedKey).'Attribute'; return $this->{$method}($model); } if ($this->hasGetAccessor($key)) { $method = 'get'.Str::studly($key).'Attribute'; return $this->{$method}($model); } if ($this->hasRelatedKey($key, $model)) { return $this->relatedKey($key, $model); } return $model->getAttribute($key); }
[ "public", "function", "getAttribute", "(", "$", "key", ",", "$", "model", "=", "false", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", ";", "}", "if", "(", "!", "$", "model", ")", "{", "$", "model", "=", "$", "this", "->", "model", ...
Gets an Attribute by the provided key on either the current model or a provided model instance. @param string $key @param mixed $model @return mixed
[ "Gets", "an", "Attribute", "by", "the", "provided", "key", "on", "either", "the", "current", "model", "or", "a", "provided", "model", "instance", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L313-L342
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.hasRelatedKey
public function hasRelatedKey($key, $model = false) { if (!$model) { $model = $this->model; } if (($methodBreaker = strpos($key, '.')) !== false) { $method = substr($key, 0, $methodBreaker); if (method_exists($model, $method)) { return true; } } return false; }
php
public function hasRelatedKey($key, $model = false) { if (!$model) { $model = $this->model; } if (($methodBreaker = strpos($key, '.')) !== false) { $method = substr($key, 0, $methodBreaker); if (method_exists($model, $method)) { return true; } } return false; }
[ "public", "function", "hasRelatedKey", "(", "$", "key", ",", "$", "model", "=", "false", ")", "{", "if", "(", "!", "$", "model", ")", "{", "$", "model", "=", "$", "this", "->", "model", ";", "}", "if", "(", "(", "$", "methodBreaker", "=", "strpos...
Determines if a key resolved a related Model. @param string $key @param mixed $model @return bool
[ "Determines", "if", "a", "key", "resolved", "a", "related", "Model", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L364-L378
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.relatedKey
public function relatedKey($key, $model = false) { if (!$model) { $model = $this->model; } if (($methodBreaker = strpos($key, '.')) !== false) { $method = substr($key, 0, $methodBreaker); if (method_exists($model, $method)) { if (method_exists($model->$method, $submethod = str_replace($method.'.', '', $key))) { return $model->$method->$submethod(); } if (isset($model->$method->$submethod)) { return $model->$method->$submethod; } return $model->getRelationValue($method); } } return false; }
php
public function relatedKey($key, $model = false) { if (!$model) { $model = $this->model; } if (($methodBreaker = strpos($key, '.')) !== false) { $method = substr($key, 0, $methodBreaker); if (method_exists($model, $method)) { if (method_exists($model->$method, $submethod = str_replace($method.'.', '', $key))) { return $model->$method->$submethod(); } if (isset($model->$method->$submethod)) { return $model->$method->$submethod; } return $model->getRelationValue($method); } } return false; }
[ "public", "function", "relatedKey", "(", "$", "key", ",", "$", "model", "=", "false", ")", "{", "if", "(", "!", "$", "model", ")", "{", "$", "model", "=", "$", "this", "->", "model", ";", "}", "if", "(", "(", "$", "methodBreaker", "=", "strpos", ...
Resolves a relation based on the key provided, either on the current model or a provided model instance. @param string $key @param mixed $model @return mixed
[ "Resolves", "a", "relation", "based", "on", "the", "key", "provided", "either", "on", "the", "current", "model", "or", "a", "provided", "model", "instance", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L389-L411
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.formatFields
protected function formatFields() { $fields = $this->fields; if (!$fields instanceof AttributeCollection) { $fields = new AttributeCollection($fields, $this); } return $this->fields = $fields->formatFields(); }
php
protected function formatFields() { $fields = $this->fields; if (!$fields instanceof AttributeCollection) { $fields = new AttributeCollection($fields, $this); } return $this->fields = $fields->formatFields(); }
[ "protected", "function", "formatFields", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "fields", ";", "if", "(", "!", "$", "fields", "instanceof", "AttributeCollection", ")", "{", "$", "fields", "=", "new", "AttributeCollection", "(", "$", "fields"...
Format the provided Attribute Fields into a more usable format.
[ "Format", "the", "provided", "Attribute", "Fields", "into", "a", "more", "usable", "format", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L491-L500
train
laravelflare/flare
src/Flare/Admin/Models/ModelAdmin.php
ModelAdmin.hasSoftDeleting
public function hasSoftDeleting() { if (!$this->hasDeleting()) { return false; } $managedModelClass = $this->getManagedModel(); return in_array( SoftDeletes::class, class_uses_recursive(get_class(new $managedModelClass())) ) && $this->hasDeleting(); }
php
public function hasSoftDeleting() { if (!$this->hasDeleting()) { return false; } $managedModelClass = $this->getManagedModel(); return in_array( SoftDeletes::class, class_uses_recursive(get_class(new $managedModelClass())) ) && $this->hasDeleting(); }
[ "public", "function", "hasSoftDeleting", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasDeleting", "(", ")", ")", "{", "return", "false", ";", "}", "$", "managedModelClass", "=", "$", "this", "->", "getManagedModel", "(", ")", ";", "return", "in...
Determine if the Managed Model is using the SoftDeletes Trait. This is guarded by hasDeleting, since we shouldn't allow SoftDeleting without the deleting trait (even though it isn't really required). @return bool
[ "Determine", "if", "the", "Managed", "Model", "is", "using", "the", "SoftDeletes", "Trait", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/ModelAdmin.php#L635-L646
train
Mihai-P/yii2-core
Module.php
Module.init
public function init() { parent::init(); \Yii::$app->getI18n()->translations['core.*'] = [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => __DIR__.'/messages', ]; $this->setAliases([ '@core' => __DIR__ ]); }
php
public function init() { parent::init(); \Yii::$app->getI18n()->translations['core.*'] = [ 'class' => 'yii\i18n\PhpMessageSource', 'basePath' => __DIR__.'/messages', ]; $this->setAliases([ '@core' => __DIR__ ]); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "getI18n", "(", ")", "->", "translations", "[", "'core.*'", "]", "=", "[", "'class'", "=>", "'yii\\i18n\\PhpMessageSource'", ",", "...
Unsuccessful Login Attempts before Captcha
[ "Unsuccessful", "Login", "Attempts", "before", "Captcha" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/Module.php#L30-L41
train
Mihai-P/yii2-core
components/SeoBehavior.php
SeoBehavior.getSeoTags
public function getSeoTags() { if($this->owner->seo) { $seo = $this->owner->seo->attributes; return array_filter(array_intersect_key($seo, array_flip(['meta_title', 'meta_keywords', 'meta_description']))); } else { return []; } }
php
public function getSeoTags() { if($this->owner->seo) { $seo = $this->owner->seo->attributes; return array_filter(array_intersect_key($seo, array_flip(['meta_title', 'meta_keywords', 'meta_description']))); } else { return []; } }
[ "public", "function", "getSeoTags", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "seo", ")", "{", "$", "seo", "=", "$", "this", "->", "owner", "->", "seo", "->", "attributes", ";", "return", "array_filter", "(", "array_intersect_key", "(...
Get the seo tags as an array @return string
[ "Get", "the", "seo", "tags", "as", "an", "array" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/SeoBehavior.php#L33-L40
train
laravelflare/flare
src/Flare/Admin/Widgets/WidgetAdmin.php
WidgetAdmin.getView
public function getView() { if (view()->exists(static::$view)) { return static::$view; } if (view()->exists('admin.widgets.'.static::safeTitle().'.widget')) { return 'admin.widgets.'.static::safeTitle().'.widget'; } if (view()->exists('admin.widgets.'.static::safeTitle())) { return 'admin.widgets.'.static::safeTitle(); } if (view()->exists('admin.'.static::safeTitle())) { return 'admin.'.static::safeTitle(); } if (view()->exists('flare::'.self::$view)) { return 'flare::'.self::$view; } }
php
public function getView() { if (view()->exists(static::$view)) { return static::$view; } if (view()->exists('admin.widgets.'.static::safeTitle().'.widget')) { return 'admin.widgets.'.static::safeTitle().'.widget'; } if (view()->exists('admin.widgets.'.static::safeTitle())) { return 'admin.widgets.'.static::safeTitle(); } if (view()->exists('admin.'.static::safeTitle())) { return 'admin.'.static::safeTitle(); } if (view()->exists('flare::'.self::$view)) { return 'flare::'.self::$view; } }
[ "public", "function", "getView", "(", ")", "{", "if", "(", "view", "(", ")", "->", "exists", "(", "static", "::", "$", "view", ")", ")", "{", "return", "static", "::", "$", "view", ";", "}", "if", "(", "view", "(", ")", "->", "exists", "(", "'a...
Returns the Widget Admin View. @return string
[ "Returns", "the", "Widget", "Admin", "View", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Widgets/WidgetAdmin.php#L46-L67
train
dadajuice/zephyrus
src/Zephyrus/Security/SecureHeader.php
SecureHeader.send
public function send() { $this->sendContentOptions(); $this->sendFrameOptions(); $this->sendXssProtection(); $this->sendStrictTransport(); $this->sendAccessControlAllowOrigin(); $this->sendContentSecurity(); }
php
public function send() { $this->sendContentOptions(); $this->sendFrameOptions(); $this->sendXssProtection(); $this->sendStrictTransport(); $this->sendAccessControlAllowOrigin(); $this->sendContentSecurity(); }
[ "public", "function", "send", "(", ")", "{", "$", "this", "->", "sendContentOptions", "(", ")", ";", "$", "this", "->", "sendFrameOptions", "(", ")", ";", "$", "this", "->", "sendXssProtection", "(", ")", ";", "$", "this", "->", "sendStrictTransport", "(...
Bulk send HTTP response header aiming security purposes. Each one are explained in code. @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
[ "Bulk", "send", "HTTP", "response", "header", "aiming", "security", "purposes", ".", "Each", "one", "are", "explained", "in", "code", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/SecureHeader.php#L70-L78
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.putItem
public function putItem($name, $value = null) { if (is_null($name) || is_int($name)) { $this->_items[] = $value; } else { $this->_items[$name] = $value; } }
php
public function putItem($name, $value = null) { if (is_null($name) || is_int($name)) { $this->_items[] = $value; } else { $this->_items[$name] = $value; } }
[ "public", "function", "putItem", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", "||", "is_int", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_items", "[", "]", "=", "$", "value",...
Straight put an item. @param string $name item name @param array $value item value
[ "Straight", "put", "an", "item", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L41-L48
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.rawItem
public function rawItem($name, $default = null) { return isset($this->_items[$name]) ? $this->_items[$name] : $default; }
php
public function rawItem($name, $default = null) { return isset($this->_items[$name]) ? $this->_items[$name] : $default; }
[ "public", "function", "rawItem", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "_items", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_items", "[", "$", "name", "]", ":", "$", "...
Get raw item. @param string $name item name @return mixed item value
[ "Get", "raw", "item", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L55-L58
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.addItem
public function addItem($name, $value = null, $where = '') { if (!$this->hasItem($name)) { $this->setItem($name, $value, $where); } return $this; }
php
public function addItem($name, $value = null, $where = '') { if (!$this->hasItem($name)) { $this->setItem($name, $value, $where); } return $this; }
[ "public", "function", "addItem", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "where", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "hasItem", "(", "$", "name", ")", ")", "{", "$", "this", "->", "setItem", "(", "$", ...
Adds an item. Doesn't touch if already exists. @param string $name item name @param array $value item value @param string|array $where where to put, @see setItem @return $this for chaining
[ "Adds", "an", "item", ".", "Doesn", "t", "touch", "if", "already", "exists", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L67-L74
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.setItem
public function setItem($name, $value = null, $where = '') { if ($name === null || $where === '') { $this->putItem($name, $value); } else { $this->setItems([$name => $value], $where); } }
php
public function setItem($name, $value = null, $where = '') { if ($name === null || $where === '') { $this->putItem($name, $value); } else { $this->setItems([$name => $value], $where); } }
[ "public", "function", "setItem", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "where", "=", "''", ")", "{", "if", "(", "$", "name", "===", "null", "||", "$", "where", "===", "''", ")", "{", "$", "this", "->", "putItem", "(", "$",...
Sets an item. Silently resets if already exists and mov. @param string $name item name @param array $value item value @param string|array $where where to put, can be empty, first, last and array of before and after
[ "Sets", "an", "item", ".", "Silently", "resets", "if", "already", "exists", "and", "mov", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L82-L89
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.putItems
public function putItems(array $items) { foreach ($items as $k => $v) { $this->putItem($k, $v); } }
php
public function putItems(array $items) { foreach ($items as $k => $v) { $this->putItem($k, $v); } }
[ "public", "function", "putItems", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "putItem", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}" ]
Straight put items. @param array $items list of items @see setItem
[ "Straight", "put", "items", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L153-L158
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.setItems
public function setItems($items, $where = '') { if (empty($items)) { return; } if (empty($where)) { $this->putItems($items); } elseif ($where === 'last') { $this->_items = ArrayHelper::insertLast($this->_items, $items); } elseif ($where === 'first') { $this->_items = ArrayHelper::insertFirst($this->_items, $items); } else { $this->_items = ArrayHelper::insertInside($this->_items, $items, $where); } }
php
public function setItems($items, $where = '') { if (empty($items)) { return; } if (empty($where)) { $this->putItems($items); } elseif ($where === 'last') { $this->_items = ArrayHelper::insertLast($this->_items, $items); } elseif ($where === 'first') { $this->_items = ArrayHelper::insertFirst($this->_items, $items); } else { $this->_items = ArrayHelper::insertInside($this->_items, $items, $where); } }
[ "public", "function", "setItems", "(", "$", "items", ",", "$", "where", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "items", ")", ")", "{", "return", ";", "}", "if", "(", "empty", "(", "$", "where", ")", ")", "{", "$", "this", "->", "p...
Adds items to specified place. @param array $items list of items @param mixed $where @see setItem()
[ "Adds", "items", "to", "specified", "place", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L166-L180
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.addItems
public function addItems(array $items, $where = '') { foreach (array_keys($items) as $k) { if (!is_int($k) && $this->hasItem($k)) { unset($items[$k]); } } if (!empty($items)) { $this->setItems($items, $where); } return $this; }
php
public function addItems(array $items, $where = '') { foreach (array_keys($items) as $k) { if (!is_int($k) && $this->hasItem($k)) { unset($items[$k]); } } if (!empty($items)) { $this->setItems($items, $where); } return $this; }
[ "public", "function", "addItems", "(", "array", "$", "items", ",", "$", "where", "=", "''", ")", "{", "foreach", "(", "array_keys", "(", "$", "items", ")", "as", "$", "k", ")", "{", "if", "(", "!", "is_int", "(", "$", "k", ")", "&&", "$", "this...
Adds items to specified place. Does not touch those items that already exists. @param array $items array of items @param string|array $where where to add. See [[setItem()]] @return $this for chaining @see setItem()
[ "Adds", "items", "to", "specified", "place", ".", "Does", "not", "touch", "those", "items", "that", "already", "exists", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L190-L202
train
hiqdev/php-collection
src/BaseTrait.php
BaseTrait.unsetItems
public function unsetItems($keys = null) { if (is_null($keys)) { $this->_items = []; } elseif (is_scalar($keys)) { unset($this->_items[$keys]); } else { foreach ($keys as $k) { unset($this->_items[$k]); } } }
php
public function unsetItems($keys = null) { if (is_null($keys)) { $this->_items = []; } elseif (is_scalar($keys)) { unset($this->_items[$keys]); } else { foreach ($keys as $k) { unset($this->_items[$k]); } } }
[ "public", "function", "unsetItems", "(", "$", "keys", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "keys", ")", ")", "{", "$", "this", "->", "_items", "=", "[", "]", ";", "}", "elseif", "(", "is_scalar", "(", "$", "keys", ")", ")", "{...
Unset specified items. @param mixed $keys specification @return array list of items
[ "Unset", "specified", "items", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/BaseTrait.php#L214-L225
train
reliv/Rcm
core/src/Controller/PageCheckController.php
PageCheckController.getList
public function getList() { $pageType = $this->params('pageType', PageTypes::NORMAL); $pageId = $this->params('pageId', null); /** @var \Rcm\Validator\Page $validator */ $validator = clone($this->getServiceLocator()->get(\Rcm\Validator\Page::class)); $validator->setPageType($pageType); $return = [ 'valid' => true ]; if (!$validator->isValid($pageId)) { $return['valid'] = false; $return['error'] = $validator->getMessages(); /** @var \Zend\Http\Response $response */ $response = $this->response; $errorCodes = array_keys($return['error']); foreach ($errorCodes as &$errorCode) { if ($errorCode == $validator::PAGE_EXISTS) { $response->setStatusCode(409); break; } elseif ($errorCode == $validator::PAGE_NAME) { $response->setStatusCode(417); } } } return new JsonModel($return); }
php
public function getList() { $pageType = $this->params('pageType', PageTypes::NORMAL); $pageId = $this->params('pageId', null); /** @var \Rcm\Validator\Page $validator */ $validator = clone($this->getServiceLocator()->get(\Rcm\Validator\Page::class)); $validator->setPageType($pageType); $return = [ 'valid' => true ]; if (!$validator->isValid($pageId)) { $return['valid'] = false; $return['error'] = $validator->getMessages(); /** @var \Zend\Http\Response $response */ $response = $this->response; $errorCodes = array_keys($return['error']); foreach ($errorCodes as &$errorCode) { if ($errorCode == $validator::PAGE_EXISTS) { $response->setStatusCode(409); break; } elseif ($errorCode == $validator::PAGE_NAME) { $response->setStatusCode(417); } } } return new JsonModel($return); }
[ "public", "function", "getList", "(", ")", "{", "$", "pageType", "=", "$", "this", "->", "params", "(", "'pageType'", ",", "PageTypes", "::", "NORMAL", ")", ";", "$", "pageId", "=", "$", "this", "->", "params", "(", "'pageId'", ",", "null", ")", ";",...
Check the page is valid and return a json response @return JsonModel
[ "Check", "the", "page", "is", "valid", "and", "return", "a", "json", "response" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Controller/PageCheckController.php#L31-L64
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.attach
public function attach($name, $resolver = null, $single = false, $override = false) { if (is_array($name)) { $resolver = current($name); $name = key($name); $this->alias($resolver, $name, $override); } if ($name instanceof Asset) { $this->setParam('assets', $name->is(), $name, $override); } elseif ($resolver instanceof \Closure && $single) { $this->setParam('assets', $name, function($params) use ($resolver) { static $obj; if ($obj === null) { $obj = $resolver($params, $this); } return $obj; }, $override); } elseif ($resolver instanceof \Closure || $resolver instanceof Asset) { $this->setParam('assets', $name, $resolver, $override); } elseif (is_object($resolver)) { $this->setParam('instances', $name, $resolver, $override); } elseif (($resolver === null) && $single) { $this->setParam('instances', $name, $name, $override); } elseif ($single) { $this->setParam('instances', $name, $resolver, $override); } elseif ($resolver === null) { $this->setParam('assets', $name, $name, $override); } // If we have a singleton, make sure it is only in // the *instances* array and not within *aliases*. if ($single && isset($this->aliases[$name])) { unset($this->aliases[$name]); } return $this; }
php
public function attach($name, $resolver = null, $single = false, $override = false) { if (is_array($name)) { $resolver = current($name); $name = key($name); $this->alias($resolver, $name, $override); } if ($name instanceof Asset) { $this->setParam('assets', $name->is(), $name, $override); } elseif ($resolver instanceof \Closure && $single) { $this->setParam('assets', $name, function($params) use ($resolver) { static $obj; if ($obj === null) { $obj = $resolver($params, $this); } return $obj; }, $override); } elseif ($resolver instanceof \Closure || $resolver instanceof Asset) { $this->setParam('assets', $name, $resolver, $override); } elseif (is_object($resolver)) { $this->setParam('instances', $name, $resolver, $override); } elseif (($resolver === null) && $single) { $this->setParam('instances', $name, $name, $override); } elseif ($single) { $this->setParam('instances', $name, $resolver, $override); } elseif ($resolver === null) { $this->setParam('assets', $name, $name, $override); } // If we have a singleton, make sure it is only in // the *instances* array and not within *aliases*. if ($single && isset($this->aliases[$name])) { unset($this->aliases[$name]); } return $this; }
[ "public", "function", "attach", "(", "$", "name", ",", "$", "resolver", "=", "null", ",", "$", "single", "=", "false", ",", "$", "override", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "resolver", "=", "cu...
Attach an asset to the service manager if it doesn't already exist. Assets can be provided by a *type* Asset object, a closure providing the asst or an actual instance of an object. Setting the bool $single to true will override any asset provided via a closure to be wrapped within another closure which will cache the results. This makes asset return the same instance on each call. (A singleton). @param string|array $name The name to index the asset by. Also excepts an array so as to alias. @param Proem\Service\Asset|closure|object $resolver Some means of resolving this asset. @param bool $single @param bool $override Optionally override existing (@see override).
[ "Attach", "an", "asset", "to", "the", "service", "manager", "if", "it", "doesn", "t", "already", "exist", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L105-L148
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.singleton
public function singleton($name, $resolver = null, $override = false) { return $this->attach($name, $resolver, true, $override); }
php
public function singleton($name, $resolver = null, $override = false) { return $this->attach($name, $resolver, true, $override); }
[ "public", "function", "singleton", "(", "$", "name", ",", "$", "resolver", "=", "null", ",", "$", "override", "=", "false", ")", "{", "return", "$", "this", "->", "attach", "(", "$", "name", ",", "$", "resolver", ",", "true", ",", "$", "override", ...
A convenience method for adding a singleton. @param string|array $name The name to index the asset by. Also excepts an array so as to alias. @param Proem\Service\Asset|closure|object $resolver Some means of resolving this asset. @param bool
[ "A", "convenience", "method", "for", "adding", "a", "singleton", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L157-L160
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.overrideAsSingleton
public function overrideAsSingleton($name, $resolver = null) { return $this->singleton($name, $resolver, true, true); }
php
public function overrideAsSingleton($name, $resolver = null) { return $this->singleton($name, $resolver, true, true); }
[ "public", "function", "overrideAsSingleton", "(", "$", "name", ",", "$", "resolver", "=", "null", ")", "{", "return", "$", "this", "->", "singleton", "(", "$", "name", ",", "$", "resolver", ",", "true", ",", "true", ")", ";", "}" ]
A convenience method for overriding an existing singleton. @param string|array $name The name to index the asset by. Also excepts an array so as to alias. @param Proem\Service\Asset|closure|object $resolver Some means of resolving this asset. @param bool
[ "A", "convenience", "method", "for", "overriding", "an", "existing", "singleton", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L180-L183
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.resolve
public function resolve($name, $params = []) { // Allow hot resolving. eg; pass a closure to the resolve() method. if (isset($params['resolver']) && $params['resolver'] instanceof \Closure) { return $params['resolver'](); } // Allow custom reflection resolutions. if (isset($params['reflector']) && $params['reflector'] instanceof \Closure) { $reflection = new \ReflectionClass($name); if ($reflection->isInstantiable()) { return $params['reflector']($reflection, $name); } } // Assets are simple. if (isset($this->assets[$name])) { if ($this->assets[$name] instanceof Asset || $this->assets[$name] instanceof \Closure) { return $this->assets[$name]($params, $this); } } // Singletons are more complex if they haven't been instantiated as yet. if (isset($this->instances[$name])) { // If we have a resolver (closure or asset) that hasn't been // instantiated into an actual instance of our asset yet, do so. if ($this->instances[$name] instanceof Asset || $this->instances[$name] instanceof \Closure) { $object = $this->instances[$name]($params, $this); $this->setParam('instances', $name, $object, true); // If we have an instance, return it. } else if (is_object($this->instances[$name])) { return $this->instances[$name]; // Do what ever we can to resolve this asset. } else { try { // Attempt to resolve by name. $object = $this->autoResolve($name, $params); $this->setParam('instances', $name, $object, true); return $this->resolve($name); } catch (\LogicException $e) { try { $object = $this->autoResolve($this->instances[$name], $params); $this->setParam('instances', $name, $object, true); return $this->resolve($name); } catch (\LogicException $e) { throw $e; } } } } // Recurse back through resolve(). // This allows complex alias mappings. if (isset($this->aliases[$name])) { return $this->resolve($this->aliases[$name]); } // At this point, we still haven't resolved anything. // Try resolving by name alone. return $this->autoResolve($name, $params); }
php
public function resolve($name, $params = []) { // Allow hot resolving. eg; pass a closure to the resolve() method. if (isset($params['resolver']) && $params['resolver'] instanceof \Closure) { return $params['resolver'](); } // Allow custom reflection resolutions. if (isset($params['reflector']) && $params['reflector'] instanceof \Closure) { $reflection = new \ReflectionClass($name); if ($reflection->isInstantiable()) { return $params['reflector']($reflection, $name); } } // Assets are simple. if (isset($this->assets[$name])) { if ($this->assets[$name] instanceof Asset || $this->assets[$name] instanceof \Closure) { return $this->assets[$name]($params, $this); } } // Singletons are more complex if they haven't been instantiated as yet. if (isset($this->instances[$name])) { // If we have a resolver (closure or asset) that hasn't been // instantiated into an actual instance of our asset yet, do so. if ($this->instances[$name] instanceof Asset || $this->instances[$name] instanceof \Closure) { $object = $this->instances[$name]($params, $this); $this->setParam('instances', $name, $object, true); // If we have an instance, return it. } else if (is_object($this->instances[$name])) { return $this->instances[$name]; // Do what ever we can to resolve this asset. } else { try { // Attempt to resolve by name. $object = $this->autoResolve($name, $params); $this->setParam('instances', $name, $object, true); return $this->resolve($name); } catch (\LogicException $e) { try { $object = $this->autoResolve($this->instances[$name], $params); $this->setParam('instances', $name, $object, true); return $this->resolve($name); } catch (\LogicException $e) { throw $e; } } } } // Recurse back through resolve(). // This allows complex alias mappings. if (isset($this->aliases[$name])) { return $this->resolve($this->aliases[$name]); } // At this point, we still haven't resolved anything. // Try resolving by name alone. return $this->autoResolve($name, $params); }
[ "public", "function", "resolve", "(", "$", "name", ",", "$", "params", "=", "[", "]", ")", "{", "// Allow hot resolving. eg; pass a closure to the resolve() method.", "if", "(", "isset", "(", "$", "params", "[", "'resolver'", "]", ")", "&&", "$", "params", "["...
Return an asset by index. First, if we have a closure as a second argument, use it to resolve our asset (or at least return whatever it returns). Otherwise if we have an asset stored under this index, return it. Failing that, check for an instance at this index and return that. Failing that, resolve any aliases recursively. If all of the above fails, we start the auto resolve process. This attempts to resolve to instantiate the requested object and any dependencies that it may require to do so. @param string $name @param array $params Any extra paremeters to pass along to a closure|Asset|object
[ "Return", "an", "asset", "by", "index", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L200-L262
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.getDependencies
public function getDependencies($params) { $deps = []; foreach ($params as $param) { $dependency = $param->getClass(); if ($dependency !== null) { if ($dependency->name == 'Proem\Service\AssetManager' || $dependency->name == 'Proem\Service\AssetManagerInterface') { $deps[] = $this; } else { $deps[] = $this->resolve($dependency->name); } } else { if ($param->isDefaultValueAvailable()) { $deps[] = $param->getDefaultValue(); } } } return $deps; }
php
public function getDependencies($params) { $deps = []; foreach ($params as $param) { $dependency = $param->getClass(); if ($dependency !== null) { if ($dependency->name == 'Proem\Service\AssetManager' || $dependency->name == 'Proem\Service\AssetManagerInterface') { $deps[] = $this; } else { $deps[] = $this->resolve($dependency->name); } } else { if ($param->isDefaultValueAvailable()) { $deps[] = $param->getDefaultValue(); } } } return $deps; }
[ "public", "function", "getDependencies", "(", "$", "params", ")", "{", "$", "deps", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "dependency", "=", "$", "param", "->", "getClass", "(", ")", ";", "if", "(", ...
A simple helper to resolve dependencies given an array of dependents. @param array $dependencies
[ "A", "simple", "helper", "to", "resolve", "dependencies", "given", "an", "array", "of", "dependents", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L269-L287
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.setParam
protected function setParam($type, $index, $value, $override = false) { if ($override) { $this->{$type}[$index] = $value; } else if (!isset($this->{$type}[$index])) { $this->{$type}[$index] = $value; } return $this; }
php
protected function setParam($type, $index, $value, $override = false) { if ($override) { $this->{$type}[$index] = $value; } else if (!isset($this->{$type}[$index])) { $this->{$type}[$index] = $value; } return $this; }
[ "protected", "function", "setParam", "(", "$", "type", ",", "$", "index", ",", "$", "value", ",", "$", "override", "=", "false", ")", "{", "if", "(", "$", "override", ")", "{", "$", "this", "->", "{", "$", "type", "}", "[", "$", "index", "]", "...
A helper used to set aliases, assets and instances. Not pretty! But hey? @param string $type @param string $index @param mixed $value @param bool override override
[ "A", "helper", "used", "to", "set", "aliases", "assets", "and", "instances", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L299-L307
train
proem/proem
lib/Proem/Service/AssetManager.php
AssetManager.autoResolve
protected function autoResolve($name, $params) { try { $reflection = new \ReflectionClass($name); if ($reflection->isInstantiable()) { $construct = $reflection->getConstructor(); if ($construct === null) { $object = new $name; } else { $dependencies = $this->getDependencies($construct->getParameters()); $object = $reflection->newInstanceArgs($dependencies); } try { $method = $reflection->getMethod('setParams'); $method->invokeArgs($object, $params); // Do nothing. This method may very well not exist. } catch (\ReflectionException $e) {} // Allow a list of methods to be executed. if (isset($params['methods'])) { foreach ($params['methods'] as $method) { $method = $reflection->getMethod($method); $method->invokeArgs($object, $this->getDependencies($method->getParameters())); } } // If this single method is invoked, its results will be returned. if (isset($params['invoke'])) { $method = $params['invoke']; $method = $reflection->getMethod($method); return $method->invokeArgs($object, $this->getDependencies($method->getParameters())); } return $object; } } catch (\ReflectionException $e) { throw new \LogicException("Unable to resolve '{$name}'"); } }
php
protected function autoResolve($name, $params) { try { $reflection = new \ReflectionClass($name); if ($reflection->isInstantiable()) { $construct = $reflection->getConstructor(); if ($construct === null) { $object = new $name; } else { $dependencies = $this->getDependencies($construct->getParameters()); $object = $reflection->newInstanceArgs($dependencies); } try { $method = $reflection->getMethod('setParams'); $method->invokeArgs($object, $params); // Do nothing. This method may very well not exist. } catch (\ReflectionException $e) {} // Allow a list of methods to be executed. if (isset($params['methods'])) { foreach ($params['methods'] as $method) { $method = $reflection->getMethod($method); $method->invokeArgs($object, $this->getDependencies($method->getParameters())); } } // If this single method is invoked, its results will be returned. if (isset($params['invoke'])) { $method = $params['invoke']; $method = $reflection->getMethod($method); return $method->invokeArgs($object, $this->getDependencies($method->getParameters())); } return $object; } } catch (\ReflectionException $e) { throw new \LogicException("Unable to resolve '{$name}'"); } }
[ "protected", "function", "autoResolve", "(", "$", "name", ",", "$", "params", ")", "{", "try", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "name", ")", ";", "if", "(", "$", "reflection", "->", "isInstantiable", "(", ")", ")",...
Method to do the heavy lifting in relation to reolution of assets. In most cases this method returns an asset (object) or null. It can however be coherced into returning the results of a call to a method on the asst (object) itself by passing a method name along within the $params array indexed by "invoke". @param string $name @param array @params Any extra parameters.
[ "Method", "to", "do", "the", "heavy", "lifting", "in", "relation", "to", "reolution", "of", "assets", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Service/AssetManager.php#L319-L359
train
webeweb/core-bundle
Manager/AbstractColorManager.php
AbstractColorManager.registerProvider
public function registerProvider(ColorProviderInterface $colorProvider) { $key = ColorHelper::getIdentifier($colorProvider); if (true === array_key_exists($key, $this->index)) { throw new AlreadyRegisteredProviderException($colorProvider); } $this->index[$key] = $this->size(); return $this->addProvider($colorProvider); }
php
public function registerProvider(ColorProviderInterface $colorProvider) { $key = ColorHelper::getIdentifier($colorProvider); if (true === array_key_exists($key, $this->index)) { throw new AlreadyRegisteredProviderException($colorProvider); } $this->index[$key] = $this->size(); return $this->addProvider($colorProvider); }
[ "public", "function", "registerProvider", "(", "ColorProviderInterface", "$", "colorProvider", ")", "{", "$", "key", "=", "ColorHelper", "::", "getIdentifier", "(", "$", "colorProvider", ")", ";", "if", "(", "true", "===", "array_key_exists", "(", "$", "key", ...
Register a color provider. @param ColorProviderInterface $colorProvider The color provider. @return ManagerInterface Returns this manager. @throws AlreadyRegisteredProviderException Throws an already registered provider exception. @throws ReflectionException Throws a reflection exception if an error occurs.
[ "Register", "a", "color", "provider", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Manager/AbstractColorManager.php#L60-L70
train
reliv/Rcm
core/src/Entity/Domain.php
Domain.setDomainName
public function setDomainName($domain) { $domain = strtolower($domain); if (!$this->getDomainValidator()->isValid($domain)) { throw new InvalidArgumentException( 'Domain name is invalid: ' . $domain ); } $this->domain = $domain; }
php
public function setDomainName($domain) { $domain = strtolower($domain); if (!$this->getDomainValidator()->isValid($domain)) { throw new InvalidArgumentException( 'Domain name is invalid: ' . $domain ); } $this->domain = $domain; }
[ "public", "function", "setDomainName", "(", "$", "domain", ")", "{", "$", "domain", "=", "strtolower", "(", "$", "domain", ")", ";", "if", "(", "!", "$", "this", "->", "getDomainValidator", "(", ")", "->", "isValid", "(", "$", "domain", ")", ")", "{"...
Set the domain name @param string $domain Domain name of object @throws \Rcm\Exception\InvalidArgumentException If domain name is invalid @return void
[ "Set", "the", "domain", "name" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Domain.php#L272-L282
train
reliv/Rcm
core/src/Entity/Domain.php
Domain.setPrimaryDomain
public function setPrimaryDomain($primaryDomain) { if (empty($primaryDomain)) { $this->primaryDomain = null; $this->primaryId = null; return; } $this->primaryDomain = $primaryDomain; $this->primaryId = $primaryDomain->getDomainId(); }
php
public function setPrimaryDomain($primaryDomain) { if (empty($primaryDomain)) { $this->primaryDomain = null; $this->primaryId = null; return; } $this->primaryDomain = $primaryDomain; $this->primaryId = $primaryDomain->getDomainId(); }
[ "public", "function", "setPrimaryDomain", "(", "$", "primaryDomain", ")", "{", "if", "(", "empty", "(", "$", "primaryDomain", ")", ")", "{", "$", "this", "->", "primaryDomain", "=", "null", ";", "$", "this", "->", "primaryId", "=", "null", ";", "return",...
Set the Primary Domain. @param Domain|null $primaryDomain @return void
[ "Set", "the", "Primary", "Domain", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Domain.php#L332-L343
train
Mihai-P/yii2-core
controllers/MenuController.php
MenuController.isSortable
public function isSortable() { $this->getSearchCriteria(); $sortable = new \stdClass; if($this->searchModel->Menu_id > 0) { $sortable->sortable = true; $sortable->link = Url::toRoute(['sort', 'Menu_id' => $this->searchModel->Menu_id]); } else { $sortable->sortable = false; $sortable->message = 'Filter on a menu first'; } return $sortable; }
php
public function isSortable() { $this->getSearchCriteria(); $sortable = new \stdClass; if($this->searchModel->Menu_id > 0) { $sortable->sortable = true; $sortable->link = Url::toRoute(['sort', 'Menu_id' => $this->searchModel->Menu_id]); } else { $sortable->sortable = false; $sortable->message = 'Filter on a menu first'; } return $sortable; }
[ "public", "function", "isSortable", "(", ")", "{", "$", "this", "->", "getSearchCriteria", "(", ")", ";", "$", "sortable", "=", "new", "\\", "stdClass", ";", "if", "(", "$", "this", "->", "searchModel", "->", "Menu_id", ">", "0", ")", "{", "$", "sort...
Sets up the sorting option
[ "Sets", "up", "the", "sorting", "option" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/MenuController.php#L43-L55
train
Mihai-P/yii2-core
controllers/MenuController.php
MenuController.actionSort
public function actionSort() { $this->layout = static::FORM_LAYOUT; $modelName = $this->getCompatibilityId(); if(isset($_POST[$modelName]) && count($_POST[$modelName])) { //If we are changing the main categories then use a different algorithm if($_GET['Menu_id']==-1) { foreach($_POST[$modelName] as $key => $id) { $record = $this->findModel($id); $record->sort_order = $key+1; $record->save(); } } else { $parent = $this->findModel($_GET['Menu_id']); foreach($_POST[$modelName] as $key => $id) { $record = $this->findModel($id); $record->appendTo($parent); } } return $this->redirect(['index']); } else { $this->getSearchCriteria(); $searchCriteria = ['MenuSearch' => ['Menu_id' => $this->searchModel->Menu_id]]; $this->searchModel = new $this->MainModelSearch; $this->dataProvider = $this->searchModel->search($searchCriteria); $this->dataProvider->pagination = false; return $this->render('sort', [ 'searchModel' => $this->searchModel, 'dataProvider' => $this->dataProvider, ]); } }
php
public function actionSort() { $this->layout = static::FORM_LAYOUT; $modelName = $this->getCompatibilityId(); if(isset($_POST[$modelName]) && count($_POST[$modelName])) { //If we are changing the main categories then use a different algorithm if($_GET['Menu_id']==-1) { foreach($_POST[$modelName] as $key => $id) { $record = $this->findModel($id); $record->sort_order = $key+1; $record->save(); } } else { $parent = $this->findModel($_GET['Menu_id']); foreach($_POST[$modelName] as $key => $id) { $record = $this->findModel($id); $record->appendTo($parent); } } return $this->redirect(['index']); } else { $this->getSearchCriteria(); $searchCriteria = ['MenuSearch' => ['Menu_id' => $this->searchModel->Menu_id]]; $this->searchModel = new $this->MainModelSearch; $this->dataProvider = $this->searchModel->search($searchCriteria); $this->dataProvider->pagination = false; return $this->render('sort', [ 'searchModel' => $this->searchModel, 'dataProvider' => $this->dataProvider, ]); } }
[ "public", "function", "actionSort", "(", ")", "{", "$", "this", "->", "layout", "=", "static", "::", "FORM_LAYOUT", ";", "$", "modelName", "=", "$", "this", "->", "getCompatibilityId", "(", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "$", "...
Allows sorting of the menus
[ "Allows", "sorting", "of", "the", "menus" ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/MenuController.php#L60-L92
train
Mihai-P/yii2-core
controllers/MenuController.php
MenuController.actionStatus
public function actionStatus($id) { $model = $this->findModel($id); if($model->status == "active") { $model->status = "inactive"; } else { $model->status = "active"; } $model->save(false); if(Yii::$app->request->getIsAjax()) { Yii::$app->response->format = 'json'; return ['success' => true]; } else { return $this->redirect(['index']); } }
php
public function actionStatus($id) { $model = $this->findModel($id); if($model->status == "active") { $model->status = "inactive"; } else { $model->status = "active"; } $model->save(false); if(Yii::$app->request->getIsAjax()) { Yii::$app->response->format = 'json'; return ['success' => true]; } else { return $this->redirect(['index']); } }
[ "public", "function", "actionStatus", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "status", "==", "\"active\"", ")", "{", "$", "model", "->", "status", "=", ...
Deletes an existing Faq model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Deletes", "an", "existing", "Faq", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/MenuController.php#L99-L114
train
Mihai-P/yii2-core
controllers/MenuController.php
MenuController.actionCreate
public function actionCreate() { $this->layout = static::FORM_LAYOUT; $model = new $this->MainModel; if ($model->load(Yii::$app->request->post()) && $model->validate()) { if(empty($model->Menu_id)) { Yii::info('Making the new node as root'); $model->makeRoot(); } else { $parent_node = Menu::findOne($model->Menu_id); $model->appendTo($parent_node); Yii::info('Making the new node as a child of ' . $parent_node->id); } $this->saveHistory($model, $this->historyField); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } }
php
public function actionCreate() { $this->layout = static::FORM_LAYOUT; $model = new $this->MainModel; if ($model->load(Yii::$app->request->post()) && $model->validate()) { if(empty($model->Menu_id)) { Yii::info('Making the new node as root'); $model->makeRoot(); } else { $parent_node = Menu::findOne($model->Menu_id); $model->appendTo($parent_node); Yii::info('Making the new node as a child of ' . $parent_node->id); } $this->saveHistory($model, $this->historyField); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "this", "->", "layout", "=", "static", "::", "FORM_LAYOUT", ";", "$", "model", "=", "new", "$", "this", "->", "MainModel", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", ...
Creates a new Faq model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "Faq", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
c52753c9c8e133b2f1ca708ae02178b51eb2e5a3
https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/controllers/MenuController.php#L122-L144
train
dadajuice/zephyrus
src/Zephyrus/Utilities/Uploaders/ImageUploader.php
ImageUploader.validateImageMimeType
private function validateImageMimeType() { $imageType = exif_imagetype($this->uploadFile->getTemporaryFilename()); $mime = image_type_to_mime_type($imageType); if (!$imageType || !in_array($mime, parent::getAllowedMimeTypes())) { throw new \Exception("Uploaded image appears to be corrupt"); // @codeCoverageIgnore } }
php
private function validateImageMimeType() { $imageType = exif_imagetype($this->uploadFile->getTemporaryFilename()); $mime = image_type_to_mime_type($imageType); if (!$imageType || !in_array($mime, parent::getAllowedMimeTypes())) { throw new \Exception("Uploaded image appears to be corrupt"); // @codeCoverageIgnore } }
[ "private", "function", "validateImageMimeType", "(", ")", "{", "$", "imageType", "=", "exif_imagetype", "(", "$", "this", "->", "uploadFile", "->", "getTemporaryFilename", "(", ")", ")", ";", "$", "mime", "=", "image_type_to_mime_type", "(", "$", "imageType", ...
Validate that the mime type is an actual valid image. @throws \Exception
[ "Validate", "that", "the", "mime", "type", "is", "an", "actual", "valid", "image", "." ]
c5fc47d7ecd158adb451702f9486c0409d71d8b0
https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Uploaders/ImageUploader.php#L61-L68
train
proem/proem
lib/Proem/Filter/ChainManager.php
ChainManager.attach
public function attach(ChainEventInterface $event, $priority = 0) { $this->queue->insert($event, $priority); return $this; }
php
public function attach(ChainEventInterface $event, $priority = 0) { $this->queue->insert($event, $priority); return $this; }
[ "public", "function", "attach", "(", "ChainEventInterface", "$", "event", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "queue", "->", "insert", "(", "$", "event", ",", "$", "priority", ")", ";", "return", "$", "this", ";", "}" ]
Insert an event into the queue @param Proem\Filter\ChainEventInterface $event @param int $priority
[ "Insert", "an", "event", "into", "the", "queue" ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Filter/ChainManager.php#L93-L97
train
GoIntegro/hateoas
JsonApi/Request/Parser.php
Parser.parsePathParts
private function parsePathParts(Request $request) { if (empty($this->apiUrlPath)) { throw new \Exception(self::ERROR_NO_API_BASE_PATH); } // Resolving not knowing whether the base contains a domain. $base = explode('/', $this->apiUrlPath); $path = explode('/', $request->getPathInfo()); return array_values(array_diff($path, $base)); }
php
private function parsePathParts(Request $request) { if (empty($this->apiUrlPath)) { throw new \Exception(self::ERROR_NO_API_BASE_PATH); } // Resolving not knowing whether the base contains a domain. $base = explode('/', $this->apiUrlPath); $path = explode('/', $request->getPathInfo()); return array_values(array_diff($path, $base)); }
[ "private", "function", "parsePathParts", "(", "Request", "$", "request", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "apiUrlPath", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "self", "::", "ERROR_NO_API_BASE_PATH", ")", ";", "}", "//...
The "router" Symfony service cannot be used, regretably. @param Request $request @return array
[ "The", "router", "Symfony", "service", "cannot", "be", "used", "regretably", "." ]
4799794294079f8bd3839e76175134219f876105
https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/JsonApi/Request/Parser.php#L337-L348
train
hiqdev/php-collection
src/ArrayHelper.php
ArrayHelper.getItems
public static function getItems($array, $keys = null) { if (is_null($keys)) { return $array; } elseif (is_scalar($keys)) { $keys = [$keys => $array[$keys]]; } $res = []; foreach ($keys as $k) { if (array_key_exists($k, $array)) { $res[$k] = $array[$k]; } } return $res; }
php
public static function getItems($array, $keys = null) { if (is_null($keys)) { return $array; } elseif (is_scalar($keys)) { $keys = [$keys => $array[$keys]]; } $res = []; foreach ($keys as $k) { if (array_key_exists($k, $array)) { $res[$k] = $array[$k]; } } return $res; }
[ "public", "static", "function", "getItems", "(", "$", "array", ",", "$", "keys", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "keys", ")", ")", "{", "return", "$", "array", ";", "}", "elseif", "(", "is_scalar", "(", "$", "keys", ")", ")...
Get specified items as array. @param mixed $keys specification @return array
[ "Get", "specified", "items", "as", "array", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/ArrayHelper.php#L67-L81
train
hiqdev/php-collection
src/ArrayHelper.php
ArrayHelper.prepareWhere
protected static function prepareWhere(array $array, $list) { if (!is_array($list)) { $list = [$list]; } foreach ($list as $v) { if (array_key_exists($v, $array)) { return $v; } } return null; }
php
protected static function prepareWhere(array $array, $list) { if (!is_array($list)) { $list = [$list]; } foreach ($list as $v) { if (array_key_exists($v, $array)) { return $v; } } return null; }
[ "protected", "static", "function", "prepareWhere", "(", "array", "$", "array", ",", "$", "list", ")", "{", "if", "(", "!", "is_array", "(", "$", "list", ")", ")", "{", "$", "list", "=", "[", "$", "list", "]", ";", "}", "foreach", "(", "$", "list"...
Internal function to prepare where list for insertInside. @param array $array source array @param array|string $list array to convert @return array
[ "Internal", "function", "to", "prepare", "where", "list", "for", "insertInside", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/ArrayHelper.php#L162-L174
train
hiqdev/php-collection
src/ArrayHelper.php
ArrayHelper.unique
public static function unique($array) { $suitable = true; foreach ($array as $k => &$v) { if (is_array($v)) { $v = self::unique($v); } elseif (!is_int($k)) { $suitable = false; } } return $suitable ? self::uniqueFlat($array) : $array; }
php
public static function unique($array) { $suitable = true; foreach ($array as $k => &$v) { if (is_array($v)) { $v = self::unique($v); } elseif (!is_int($k)) { $suitable = false; } } return $suitable ? self::uniqueFlat($array) : $array; }
[ "public", "static", "function", "unique", "(", "$", "array", ")", "{", "$", "suitable", "=", "true", ";", "foreach", "(", "$", "array", "as", "$", "k", "=>", "&", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$", "...
Recursively removes duplicate values from non-associative arrays.
[ "Recursively", "removes", "duplicate", "values", "from", "non", "-", "associative", "arrays", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/ArrayHelper.php#L179-L191
train
hiqdev/php-collection
src/ArrayHelper.php
ArrayHelper.uniqueFlat
public static function uniqueFlat($array) { $uniqs = []; $res = []; foreach ($array as $k => $v) { $uv = var_export($v, true); if (array_key_exists($uv, $uniqs)) { continue; } $uniqs[$uv] = 1; $res[$k] = $v; } return $res; }
php
public static function uniqueFlat($array) { $uniqs = []; $res = []; foreach ($array as $k => $v) { $uv = var_export($v, true); if (array_key_exists($uv, $uniqs)) { continue; } $uniqs[$uv] = 1; $res[$k] = $v; } return $res; }
[ "public", "static", "function", "uniqueFlat", "(", "$", "array", ")", "{", "$", "uniqs", "=", "[", "]", ";", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "uv", "=", "var_export", ...
Non-recursively removes duplicate values from non-associative arrays.
[ "Non", "-", "recursively", "removes", "duplicate", "values", "from", "non", "-", "associative", "arrays", "." ]
7f7fdacb62ff848147607a018ee889a4ae8fb010
https://github.com/hiqdev/php-collection/blob/7f7fdacb62ff848147607a018ee889a4ae8fb010/src/ArrayHelper.php#L196-L210
train
reliv/Rcm
admin/src/Module.php
Module.onBootstrap
public function onBootstrap(MvcEvent $e) { $serviceManager = $e->getApplication()->getServiceManager(); // Don't break console routes if ($e->getRequest() instanceof Request) { return; } //Add Domain Checker $onDispatchListener = $serviceManager->get( \RcmAdmin\EventListener\DispatchListener::class ); /** @var \Zend\EventManager\EventManager $eventManager */ $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach( MvcEvent::EVENT_DISPATCH, [ $onDispatchListener, 'getAdminPanel' ], 10001 ); }
php
public function onBootstrap(MvcEvent $e) { $serviceManager = $e->getApplication()->getServiceManager(); // Don't break console routes if ($e->getRequest() instanceof Request) { return; } //Add Domain Checker $onDispatchListener = $serviceManager->get( \RcmAdmin\EventListener\DispatchListener::class ); /** @var \Zend\EventManager\EventManager $eventManager */ $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach( MvcEvent::EVENT_DISPATCH, [ $onDispatchListener, 'getAdminPanel' ], 10001 ); }
[ "public", "function", "onBootstrap", "(", "MvcEvent", "$", "e", ")", "{", "$", "serviceManager", "=", "$", "e", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", ";", "// Don't break console routes", "if", "(", "$", "e", "->", "getReques...
Add Listeners to the bootstrap @param MvcEvent $e Event Manager @return null
[ "Add", "Listeners", "to", "the", "bootstrap" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Module.php#L32-L57
train
proem/proem
lib/Proem/Routing/RouteManager.php
RouteManager.group
public function group(array $attributes, callable $callback) { $this->groupAttributes = $attributes; $callback(); $this->groupAttributes = null; return $this; }
php
public function group(array $attributes, callable $callback) { $this->groupAttributes = $attributes; $callback(); $this->groupAttributes = null; return $this; }
[ "public", "function", "group", "(", "array", "$", "attributes", ",", "callable", "$", "callback", ")", "{", "$", "this", "->", "groupAttributes", "=", "$", "attributes", ";", "$", "callback", "(", ")", ";", "$", "this", "->", "groupAttributes", "=", "nul...
Group routes by attributes. @param array $attributes @param callable $callback
[ "Group", "routes", "by", "attributes", "." ]
31e00b315a12d6bfa65803ad49b3117d8b9c4da4
https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Routing/RouteManager.php#L131-L137
train
phptuts/StarterBundleForSymfony
src/Security/Guard/Login/EmailGuard.php
EmailGuard.supports
public function supports(Request $request) { $post = json_decode($request->getContent(), true); return !empty($post[self::EMAIL_FIELD]) && !empty($post[self::PASSWORD_FIELD]); }
php
public function supports(Request $request) { $post = json_decode($request->getContent(), true); return !empty($post[self::EMAIL_FIELD]) && !empty($post[self::PASSWORD_FIELD]); }
[ "public", "function", "supports", "(", "Request", "$", "request", ")", "{", "$", "post", "=", "json_decode", "(", "$", "request", "->", "getContent", "(", ")", ",", "true", ")", ";", "return", "!", "empty", "(", "$", "post", "[", "self", "::", "EMAIL...
1) Returns true if request has email and password in the json body @param Request $request @return bool
[ "1", ")", "Returns", "true", "if", "request", "has", "email", "and", "password", "in", "the", "json", "body" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/Login/EmailGuard.php#L57-L62
train
phptuts/StarterBundleForSymfony
src/Security/Guard/Login/EmailGuard.php
EmailGuard.getCredentials
public function getCredentials(Request $request) { $post = json_decode($request->getContent(), true); return new CredentialEmailModel($post[self::EMAIL_FIELD], $post[self::PASSWORD_FIELD]); }
php
public function getCredentials(Request $request) { $post = json_decode($request->getContent(), true); return new CredentialEmailModel($post[self::EMAIL_FIELD], $post[self::PASSWORD_FIELD]); }
[ "public", "function", "getCredentials", "(", "Request", "$", "request", ")", "{", "$", "post", "=", "json_decode", "(", "$", "request", "->", "getContent", "(", ")", ",", "true", ")", ";", "return", "new", "CredentialEmailModel", "(", "$", "post", "[", "...
2) Returns CredentialEmailModel @param Request $request @return CredentialEmailModel
[ "2", ")", "Returns", "CredentialEmailModel" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/Login/EmailGuard.php#L70-L75
train
phptuts/StarterBundleForSymfony
src/Security/Guard/Login/EmailGuard.php
EmailGuard.checkCredentials
public function checkCredentials($credentials, UserInterface $user) { return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword()); }
php
public function checkCredentials($credentials, UserInterface $user) { return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword()); }
[ "public", "function", "checkCredentials", "(", "$", "credentials", ",", "UserInterface", "$", "user", ")", "{", "return", "$", "this", "->", "userPasswordEncoderFactory", "->", "isPasswordValid", "(", "$", "user", ",", "$", "credentials", "->", "getPassword", "(...
4) Returns true if the credentials are valid. For token based requests, facebook, etc. Token are validate by a 3rd party provider in the getUser function @param CredentialEmailModel $credentials @param UserInterface $user @return bool
[ "4", ")", "Returns", "true", "if", "the", "credentials", "are", "valid", ".", "For", "token", "based", "requests", "facebook", "etc", ".", "Token", "are", "validate", "by", "a", "3rd", "party", "provider", "in", "the", "getUser", "function" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/Login/EmailGuard.php#L85-L88
train
webeweb/core-bundle
EventListener/NotificationEventListener.php
NotificationEventListener.onNotify
public function onNotify(NotificationEvent $event) { if (true === ($this->getSession() instanceof Session)) { $this->getSession()->getFlashBag()->add($event->getNotification()->getType(), $event->getNotification()->getContent()); } return $event; }
php
public function onNotify(NotificationEvent $event) { if (true === ($this->getSession() instanceof Session)) { $this->getSession()->getFlashBag()->add($event->getNotification()->getType(), $event->getNotification()->getContent()); } return $event; }
[ "public", "function", "onNotify", "(", "NotificationEvent", "$", "event", ")", "{", "if", "(", "true", "===", "(", "$", "this", "->", "getSession", "(", ")", "instanceof", "Session", ")", ")", "{", "$", "this", "->", "getSession", "(", ")", "->", "getF...
On notify. @param NotificationEvent $event The event. @return NotificationEvent Returns the event.
[ "On", "notify", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/EventListener/NotificationEventListener.php#L51-L56
train
reliv/Rcm
core/src/Entity/PluginInstance.php
PluginInstance.setInstanceConfig
public function setInstanceConfig($instanceConfig) { $this->instanceConfig = json_encode($instanceConfig); if (json_last_error() !== JSON_ERROR_NONE) { throw new \Exception(json_last_error_msg()); } }
php
public function setInstanceConfig($instanceConfig) { $this->instanceConfig = json_encode($instanceConfig); if (json_last_error() !== JSON_ERROR_NONE) { throw new \Exception(json_last_error_msg()); } }
[ "public", "function", "setInstanceConfig", "(", "$", "instanceConfig", ")", "{", "$", "this", "->", "instanceConfig", "=", "json_encode", "(", "$", "instanceConfig", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw",...
Sets the config that will be stored in the DB as JSON @param array $instanceConfig new value test @return void @throws \Exception
[ "Sets", "the", "config", "that", "will", "be", "stored", "in", "the", "DB", "as", "JSON" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/PluginInstance.php#L400-L407
train
russsiq/bixbite
app/Support/CacheFile.php
CacheFile.created
public function created(string $key) { $path = $this->path($key); return $this->files->exists($path) ? \Carbon\Carbon::createFromTimestamp( $this->files->lastModified($path) ) : null; }
php
public function created(string $key) { $path = $this->path($key); return $this->files->exists($path) ? \Carbon\Carbon::createFromTimestamp( $this->files->lastModified($path) ) : null; }
[ "public", "function", "created", "(", "string", "$", "key", ")", "{", "$", "path", "=", "$", "this", "->", "path", "(", "$", "key", ")", ";", "return", "$", "this", "->", "files", "->", "exists", "(", "$", "path", ")", "?", "\\", "Carbon", "\\", ...
Get datetime of created cache file by key. @param string $key @return \Carbon\Carbon|null
[ "Get", "datetime", "of", "created", "cache", "file", "by", "key", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/CacheFile.php#L28-L36
train
russsiq/bixbite
app/Support/CacheFile.php
CacheFile.expired
public function expired(string $key) { $path = $this->path($key); return $this->files->exists($path) ? \Carbon\Carbon::createFromTimestamp( substr($this->files->get($path), 0, 10) ) : null; }
php
public function expired(string $key) { $path = $this->path($key); return $this->files->exists($path) ? \Carbon\Carbon::createFromTimestamp( substr($this->files->get($path), 0, 10) ) : null; }
[ "public", "function", "expired", "(", "string", "$", "key", ")", "{", "$", "path", "=", "$", "this", "->", "path", "(", "$", "key", ")", ";", "return", "$", "this", "->", "files", "->", "exists", "(", "$", "path", ")", "?", "\\", "Carbon", "\\", ...
Get the expiration time from cache file by key. @param string $key @return \Carbon\Carbon|null
[ "Get", "the", "expiration", "time", "from", "cache", "file", "by", "key", "." ]
f7d9dcdc81c1803406bf7b9374887578f10f9c08
https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/CacheFile.php#L43-L51
train
noodle69/EdgarEzUICronBundle
src/bundle/EventListener/ConfigureMenuListener.php
ConfigureMenuListener.onMenuConfigure
public function onMenuConfigure(ConfigureMenuEvent $event) { if (!$this->permissionResolver->hasAccess('uicron', 'list')) { return; } $menu = $event->getMenu(); $cronsMenu = $menu->getChild(MainMenuBuilder::ITEM_ADMIN); $cronsMenu->addChild(self::ITEM_CRONS, ['route' => 'edgar.ezuicron.list']); }
php
public function onMenuConfigure(ConfigureMenuEvent $event) { if (!$this->permissionResolver->hasAccess('uicron', 'list')) { return; } $menu = $event->getMenu(); $cronsMenu = $menu->getChild(MainMenuBuilder::ITEM_ADMIN); $cronsMenu->addChild(self::ITEM_CRONS, ['route' => 'edgar.ezuicron.list']); }
[ "public", "function", "onMenuConfigure", "(", "ConfigureMenuEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "permissionResolver", "->", "hasAccess", "(", "'uicron'", ",", "'list'", ")", ")", "{", "return", ";", "}", "$", "menu", "=", "...
Add cron to admin menu. @param ConfigureMenuEvent $event
[ "Add", "cron", "to", "admin", "menu", "." ]
54f31e1cd13a9fddc0d67b0481333ed64849c70a
https://github.com/noodle69/EdgarEzUICronBundle/blob/54f31e1cd13a9fddc0d67b0481333ed64849c70a/src/bundle/EventListener/ConfigureMenuListener.php#L36-L46
train
phptuts/StarterBundleForSymfony
src/Service/AuthResponseService.php
AuthResponseService.createJsonAuthResponse
public function createJsonAuthResponse(BaseUser $user) { $responseModel = $this->createResponseAuthModel($user); $response = new JsonResponse($responseModel->getBody(), Response::HTTP_CREATED); return $this->setCookieForResponse($response, $responseModel); }
php
public function createJsonAuthResponse(BaseUser $user) { $responseModel = $this->createResponseAuthModel($user); $response = new JsonResponse($responseModel->getBody(), Response::HTTP_CREATED); return $this->setCookieForResponse($response, $responseModel); }
[ "public", "function", "createJsonAuthResponse", "(", "BaseUser", "$", "user", ")", "{", "$", "responseModel", "=", "$", "this", "->", "createResponseAuthModel", "(", "$", "user", ")", ";", "$", "response", "=", "new", "JsonResponse", "(", "$", "responseModel",...
Creates a json response that will contain new credentials for the user. @param BaseUser $user @return JsonResponse|Response
[ "Creates", "a", "json", "response", "that", "will", "contain", "new", "credentials", "for", "the", "user", "." ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/AuthResponseService.php#L50-L57
train
phptuts/StarterBundleForSymfony
src/Service/AuthResponseService.php
AuthResponseService.authenticateResponse
public function authenticateResponse(BaseUser $user, Response $response) { return $this->setCookieForResponse($response, $this->createResponseAuthModel($user)); }
php
public function authenticateResponse(BaseUser $user, Response $response) { return $this->setCookieForResponse($response, $this->createResponseAuthModel($user)); }
[ "public", "function", "authenticateResponse", "(", "BaseUser", "$", "user", ",", "Response", "$", "response", ")", "{", "return", "$", "this", "->", "setCookieForResponse", "(", "$", "response", ",", "$", "this", "->", "createResponseAuthModel", "(", "$", "use...
Sets the auth cookie for an authenticated response @param BaseUser $user @param Response $response @return Response
[ "Sets", "the", "auth", "cookie", "for", "an", "authenticated", "response" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/AuthResponseService.php#L66-L69
train
phptuts/StarterBundleForSymfony
src/Service/AuthResponseService.php
AuthResponseService.setCookieForResponse
protected function setCookieForResponse(Response $response, ResponseAuthenticationModel $responseModel) { $response->headers->setCookie( new Cookie( self::AUTH_COOKIE, $responseModel->getAuthToken(), $responseModel->getTokenExpirationTimeStamp(), null, false, false ) ); return $response; }
php
protected function setCookieForResponse(Response $response, ResponseAuthenticationModel $responseModel) { $response->headers->setCookie( new Cookie( self::AUTH_COOKIE, $responseModel->getAuthToken(), $responseModel->getTokenExpirationTimeStamp(), null, false, false ) ); return $response; }
[ "protected", "function", "setCookieForResponse", "(", "Response", "$", "response", ",", "ResponseAuthenticationModel", "$", "responseModel", ")", "{", "$", "response", "->", "headers", "->", "setCookie", "(", "new", "Cookie", "(", "self", "::", "AUTH_COOKIE", ",",...
Sets the auth cookie @param Response $response @param ResponseAuthenticationModel $responseModel @return Response
[ "Sets", "the", "auth", "cookie" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/AuthResponseService.php#L78-L92
train
phptuts/StarterBundleForSymfony
src/Service/AuthResponseService.php
AuthResponseService.createResponseAuthModel
protected function createResponseAuthModel(BaseUser $user) { $user = $this->userService->updateUserRefreshToken($user); $authTokenModel = $this->authTokenService->createAuthTokenModel($user); return new ResponseAuthenticationModel($user, $authTokenModel, $user->getAuthRefreshModel()); }
php
protected function createResponseAuthModel(BaseUser $user) { $user = $this->userService->updateUserRefreshToken($user); $authTokenModel = $this->authTokenService->createAuthTokenModel($user); return new ResponseAuthenticationModel($user, $authTokenModel, $user->getAuthRefreshModel()); }
[ "protected", "function", "createResponseAuthModel", "(", "BaseUser", "$", "user", ")", "{", "$", "user", "=", "$", "this", "->", "userService", "->", "updateUserRefreshToken", "(", "$", "user", ")", ";", "$", "authTokenModel", "=", "$", "this", "->", "authTo...
Creates a credentials model for the user @param BaseUser $user @return ResponseAuthenticationModel
[ "Creates", "a", "credentials", "model", "for", "the", "user" ]
aa953fbafea512a0535ca20e94ecd7d318db1e13
https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Service/AuthResponseService.php#L100-L106
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelSoftDeleting.php
ModelSoftDeleting.doDelete
private function doDelete() { if (!$this->model->trashed()) { $this->model->delete(); event(new ModelSoftDelete($this)); return; } $this->model->forceDelete(); event(new ModelDelete($this)); }
php
private function doDelete() { if (!$this->model->trashed()) { $this->model->delete(); event(new ModelSoftDelete($this)); return; } $this->model->forceDelete(); event(new ModelDelete($this)); }
[ "private", "function", "doDelete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "model", "->", "trashed", "(", ")", ")", "{", "$", "this", "->", "model", "->", "delete", "(", ")", ";", "event", "(", "new", "ModelSoftDelete", "(", "$", "this", ...
The actual delete action. @return
[ "The", "actual", "delete", "action", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelSoftDeleting.php#L96-L107
train
laravelflare/flare
src/Flare/Admin/Models/Traits/ModelSoftDeleting.php
ModelSoftDeleting.restore
public function restore($modelitemId) { event(new BeforeRestore($this)); $this->findOnlyTrashed($modelitemId); $this->beforeRestore(); $this->doRestore(); $this->afterRestore(); event(new AfterRestore($this)); }
php
public function restore($modelitemId) { event(new BeforeRestore($this)); $this->findOnlyTrashed($modelitemId); $this->beforeRestore(); $this->doRestore(); $this->afterRestore(); event(new AfterRestore($this)); }
[ "public", "function", "restore", "(", "$", "modelitemId", ")", "{", "event", "(", "new", "BeforeRestore", "(", "$", "this", ")", ")", ";", "$", "this", "->", "findOnlyTrashed", "(", "$", "modelitemId", ")", ";", "$", "this", "->", "beforeRestore", "(", ...
Restore Action. Fires off beforeRestore(), doRestore() and afterRestore() @param int $modelitemId @return
[ "Restore", "Action", "." ]
9b40388e0a28a92e8a9ba5196c28603e4a230dde
https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelSoftDeleting.php#L136-L149
train
brightnucleus/injector
src/CachingReflector.php
CachingReflector.getClass
public function getClass($class) { $cacheKey = self::CACHE_KEY_CLASSES . strtolower($class); if (! $reflectionClass = $this->cache->fetch($cacheKey)) { $reflectionClass = new ReflectionClass($class); $this->cache->store($cacheKey, $reflectionClass); } return $reflectionClass; }
php
public function getClass($class) { $cacheKey = self::CACHE_KEY_CLASSES . strtolower($class); if (! $reflectionClass = $this->cache->fetch($cacheKey)) { $reflectionClass = new ReflectionClass($class); $this->cache->store($cacheKey, $reflectionClass); } return $reflectionClass; }
[ "public", "function", "getClass", "(", "$", "class", ")", "{", "$", "cacheKey", "=", "self", "::", "CACHE_KEY_CLASSES", ".", "strtolower", "(", "$", "class", ")", ";", "if", "(", "!", "$", "reflectionClass", "=", "$", "this", "->", "cache", "->", "fetc...
Retrieves ReflectionClass instances, caching them for future retrieval. @since 0.3.0 @param string $class Class name to retrieve the ReflectionClass from. @return ReflectionClass ReflectionClass object for the specified class.
[ "Retrieves", "ReflectionClass", "instances", "caching", "them", "for", "future", "retrieval", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/CachingReflector.php#L55-L65
train
brightnucleus/injector
src/CachingReflector.php
CachingReflector.getConstructorParams
public function getConstructorParams($class) { $cacheKey = self::CACHE_KEY_CTOR_PARAMS . strtolower($class); $reflectedConstructorParams = $this->cache->fetch($cacheKey); if (false !== $reflectedConstructorParams) { return $reflectedConstructorParams; } elseif ($reflectedConstructor = $this->getConstructor($class)) { $reflectedConstructorParams = $reflectedConstructor->getParameters(); } else { $reflectedConstructorParams = null; } $this->cache->store($cacheKey, $reflectedConstructorParams); return $reflectedConstructorParams; }
php
public function getConstructorParams($class) { $cacheKey = self::CACHE_KEY_CTOR_PARAMS . strtolower($class); $reflectedConstructorParams = $this->cache->fetch($cacheKey); if (false !== $reflectedConstructorParams) { return $reflectedConstructorParams; } elseif ($reflectedConstructor = $this->getConstructor($class)) { $reflectedConstructorParams = $reflectedConstructor->getParameters(); } else { $reflectedConstructorParams = null; } $this->cache->store($cacheKey, $reflectedConstructorParams); return $reflectedConstructorParams; }
[ "public", "function", "getConstructorParams", "(", "$", "class", ")", "{", "$", "cacheKey", "=", "self", "::", "CACHE_KEY_CTOR_PARAMS", ".", "strtolower", "(", "$", "class", ")", ";", "$", "reflectedConstructorParams", "=", "$", "this", "->", "cache", "->", ...
Retrieves and caches an array of constructor parameters for the given class. @since 0.3.0 @param string $class Class name to retrieve the constructor arguments from. @return ReflectionParameter[] Array of ReflectionParameter objects for the given class' constructor.
[ "Retrieves", "and", "caches", "an", "array", "of", "constructor", "parameters", "for", "the", "given", "class", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/CachingReflector.php#L100-L117
train
brightnucleus/injector
src/CachingReflector.php
CachingReflector.getFunction
public function getFunction($functionName) { $lowFunc = strtolower($functionName); $cacheKey = self::CACHE_KEY_FUNCS . $lowFunc; $reflectedFunc = $this->cache->fetch($cacheKey); if (false === $reflectedFunc) { $reflectedFunc = new ReflectionFunction($functionName); $this->cache->store($cacheKey, $reflectedFunc); } return $reflectedFunc; }
php
public function getFunction($functionName) { $lowFunc = strtolower($functionName); $cacheKey = self::CACHE_KEY_FUNCS . $lowFunc; $reflectedFunc = $this->cache->fetch($cacheKey); if (false === $reflectedFunc) { $reflectedFunc = new ReflectionFunction($functionName); $this->cache->store($cacheKey, $reflectedFunc); } return $reflectedFunc; }
[ "public", "function", "getFunction", "(", "$", "functionName", ")", "{", "$", "lowFunc", "=", "strtolower", "(", "$", "functionName", ")", ";", "$", "cacheKey", "=", "self", "::", "CACHE_KEY_FUNCS", ".", "$", "lowFunc", ";", "$", "reflectedFunc", "=", "$",...
Retrieves and caches a reflection for the specified function. @since 0.3.0 @param string $functionName Name of the function to get a reflection for. @return ReflectionFunction ReflectionFunction object for the specified function.
[ "Retrieves", "and", "caches", "a", "reflection", "for", "the", "specified", "function", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/CachingReflector.php#L176-L189
train
brightnucleus/injector
src/CachingReflector.php
CachingReflector.getMethod
public function getMethod($classNameOrInstance, $methodName) { $className = is_string($classNameOrInstance) ? $classNameOrInstance : get_class($classNameOrInstance); $cacheKey = self::CACHE_KEY_METHODS . strtolower($className) . '.' . strtolower($methodName); if (! $reflectedMethod = $this->cache->fetch($cacheKey)) { $reflectedMethod = new ReflectionMethod($className, $methodName); $this->cache->store($cacheKey, $reflectedMethod); } return $reflectedMethod; }
php
public function getMethod($classNameOrInstance, $methodName) { $className = is_string($classNameOrInstance) ? $classNameOrInstance : get_class($classNameOrInstance); $cacheKey = self::CACHE_KEY_METHODS . strtolower($className) . '.' . strtolower($methodName); if (! $reflectedMethod = $this->cache->fetch($cacheKey)) { $reflectedMethod = new ReflectionMethod($className, $methodName); $this->cache->store($cacheKey, $reflectedMethod); } return $reflectedMethod; }
[ "public", "function", "getMethod", "(", "$", "classNameOrInstance", ",", "$", "methodName", ")", "{", "$", "className", "=", "is_string", "(", "$", "classNameOrInstance", ")", "?", "$", "classNameOrInstance", ":", "get_class", "(", "$", "classNameOrInstance", ")...
Retrieves and caches a reflection for the specified class method. @since 0.3.0 @param string|object $classNameOrInstance Class name or instance the method is referring to. @param string $methodName Name of the method to get the reflection for. @return ReflectionMethod ReflectionMethod object for the specified method.
[ "Retrieves", "and", "caches", "a", "reflection", "for", "the", "specified", "class", "method", "." ]
e1de664630bb48edadad55e8f8ff307dfaf8f140
https://github.com/brightnucleus/injector/blob/e1de664630bb48edadad55e8f8ff307dfaf8f140/src/CachingReflector.php#L201-L215
train
MatthewPattell/yii2-services
src/ImplementServices.php
ImplementServices.getServiceConfig
private function getServiceConfig(string $name) { $config = $this->services()[$name] ?? null; if ($config === null) { return null; } if (\is_string($config)) { return [ 'class' => $config, ]; } if (\is_array($config) && array_key_exists('class', $config)) { return $config; } throw new InvalidConfigException('Config must be either type of string (class name) or array (with `class` element'); }
php
private function getServiceConfig(string $name) { $config = $this->services()[$name] ?? null; if ($config === null) { return null; } if (\is_string($config)) { return [ 'class' => $config, ]; } if (\is_array($config) && array_key_exists('class', $config)) { return $config; } throw new InvalidConfigException('Config must be either type of string (class name) or array (with `class` element'); }
[ "private", "function", "getServiceConfig", "(", "string", "$", "name", ")", "{", "$", "config", "=", "$", "this", "->", "services", "(", ")", "[", "$", "name", "]", "??", "null", ";", "if", "(", "$", "config", "===", "null", ")", "{", "return", "nu...
Get service class name @param string $name @return array|string|NULL @throws InvalidConfigException
[ "Get", "service", "class", "name" ]
f4ef27456b284b751a849cb0c8e8a04bf73582fd
https://github.com/MatthewPattell/yii2-services/blob/f4ef27456b284b751a849cb0c8e8a04bf73582fd/src/ImplementServices.php#L212-L229
train
reliv/Rcm
admin/src/Controller/ApiAdminManageSitesController.php
ApiAdminManageSitesController.create
public function create($data) { /* ACCESS CHECK */ if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) { $this->getResponse()->setStatusCode(Response::STATUS_CODE_401); return $this->getResponse(); } /* */ $inputFilter = new SiteInputFilter(); $inputFilter->setData($data); if (!$inputFilter->isValid()) { return new ApiJsonModel( [], 1, 'Some values are missing or invalid.', $inputFilter->getMessages() ); } $data = $inputFilter->getValues(); $siteManager = $this->getSiteManager(); $userId = $this->getCurrentUserId(); $data = $siteManager->prepareSiteData($data); /** @var \Rcm\Repository\Domain $domainRepo */ $domainRepo = $this->getEntityManager()->getRepository( \Rcm\Entity\Domain::class ); $data['domain'] = $domainRepo->createDomain( $data['domainName'], $userId, 'Create new domain in ' . get_class($this) ); /** @var \Rcm\Entity\Site $newSite */ $newSite = new Site( $userId, 'Create new site in ' . get_class($this) ); $newSite->populate($data); // make sure we don't have a siteId $newSite->setSiteId(null); $newSite = $siteManager->createSite($newSite); return new ApiJsonModel($newSite, 0, 'Success'); }
php
public function create($data) { /* ACCESS CHECK */ if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) { $this->getResponse()->setStatusCode(Response::STATUS_CODE_401); return $this->getResponse(); } /* */ $inputFilter = new SiteInputFilter(); $inputFilter->setData($data); if (!$inputFilter->isValid()) { return new ApiJsonModel( [], 1, 'Some values are missing or invalid.', $inputFilter->getMessages() ); } $data = $inputFilter->getValues(); $siteManager = $this->getSiteManager(); $userId = $this->getCurrentUserId(); $data = $siteManager->prepareSiteData($data); /** @var \Rcm\Repository\Domain $domainRepo */ $domainRepo = $this->getEntityManager()->getRepository( \Rcm\Entity\Domain::class ); $data['domain'] = $domainRepo->createDomain( $data['domainName'], $userId, 'Create new domain in ' . get_class($this) ); /** @var \Rcm\Entity\Site $newSite */ $newSite = new Site( $userId, 'Create new site in ' . get_class($this) ); $newSite->populate($data); // make sure we don't have a siteId $newSite->setSiteId(null); $newSite = $siteManager->createSite($newSite); return new ApiJsonModel($newSite, 0, 'Success'); }
[ "public", "function", "create", "(", "$", "data", ")", "{", "/* ACCESS CHECK */", "if", "(", "!", "$", "this", "->", "isAllowed", "(", "ResourceName", "::", "RESOURCE_SITES", ",", "'admin'", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->"...
create - Create a site @param array $data @return mixed|JsonModel
[ "create", "-", "Create", "a", "site" ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Controller/ApiAdminManageSitesController.php#L322-L374
train
webeweb/core-bundle
Helper/PhantomJSHelper.php
PhantomJSHelper.getCommand
public function getCommand() { // Initialize the command. $command = $this->getBinaryPath(); $command .= true === OSHelper::isWindows() ? ".exe" : ""; // Return the command. return realpath($command); }
php
public function getCommand() { // Initialize the command. $command = $this->getBinaryPath(); $command .= true === OSHelper::isWindows() ? ".exe" : ""; // Return the command. return realpath($command); }
[ "public", "function", "getCommand", "(", ")", "{", "// Initialize the command.", "$", "command", "=", "$", "this", "->", "getBinaryPath", "(", ")", ";", "$", "command", ".=", "true", "===", "OSHelper", "::", "isWindows", "(", ")", "?", "\".exe\"", ":", "\"...
Get the command. @return string Returns the command.
[ "Get", "the", "command", "." ]
2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5
https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Helper/PhantomJSHelper.php#L77-L85
train
XcoreCMS/InlineEditing
src/Model/Simple/ContentProvider.php
ContentProvider.getContent
public function getContent(string $namespace, string $locale, string $name): string { $nKey = self::getNKey($namespace, $locale); // L1 read $content = $this->loadedData[$nKey][$name] ?? false; if (is_string($content)) { // L1 hit return $content; } // L2 read + L1 write $this->loadedData[$nKey] = $this->loadedData[$nKey] ?? $this->loadNspaceFromCache($namespace, $locale); $fallbackLocale = $this->config['fallback'] ?? ''; $content = $this->loadedData[$nKey][$name] ?? false; if (is_string($content)) { return $content; } if ($fallbackLocale === false || $locale === $fallbackLocale) { return ''; } return $this->getContent($namespace, $fallbackLocale, $name); }
php
public function getContent(string $namespace, string $locale, string $name): string { $nKey = self::getNKey($namespace, $locale); // L1 read $content = $this->loadedData[$nKey][$name] ?? false; if (is_string($content)) { // L1 hit return $content; } // L2 read + L1 write $this->loadedData[$nKey] = $this->loadedData[$nKey] ?? $this->loadNspaceFromCache($namespace, $locale); $fallbackLocale = $this->config['fallback'] ?? ''; $content = $this->loadedData[$nKey][$name] ?? false; if (is_string($content)) { return $content; } if ($fallbackLocale === false || $locale === $fallbackLocale) { return ''; } return $this->getContent($namespace, $fallbackLocale, $name); }
[ "public", "function", "getContent", "(", "string", "$", "namespace", ",", "string", "$", "locale", ",", "string", "$", "name", ")", ":", "string", "{", "$", "nKey", "=", "self", "::", "getNKey", "(", "$", "namespace", ",", "$", "locale", ")", ";", "/...
L1 - PHP ARRAY LAYER @param string $namespace @param string $locale @param string $name @return string
[ "L1", "-", "PHP", "ARRAY", "LAYER" ]
5389cfafcc1a039022797516f8cb0fbf7c422558
https://github.com/XcoreCMS/InlineEditing/blob/5389cfafcc1a039022797516f8cb0fbf7c422558/src/Model/Simple/ContentProvider.php#L77-L104
train
CHECK24/apitk-common-bundle
Util/ControllerReflector.php
ControllerReflector.getReflectionMethod
public function getReflectionMethod(string $controller) { $callable = $this->getClassAndMethod($controller); if (null === $callable) { return null; } list($class, $method) = $callable; try { return new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { // In case we can't reflect the controller, we just // ignore the route } }
php
public function getReflectionMethod(string $controller) { $callable = $this->getClassAndMethod($controller); if (null === $callable) { return null; } list($class, $method) = $callable; try { return new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { // In case we can't reflect the controller, we just // ignore the route } }
[ "public", "function", "getReflectionMethod", "(", "string", "$", "controller", ")", "{", "$", "callable", "=", "$", "this", "->", "getClassAndMethod", "(", "$", "controller", ")", ";", "if", "(", "null", "===", "$", "callable", ")", "{", "return", "null", ...
Returns the ReflectionMethod for the given controller string. @param string $controller @return \ReflectionMethod|null
[ "Returns", "the", "ReflectionMethod", "for", "the", "given", "controller", "string", "." ]
4b312eaf26f368db77d2e786c1acf144244c0d21
https://github.com/CHECK24/apitk-common-bundle/blob/4b312eaf26f368db77d2e786c1acf144244c0d21/Util/ControllerReflector.php#L27-L42
train
brightnucleus/dependencies
src/AbstractDependencyHandler.php
AbstractDependencyHandler.maybe_enqueue
public function maybe_enqueue( $handle ) { if ( $this->is_registered( $handle ) ) { $enqueue = $this->get_enqueue_function(); $enqueue( $handle ); return true; } return false; }
php
public function maybe_enqueue( $handle ) { if ( $this->is_registered( $handle ) ) { $enqueue = $this->get_enqueue_function(); $enqueue( $handle ); return true; } return false; }
[ "public", "function", "maybe_enqueue", "(", "$", "handle", ")", "{", "if", "(", "$", "this", "->", "is_registered", "(", "$", "handle", ")", ")", "{", "$", "enqueue", "=", "$", "this", "->", "get_enqueue_function", "(", ")", ";", "$", "enqueue", "(", ...
Maybe enqueue a dependency that has been registered outside of the Dependency Manager. @since 0.2.3 @param string $handle Handle of the dependency to enqueue. @return bool Whether the handle was found or not.
[ "Maybe", "enqueue", "a", "dependency", "that", "has", "been", "registered", "outside", "of", "the", "Dependency", "Manager", "." ]
b51ba30c32d98817b34ca710382a633bb4138a7b
https://github.com/brightnucleus/dependencies/blob/b51ba30c32d98817b34ca710382a633bb4138a7b/src/AbstractDependencyHandler.php#L83-L90
train
php-kitchen/yii2-di
src/ClassFactory.php
ClassFactory.createWithConstructorParams
public function createWithConstructorParams(array $params, $config = []) { $definition = $this->prepareObjectDefinitionFromConfig($config); return $this->getContainer()->create($definition, $params); }
php
public function createWithConstructorParams(array $params, $config = []) { $definition = $this->prepareObjectDefinitionFromConfig($config); return $this->getContainer()->create($definition, $params); }
[ "public", "function", "createWithConstructorParams", "(", "array", "$", "params", ",", "$", "config", "=", "[", "]", ")", "{", "$", "definition", "=", "$", "this", "->", "prepareObjectDefinitionFromConfig", "(", "$", "config", ")", ";", "return", "$", "this"...
Creates a new object with specified constructor parameters using the given or default configuration. @param array $params the constructor parameters @param array $config a configuration array of the name-value pairs that will be used to initialize the corresponding object properties @return object the created object @throws \yii\base\InvalidConfigException if the configuration is invalid. @see \PHPKitchen\DI\Container
[ "Creates", "a", "new", "object", "with", "specified", "constructor", "parameters", "using", "the", "given", "or", "default", "configuration", "." ]
303a43e4cf16dad576e1d7eea5faeacb9977faca
https://github.com/php-kitchen/yii2-di/blob/303a43e4cf16dad576e1d7eea5faeacb9977faca/src/ClassFactory.php#L91-L95
train
reliv/Rcm
core/src/Service/LayoutManager.php
LayoutManager.getThemesConfig
public function getThemesConfig() { if (empty($this->config['Rcm']) || empty($this->config['Rcm']['themes']) ) { throw new RuntimeException( 'No Themes found defined in configuration. Please report the issue with the themes author.' ); } return $this->config['Rcm']['themes']; }
php
public function getThemesConfig() { if (empty($this->config['Rcm']) || empty($this->config['Rcm']['themes']) ) { throw new RuntimeException( 'No Themes found defined in configuration. Please report the issue with the themes author.' ); } return $this->config['Rcm']['themes']; }
[ "public", "function", "getThemesConfig", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "config", "[", "'Rcm'", "]", ")", "||", "empty", "(", "$", "this", "->", "config", "[", "'Rcm'", "]", "[", "'themes'", "]", ")", ")", "{", "throw", ...
Get the installed RCM Themes configuration. @return array @throws \Rcm\Exception\RuntimeException
[ "Get", "the", "installed", "RCM", "Themes", "configuration", "." ]
18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb
https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L50-L62
train