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
calgamo/filesystem
src/File.php
File.makeDirectory
public function makeDirectory( $mode = NULL ) { $mode = $mode ? $mode : 0777; if ( file_exists($this->path) ){ if ( is_file($this->path) ){ throw new MakeDirectoryException($this); } return; } $parent_dir = $this->getParent(); if ( !$parent_dir->exists() ){ $parent_dir->makeDirectory( $mode ); } $res = @mkdir( $this->path, $mode ); if ( $res === FALSE ){ throw new MakeDirectoryException($this); } }
php
public function makeDirectory( $mode = NULL ) { $mode = $mode ? $mode : 0777; if ( file_exists($this->path) ){ if ( is_file($this->path) ){ throw new MakeDirectoryException($this); } return; } $parent_dir = $this->getParent(); if ( !$parent_dir->exists() ){ $parent_dir->makeDirectory( $mode ); } $res = @mkdir( $this->path, $mode ); if ( $res === FALSE ){ throw new MakeDirectoryException($this); } }
[ "public", "function", "makeDirectory", "(", "$", "mode", "=", "NULL", ")", "{", "$", "mode", "=", "$", "mode", "?", "$", "mode", ":", "0777", ";", "if", "(", "file_exists", "(", "$", "this", "->", "path", ")", ")", "{", "if", "(", "is_file", "(",...
Create empty directory @param string $mode File mode.If this parameter is set NULL, 0777 will be applied. @return void @throws MakeDirectoryException
[ "Create", "empty", "directory" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L397-L418
train
calgamo/filesystem
src/File.php
File.listFiles
public function listFiles( $filter = NULL ) : array { $path = $this->path; if ( !file_exists($path) ) return NULL; if ( !is_readable($path) ) return NULL; if ( is_file($path) ) return NULL; $files = array(); $dh = opendir($path); while( ($file_name = readdir($dh)) !== FALSE ){ if ( $file_name === '.' || $file_name === '..' ){ continue; } $file = new File( $file_name, $this ); if ( $filter ){ if ( $filter instanceof FileFilterInterface ){ if ( $filter->accept($file) ){ $files[] = $file; } } else if ( is_callable($filter) ){ if ( $filter($file) ){ $files[] = $file; } } } else{ $files[] = $file; } } return $files; }
php
public function listFiles( $filter = NULL ) : array { $path = $this->path; if ( !file_exists($path) ) return NULL; if ( !is_readable($path) ) return NULL; if ( is_file($path) ) return NULL; $files = array(); $dh = opendir($path); while( ($file_name = readdir($dh)) !== FALSE ){ if ( $file_name === '.' || $file_name === '..' ){ continue; } $file = new File( $file_name, $this ); if ( $filter ){ if ( $filter instanceof FileFilterInterface ){ if ( $filter->accept($file) ){ $files[] = $file; } } else if ( is_callable($filter) ){ if ( $filter($file) ){ $files[] = $file; } } } else{ $files[] = $file; } } return $files; }
[ "public", "function", "listFiles", "(", "$", "filter", "=", "NULL", ")", ":", "array", "{", "$", "path", "=", "$", "this", "->", "path", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "return", "NULL", ";", "if", "(", "!", "is_re...
Listing up files in directory which this object means @param FileFilterInterface|callable $filter Fileter object which implements selection logic. If this parameter is omitted, all files will be selected. @return File[]
[ "Listing", "up", "files", "in", "directory", "which", "this", "object", "means" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L427-L462
train
calgamo/filesystem
src/File.php
File.touch
public function touch( $time = NULL ) : bool { if ( $time === NULL ){ return touch( $this->path ); } return touch( $this->path, $time ); }
php
public function touch( $time = NULL ) : bool { if ( $time === NULL ){ return touch( $this->path ); } return touch( $this->path, $time ); }
[ "public", "function", "touch", "(", "$", "time", "=", "NULL", ")", ":", "bool", "{", "if", "(", "$", "time", "===", "NULL", ")", "{", "return", "touch", "(", "$", "this", "->", "path", ")", ";", "}", "return", "touch", "(", "$", "this", "->", "...
Update last modified date of the file @param int|Integer $time time value to set @return bool
[ "Update", "last", "modified", "date", "of", "the", "file" ]
35b0f1286197f1566cdad3bca07fc41fb88edbf1
https://github.com/calgamo/filesystem/blob/35b0f1286197f1566cdad3bca07fc41fb88edbf1/src/File.php#L472-L478
train
tenside/core-bundle
src/Security/PermissionVoter.php
PermissionVoter.supportsAnyAttribute
private function supportsAnyAttribute($attributes) { foreach ($attributes as $attribute) { if ($this->supportsAttribute($attribute)) { return true; } } return false; }
php
private function supportsAnyAttribute($attributes) { foreach ($attributes as $attribute) { if ($this->supportsAttribute($attribute)) { return true; } } return false; }
[ "private", "function", "supportsAnyAttribute", "(", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "supportsAttribute", "(", "$", "attribute", ")", ")", "{", "return", "true",...
Test if we support any of the attributes. @param string[] $attributes The attributes to test. @return bool
[ "Test", "if", "we", "support", "any", "of", "the", "attributes", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Security/PermissionVoter.php#L151-L160
train
tenside/core-bundle
src/Security/PermissionVoter.php
PermissionVoter.getRouteRoles
private function getRouteRoles() { $router = $this->router; $cache = $this->getConfigCacheFactory()->cache( $this->options['cache_dir'].'/tenside_roles.php', function (ConfigCacheInterface $cache) use ($router) { $routes = $router->getRouteCollection(); $roles = []; foreach ($routes as $name => $route) { if ($requiredRole = $route->getOption('required_role')) { $roles[$name] = $requiredRole; } } $cache->write('<?php return ' . var_export($roles, true) . ';', $routes->getResources()); } ); return require_once $cache->getPath(); }
php
private function getRouteRoles() { $router = $this->router; $cache = $this->getConfigCacheFactory()->cache( $this->options['cache_dir'].'/tenside_roles.php', function (ConfigCacheInterface $cache) use ($router) { $routes = $router->getRouteCollection(); $roles = []; foreach ($routes as $name => $route) { if ($requiredRole = $route->getOption('required_role')) { $roles[$name] = $requiredRole; } } $cache->write('<?php return ' . var_export($roles, true) . ';', $routes->getResources()); } ); return require_once $cache->getPath(); }
[ "private", "function", "getRouteRoles", "(", ")", "{", "$", "router", "=", "$", "this", "->", "router", ";", "$", "cache", "=", "$", "this", "->", "getConfigCacheFactory", "(", ")", "->", "cache", "(", "$", "this", "->", "options", "[", "'cache_dir'", ...
Get the required roles from cache if possible. @return array
[ "Get", "the", "required", "roles", "from", "cache", "if", "possible", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Security/PermissionVoter.php#L181-L201
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Raw.php
Raw.createNew
public function createNew( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPost( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
php
public function createNew( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPost( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
[ "public", "function", "createNew", "(", "int", "$", "sourceId", ",", "string", "$", "collectionName", ",", "array", "$", "data", ")", ":", "array", "{", "return", "$", "this", "->", "sendPost", "(", "sprintf", "(", "'/profiles/%s/raw'", ",", "$", "this", ...
Creates a new raw data for the given source. @param int $sourceId @param string $collectionName @param array $data @return array Response
[ "Creates", "a", "new", "raw", "data", "for", "the", "given", "source", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Raw.php#L20-L34
train
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Raw.php
Raw.upsertOne
public function upsertOne( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPut( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
php
public function upsertOne( int $sourceId, string $collectionName, array $data ) : array { return $this->sendPut( sprintf('/profiles/%s/raw', $this->userName), [], [ 'source_id' => $sourceId, 'collection' => $collectionName, 'data' => $data ] ); }
[ "public", "function", "upsertOne", "(", "int", "$", "sourceId", ",", "string", "$", "collectionName", ",", "array", "$", "data", ")", ":", "array", "{", "return", "$", "this", "->", "sendPut", "(", "sprintf", "(", "'/profiles/%s/raw'", ",", "$", "this", ...
Tries to update a raw data and if it doesnt exists, creates a new raw data. @param int $sourceId @param string $collectionName @param array $data @return array Response
[ "Tries", "to", "update", "a", "raw", "data", "and", "if", "it", "doesnt", "exists", "creates", "a", "new", "raw", "data", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Raw.php#L45-L59
train
score-ya/cinderella-sdk
src/Common/ClientBuilder.php
ClientBuilder.get
public function get($name, $throwAway = false) { $client = parent::get($name, $throwAway); if ($client instanceof ApiKeyClientInterface) { $client->setApiKey(self::$apiKey); } return $client; }
php
public function get($name, $throwAway = false) { $client = parent::get($name, $throwAway); if ($client instanceof ApiKeyClientInterface) { $client->setApiKey(self::$apiKey); } return $client; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "throwAway", "=", "false", ")", "{", "$", "client", "=", "parent", "::", "get", "(", "$", "name", ",", "$", "throwAway", ")", ";", "if", "(", "$", "client", "instanceof", "ApiKeyClientInterface",...
set the api key for api key clients @param string $name @param bool $throwAway @return ClientInterface
[ "set", "the", "api", "key", "for", "api", "key", "clients" ]
bed7371cb1caeefd1efcb09306c10d8805270e17
https://github.com/score-ya/cinderella-sdk/blob/bed7371cb1caeefd1efcb09306c10d8805270e17/src/Common/ClientBuilder.php#L40-L49
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.showAction
public function showAction(ProductItemFieldData $productitemfielddata) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction(ProductItemFieldData $productitemfielddata) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "ProductItemFieldData", "$", "productitemfielddata", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"", ")", ",", "$", "produ...
Finds and displays a ProductItemFieldData entity. @Route("/{id}/show", name="admin_productitemfielddata_show", requirements={"id"="\d+"}) @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L47-L61
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.newAction
public function newAction() { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
php
public function newAction() { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "productitemfielddata", "=", "new", "ProductItemFieldData", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.field.data\"...
Displays a form to create a new ProductItemFieldData entity. @Route("/new", name="admin_productitemfielddata_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L70-L79
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.createAction
public function createAction(Request $request) { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($productitemfielddata); $em->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $productitemfielddata = new ProductItemFieldData(); $form = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($productitemfielddata); $em->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } return array( 'productitemfielddata' => $productitemfielddata, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "productitemfielddata", "=", "new", "ProductItemFieldData", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen...
Creates a new ProductItemFieldData entity. @Route("/create", name="admin_productitemfielddata_create") @Method("POST") @Template("AmulenShopBundle:ProductItemFieldData:new.html.twig")
[ "Creates", "a", "new", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L88-L104
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php
AdminProductItemFieldDataController.updateAction
public function updateAction(ProductItemFieldData $productitemfielddata, Request $request) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(ProductItemFieldData $productitemfielddata, Request $request) { $editForm = $this->createForm($this->get("amulen.shop.form.product.item.field.data"), $productitemfielddata, array( 'action' => $this->generateUrl('admin_productitemfielddata_update', array('id' => $productitemfielddata->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('admin_productitemfielddata_show', array('id' => $productitemfielddata->getId()))); } $deleteForm = $this->createDeleteForm($productitemfielddata->getId(), 'admin_productitemfielddata_delete'); return array( 'productitemfielddata' => $productitemfielddata, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "ProductItemFieldData", "$", "productitemfielddata", ",", "Request", "$", "request", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "\"amulen.shop.form.product.item.fi...
Edits an existing ProductItemFieldData entity. @Route("/{id}/update", name="admin_productitemfielddata_update", requirements={"id"="\d+"}) @Method("PUT") @Template("AmulenShopBundle:ProductItemFieldData:edit.html.twig")
[ "Edits", "an", "existing", "ProductItemFieldData", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductItemFieldDataController.php#L113-L131
train
oaugustus/direct-silex-provider
src/Direct/Router.php
Router.route
public function route() { $batch = array(); foreach ($this->request->getCalls() as $call) { $batch[] = $this->dispatch($call); } return $this->response->encode($batch); }
php
public function route() { $batch = array(); foreach ($this->request->getCalls() as $call) { $batch[] = $this->dispatch($call); } return $this->response->encode($batch); }
[ "public", "function", "route", "(", ")", "{", "$", "batch", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "request", "->", "getCalls", "(", ")", "as", "$", "call", ")", "{", "$", "batch", "[", "]", "=", "$", "this", "->", "dis...
Do the ExtDirect routing processing. @return JSON
[ "Do", "the", "ExtDirect", "routing", "processing", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router.php#L56-L65
train
oaugustus/direct-silex-provider
src/Direct/Router.php
Router.dispatch
private function dispatch($call) { $path = $call->getAction(); $method = $call->getMethod(); $matches = preg_split('/(?=[A-Z])/',$path); $route = strtolower(implode('/', $matches)); $route .= "/".$method; $request = $this->app['request']; $files = $this->fixFiles($request->files->all()); // create the route request $routeRequest = Request::create($route, 'POST', $call->getData(), $request->cookies->all(), $files, $request->server->all()); if ('form' == $this->request->getCallType()) { $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); } else { try{ $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); }catch(\Exception $e){ $response = $call->getException($e); } } return $response; }
php
private function dispatch($call) { $path = $call->getAction(); $method = $call->getMethod(); $matches = preg_split('/(?=[A-Z])/',$path); $route = strtolower(implode('/', $matches)); $route .= "/".$method; $request = $this->app['request']; $files = $this->fixFiles($request->files->all()); // create the route request $routeRequest = Request::create($route, 'POST', $call->getData(), $request->cookies->all(), $files, $request->server->all()); if ('form' == $this->request->getCallType()) { $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); } else { try{ $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST); $response = $call->getResponse($result); }catch(\Exception $e){ $response = $call->getException($e); } } return $response; }
[ "private", "function", "dispatch", "(", "$", "call", ")", "{", "$", "path", "=", "$", "call", "->", "getAction", "(", ")", ";", "$", "method", "=", "$", "call", "->", "getMethod", "(", ")", ";", "$", "matches", "=", "preg_split", "(", "'/(?=[A-Z])/'"...
Dispatch a remote method call. @param \Direct\Router\Call $call @return Mixed
[ "Dispatch", "a", "remote", "method", "call", "." ]
8d92afdf5ede04c3048cde82b9879de7e1d6c153
https://github.com/oaugustus/direct-silex-provider/blob/8d92afdf5ede04c3048cde82b9879de7e1d6c153/src/Direct/Router.php#L73-L105
train
bishopb/vanilla
library/core/class.session.php
Gdn_Session.CheckPermission
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') { if (is_object($this->User)) { if ($this->User->Banned || GetValue('Deleted', $this->User)) return FALSE; elseif ($this->User->Admin) return TRUE; } // Allow wildcard permission checks (e.g. 'any' Category) if ($JunctionID == 'any') $JunctionID = ''; $Permissions = $this->GetPermissions(); if ($JunctionTable && !C('Garden.Permissions.Disabled.'.$JunctionTable)) { // Junction permission ($Permissions[PermissionName] = array(JunctionIDs)) if (is_array($Permission)) { foreach ($Permission as $PermissionName) { if($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) { if(!$FullMatch) return TRUE; } else { if($FullMatch) return FALSE; } } return TRUE; } else { if ($JunctionID !== '') { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]); } else { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && count($Permissions[$Permission]); } return $Result; } } else { // Non-junction permission ($Permissions = array(PermissionNames)) if (is_array($Permission)) { return ArrayInArray($Permission, $Permissions, $FullMatch); } else { return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions); } } }
php
public function CheckPermission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '') { if (is_object($this->User)) { if ($this->User->Banned || GetValue('Deleted', $this->User)) return FALSE; elseif ($this->User->Admin) return TRUE; } // Allow wildcard permission checks (e.g. 'any' Category) if ($JunctionID == 'any') $JunctionID = ''; $Permissions = $this->GetPermissions(); if ($JunctionTable && !C('Garden.Permissions.Disabled.'.$JunctionTable)) { // Junction permission ($Permissions[PermissionName] = array(JunctionIDs)) if (is_array($Permission)) { foreach ($Permission as $PermissionName) { if($this->CheckPermission($PermissionName, FALSE, $JunctionTable, $JunctionID)) { if(!$FullMatch) return TRUE; } else { if($FullMatch) return FALSE; } } return TRUE; } else { if ($JunctionID !== '') { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && in_array($JunctionID, $Permissions[$Permission]); } else { $Result = array_key_exists($Permission, $Permissions) && is_array($Permissions[$Permission]) && count($Permissions[$Permission]); } return $Result; } } else { // Non-junction permission ($Permissions = array(PermissionNames)) if (is_array($Permission)) { return ArrayInArray($Permission, $Permissions, $FullMatch); } else { return in_array($Permission, $Permissions) || array_key_exists($Permission, $Permissions); } } }
[ "public", "function", "CheckPermission", "(", "$", "Permission", ",", "$", "FullMatch", "=", "TRUE", ",", "$", "JunctionTable", "=", "''", ",", "$", "JunctionID", "=", "''", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "User", ")", ")", ...
Checks the currently authenticated user's permissions for the specified permission. Returns a boolean value indicating if the action is permitted. @param mixed $Permission The permission (or array of permissions) to check. @param int $JunctionID The JunctionID associated with $Permission (ie. A discussion category identifier). @param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions. @param string $JunctionTable The name of the junction table for a junction permission. @param in $JunctionID The ID of the junction permission. * @return boolean
[ "Checks", "the", "currently", "authenticated", "user", "s", "permissions", "for", "the", "specified", "permission", ".", "Returns", "a", "boolean", "value", "indicating", "if", "the", "action", "is", "permitted", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L91-L137
train
bishopb/vanilla
library/core/class.session.php
Gdn_Session.End
public function End($Authenticator = NULL) { if ($Authenticator == NULL) $Authenticator = Gdn::Authenticator(); $Authenticator->AuthenticateWith()->DeAuthenticate(); $this->SetCookie('-Vv', NULL, -3600); $this->UserID = 0; $this->User = FALSE; $this->_Attributes = array(); $this->_Permissions = array(); $this->_Preferences = array(); $this->_TransientKey = FALSE; }
php
public function End($Authenticator = NULL) { if ($Authenticator == NULL) $Authenticator = Gdn::Authenticator(); $Authenticator->AuthenticateWith()->DeAuthenticate(); $this->SetCookie('-Vv', NULL, -3600); $this->UserID = 0; $this->User = FALSE; $this->_Attributes = array(); $this->_Permissions = array(); $this->_Preferences = array(); $this->_TransientKey = FALSE; }
[ "public", "function", "End", "(", "$", "Authenticator", "=", "NULL", ")", "{", "if", "(", "$", "Authenticator", "==", "NULL", ")", "$", "Authenticator", "=", "Gdn", "::", "Authenticator", "(", ")", ";", "$", "Authenticator", "->", "AuthenticateWith", "(", ...
End a session @param Gdn_Authenticator $Authenticator
[ "End", "a", "session" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L144-L157
train
bishopb/vanilla
library/core/class.session.php
Gdn_Session.HourOffset
public function HourOffset() { static $GuestHourOffset; if ($this->UserID > 0) { return $this->User->HourOffset; } else { if (!isset($GuestHourOffset)) { $GuestTimeZone = C('Garden.GuestTimeZone'); if ($GuestTimeZone) { try { $TimeZone = new DateTimeZone($GuestTimeZone); $Offset = $TimeZone->getOffset(new DateTime('now', new DateTimeZone('UTC'))); $GuestHourOffset = floor($Offset / 3600); } catch (Exception $Ex) { $GuestHourOffset = 0; LogException($Ex); } } } return $GuestHourOffset; } }
php
public function HourOffset() { static $GuestHourOffset; if ($this->UserID > 0) { return $this->User->HourOffset; } else { if (!isset($GuestHourOffset)) { $GuestTimeZone = C('Garden.GuestTimeZone'); if ($GuestTimeZone) { try { $TimeZone = new DateTimeZone($GuestTimeZone); $Offset = $TimeZone->getOffset(new DateTime('now', new DateTimeZone('UTC'))); $GuestHourOffset = floor($Offset / 3600); } catch (Exception $Ex) { $GuestHourOffset = 0; LogException($Ex); } } } return $GuestHourOffset; } }
[ "public", "function", "HourOffset", "(", ")", "{", "static", "$", "GuestHourOffset", ";", "if", "(", "$", "this", "->", "UserID", ">", "0", ")", "{", "return", "$", "this", "->", "User", "->", "HourOffset", ";", "}", "else", "{", "if", "(", "!", "i...
Return the timezone hour difference between the user and utc. @return int The hour offset.
[ "Return", "the", "timezone", "hour", "difference", "between", "the", "user", "and", "utc", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L177-L199
train
bishopb/vanilla
library/core/class.session.php
Gdn_Session.Start
public function Start($UserID = FALSE, $SetIdentity = TRUE, $Persist = FALSE) { if (!C('Garden.Installed', FALSE)) return; // Retrieve the authenticated UserID from the Authenticator module. $UserModel = Gdn::Authenticator()->GetUserModel(); $this->UserID = $UserID !== FALSE ? $UserID : Gdn::Authenticator()->GetIdentity(); $this->User = FALSE; // Now retrieve user information if ($this->UserID > 0) { // Instantiate a UserModel to get session info $this->User = $UserModel->GetSession($this->UserID); if ($this->User) { if ($SetIdentity) Gdn::Authenticator()->SetIdentity($this->UserID, $Persist); $UserModel->EventArguments['User'] =& $this->User; $UserModel->FireEvent('AfterGetSession'); $this->_Permissions = Gdn_Format::Unserialize($this->User->Permissions); $this->_Preferences = Gdn_Format::Unserialize($this->User->Preferences); $this->_Attributes = Gdn_Format::Unserialize($this->User->Attributes); $this->_TransientKey = is_array($this->_Attributes) ? ArrayValue('TransientKey', $this->_Attributes) : FALSE; if ($this->_TransientKey === FALSE) $this->_TransientKey = $UserModel->SetTransientKey($this->UserID); // Save any visit-level information. $UserModel->UpdateVisit($this->UserID); } else { $this->UserID = 0; $this->User = FALSE; if ($SetIdentity) Gdn::Authenticator()->SetIdentity(NULL); } } else { // Grab the transient key from the cookie. This doesn't always get set but we'll try it here anyway. $this->_TransientKey = GetAppCookie('tk'); } // Load guest permissions if necessary if ($this->UserID == 0) $this->_Permissions = Gdn_Format::Unserialize($UserModel->DefinePermissions(0)); }
php
public function Start($UserID = FALSE, $SetIdentity = TRUE, $Persist = FALSE) { if (!C('Garden.Installed', FALSE)) return; // Retrieve the authenticated UserID from the Authenticator module. $UserModel = Gdn::Authenticator()->GetUserModel(); $this->UserID = $UserID !== FALSE ? $UserID : Gdn::Authenticator()->GetIdentity(); $this->User = FALSE; // Now retrieve user information if ($this->UserID > 0) { // Instantiate a UserModel to get session info $this->User = $UserModel->GetSession($this->UserID); if ($this->User) { if ($SetIdentity) Gdn::Authenticator()->SetIdentity($this->UserID, $Persist); $UserModel->EventArguments['User'] =& $this->User; $UserModel->FireEvent('AfterGetSession'); $this->_Permissions = Gdn_Format::Unserialize($this->User->Permissions); $this->_Preferences = Gdn_Format::Unserialize($this->User->Preferences); $this->_Attributes = Gdn_Format::Unserialize($this->User->Attributes); $this->_TransientKey = is_array($this->_Attributes) ? ArrayValue('TransientKey', $this->_Attributes) : FALSE; if ($this->_TransientKey === FALSE) $this->_TransientKey = $UserModel->SetTransientKey($this->UserID); // Save any visit-level information. $UserModel->UpdateVisit($this->UserID); } else { $this->UserID = 0; $this->User = FALSE; if ($SetIdentity) Gdn::Authenticator()->SetIdentity(NULL); } } else { // Grab the transient key from the cookie. This doesn't always get set but we'll try it here anyway. $this->_TransientKey = GetAppCookie('tk'); } // Load guest permissions if necessary if ($this->UserID == 0) $this->_Permissions = Gdn_Format::Unserialize($UserModel->DefinePermissions(0)); }
[ "public", "function", "Start", "(", "$", "UserID", "=", "FALSE", ",", "$", "SetIdentity", "=", "TRUE", ",", "$", "Persist", "=", "FALSE", ")", "{", "if", "(", "!", "C", "(", "'Garden.Installed'", ",", "FALSE", ")", ")", "return", ";", "// Retrieve the ...
Authenticates the user with the provided Authenticator class. @param int $UserID The UserID to start the session with. @param bool $SetIdentity Whether or not to set the identity (cookie) or make this a one request session. @param bool $Persist If setting an identity, should we persist it beyond browser restart?
[ "Authenticates", "the", "user", "with", "the", "provided", "Authenticator", "class", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L343-L386
train
bishopb/vanilla
library/core/class.session.php
Gdn_Session.TransientKey
public function TransientKey($NewKey = NULL) { if (!is_null($NewKey)) { $this->_TransientKey = Gdn::Authenticator()->GetUserModel()->SetTransientKey($this->UserID, $NewKey); } // if ($this->_TransientKey) return $this->_TransientKey; // else // return RandomString(12); // Postbacks will never be authenticated if transientkey is not defined. }
php
public function TransientKey($NewKey = NULL) { if (!is_null($NewKey)) { $this->_TransientKey = Gdn::Authenticator()->GetUserModel()->SetTransientKey($this->UserID, $NewKey); } // if ($this->_TransientKey) return $this->_TransientKey; // else // return RandomString(12); // Postbacks will never be authenticated if transientkey is not defined. }
[ "public", "function", "TransientKey", "(", "$", "NewKey", "=", "NULL", ")", "{", "if", "(", "!", "is_null", "(", "$", "NewKey", ")", ")", "{", "$", "this", "->", "_TransientKey", "=", "Gdn", "::", "Authenticator", "(", ")", "->", "GetUserModel", "(", ...
Returns the transient key for the authenticated user. @return string @todo check return type
[ "Returns", "the", "transient", "key", "for", "the", "authenticated", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.session.php#L446-L455
train
spec-gen/state-workflow-spec-gen-bundle
Domain/IntrospectedWorkflow.php
IntrospectedWorkflow.guessIsIntrospectedStateRootOrLeaf
private function guessIsIntrospectedStateRootOrLeaf() { foreach ($this->introspectedStates as $introspectedState) { $this->guessIsIntrospectedStateRoot($introspectedState); $this->guessIsIntrospectedStateLeaf($introspectedState); } }
php
private function guessIsIntrospectedStateRootOrLeaf() { foreach ($this->introspectedStates as $introspectedState) { $this->guessIsIntrospectedStateRoot($introspectedState); $this->guessIsIntrospectedStateLeaf($introspectedState); } }
[ "private", "function", "guessIsIntrospectedStateRootOrLeaf", "(", ")", "{", "foreach", "(", "$", "this", "->", "introspectedStates", "as", "$", "introspectedState", ")", "{", "$", "this", "->", "guessIsIntrospectedStateRoot", "(", "$", "introspectedState", ")", ";",...
Update introspectedState isLeaf|isRoot on the fly
[ "Update", "introspectedState", "isLeaf|isRoot", "on", "the", "fly" ]
20490717ab28c5f8ff9424ff51898e52283bb2c2
https://github.com/spec-gen/state-workflow-spec-gen-bundle/blob/20490717ab28c5f8ff9424ff51898e52283bb2c2/Domain/IntrospectedWorkflow.php#L188-L194
train
GrupaZero/core
src/Gzero/Core/Policies/OptionPolicy.php
OptionPolicy.update
public function update(User $user, $option, $categoryKey) { if (!empty($option)) { return $user->hasPermission('options-update-' . $categoryKey); } return false; }
php
public function update(User $user, $option, $categoryKey) { if (!empty($option)) { return $user->hasPermission('options-update-' . $categoryKey); } return false; }
[ "public", "function", "update", "(", "User", "$", "user", ",", "$", "option", ",", "$", "categoryKey", ")", "{", "if", "(", "!", "empty", "(", "$", "option", ")", ")", "{", "return", "$", "user", "->", "hasPermission", "(", "'options-update-'", ".", ...
Policy for updating options for specified category @param User $user User trying to do it @param Option $option Option class name @param String $categoryKey option category @return bool
[ "Policy", "for", "updating", "options", "for", "specified", "category" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Policies/OptionPolicy.php#L29-L35
train
weavephp/middleware-middleman2
src/Middleman.php
Middleman.executePipeline
public function executePipeline($pipeline, Request $request, Response $response = null) { $middleman = new \mindplay\middleman\Dispatcher($pipeline, $this->resolver); return $middleman->dispatch($request); }
php
public function executePipeline($pipeline, Request $request, Response $response = null) { $middleman = new \mindplay\middleman\Dispatcher($pipeline, $this->resolver); return $middleman->dispatch($request); }
[ "public", "function", "executePipeline", "(", "$", "pipeline", ",", "Request", "$", "request", ",", "Response", "$", "response", "=", "null", ")", "{", "$", "middleman", "=", "new", "\\", "mindplay", "\\", "middleman", "\\", "Dispatcher", "(", "$", "pipeli...
Trigger execution of the supplied pipeline through Middleman. @param mixed $pipeline The stack of middleware definitions. @param Request $request The PSR7 request. @param Response $response The PSR7 response (for double-pass stacks). @return Response
[ "Trigger", "execution", "of", "the", "supplied", "pipeline", "through", "Middleman", "." ]
90dc363fa1638ce6f34b263c58ed715863d30aef
https://github.com/weavephp/middleware-middleman2/blob/90dc363fa1638ce6f34b263c58ed715863d30aef/src/Middleman.php#L53-L57
train
tomk79/php-excellent-db
php/endpoint/form.php
endpoint_form.automatic_form
public function automatic_form(){ @header('text/html; charset=UTF-8'); $rtn = ''; if( !strlen($this->options['table']) ){ // -------------------- // 対象のテーブルが選択されていない echo $this->page_table_list(); return null; } $table_definition = $this->get_current_table_definition(); // var_dump($table_definition); if( !$table_definition ){ @header("HTTP/1.0 404 Not Found"); $rtn = $this->page_fatal_error('Table NOT Exists.'); echo $rtn; return null; } if( !strlen($this->options['id']) ){ // ID無指定の場合、一覧情報を返す echo $this->page_list($this->options['table']); return null; }elseif( $this->options['id'] == ':create' ){ // IDの代わりに文字列 `:create` が指定されたら、新規作成画面を返す echo $this->page_edit($this->options['table']); return null; }else{ // ID指定がある場合、詳細情報1件を返す $row_data = $this->get_current_row_data(); if( !$row_data && !($this->options['action'] == 'delete' && $this->query_options['action'] == 'done') ){ @header("HTTP/1.0 404 Not Found"); $rtn = $this->page_fatal_error('ID NOT Exists.'); echo $rtn; return null; } if( $this->options['action'] == 'delete' ){ echo $this->page_delete($this->options['table'], $this->options['id']); }elseif( $this->options['action'] == 'edit' ){ echo $this->page_edit($this->options['table'], $this->options['id']); }else{ echo $this->page_detail($this->options['table'], $this->options['id']); } return null; } // エラー画面 $rtn = $this->page_fatal_error('Unknown method'); echo $rtn; return null; }
php
public function automatic_form(){ @header('text/html; charset=UTF-8'); $rtn = ''; if( !strlen($this->options['table']) ){ // -------------------- // 対象のテーブルが選択されていない echo $this->page_table_list(); return null; } $table_definition = $this->get_current_table_definition(); // var_dump($table_definition); if( !$table_definition ){ @header("HTTP/1.0 404 Not Found"); $rtn = $this->page_fatal_error('Table NOT Exists.'); echo $rtn; return null; } if( !strlen($this->options['id']) ){ // ID無指定の場合、一覧情報を返す echo $this->page_list($this->options['table']); return null; }elseif( $this->options['id'] == ':create' ){ // IDの代わりに文字列 `:create` が指定されたら、新規作成画面を返す echo $this->page_edit($this->options['table']); return null; }else{ // ID指定がある場合、詳細情報1件を返す $row_data = $this->get_current_row_data(); if( !$row_data && !($this->options['action'] == 'delete' && $this->query_options['action'] == 'done') ){ @header("HTTP/1.0 404 Not Found"); $rtn = $this->page_fatal_error('ID NOT Exists.'); echo $rtn; return null; } if( $this->options['action'] == 'delete' ){ echo $this->page_delete($this->options['table'], $this->options['id']); }elseif( $this->options['action'] == 'edit' ){ echo $this->page_edit($this->options['table'], $this->options['id']); }else{ echo $this->page_detail($this->options['table'], $this->options['id']); } return null; } // エラー画面 $rtn = $this->page_fatal_error('Unknown method'); echo $rtn; return null; }
[ "public", "function", "automatic_form", "(", ")", "{", "@", "header", "(", "'text/html; charset=UTF-8'", ")", ";", "$", "rtn", "=", "''", ";", "if", "(", "!", "strlen", "(", "$", "this", "->", "options", "[", "'table'", "]", ")", ")", "{", "// --------...
Execute Automatic form @return null This method returns no value.
[ "Execute", "Automatic", "form" ]
deeacf64c090fc5647267a06f97c3fb60fdf8f68
https://github.com/tomk79/php-excellent-db/blob/deeacf64c090fc5647267a06f97c3fb60fdf8f68/php/endpoint/form.php#L175-L231
train
tomk79/php-excellent-db
php/endpoint/form.php
endpoint_form.automatic_signup_form
public function automatic_signup_form($table_name, $init_cols, $options = array()){ @header('text/html; charset=UTF-8'); $param_options = $this->get_options(); $data = $param_options['post_params']; $this->table_definition = $this->exdb->get_table_definition($table_name); $is_login = $this->exdb->user()->is_login($table_name); if( $is_login ){ // ログイン処理済みなら終了 echo '<p>Already Logging in.</p>'; return true; } $page_edit = new endpoint_form_signup($this->exdb, $this, $table_name, $init_cols, $options); echo $page_edit->execute(); return true; }
php
public function automatic_signup_form($table_name, $init_cols, $options = array()){ @header('text/html; charset=UTF-8'); $param_options = $this->get_options(); $data = $param_options['post_params']; $this->table_definition = $this->exdb->get_table_definition($table_name); $is_login = $this->exdb->user()->is_login($table_name); if( $is_login ){ // ログイン処理済みなら終了 echo '<p>Already Logging in.</p>'; return true; } $page_edit = new endpoint_form_signup($this->exdb, $this, $table_name, $init_cols, $options); echo $page_edit->execute(); return true; }
[ "public", "function", "automatic_signup_form", "(", "$", "table_name", ",", "$", "init_cols", ",", "$", "options", "=", "array", "(", ")", ")", "{", "@", "header", "(", "'text/html; charset=UTF-8'", ")", ";", "$", "param_options", "=", "$", "this", "->", "...
Automatic Signup form @param string $table_name テーブル名 @param array $init_cols 初期設定するカラム名 @param array $options オプション @return boolean Always `true`.
[ "Automatic", "Signup", "form" ]
deeacf64c090fc5647267a06f97c3fb60fdf8f68
https://github.com/tomk79/php-excellent-db/blob/deeacf64c090fc5647267a06f97c3fb60fdf8f68/php/endpoint/form.php#L242-L260
train
tomk79/php-excellent-db
php/endpoint/form.php
endpoint_form.auth
public function auth($table_name, $inquiries){ $options = $this->get_options(); $data = $options['post_params']; if(@$this->query_options['action'] == 'login'){ // ログインを試みる $result = $this->exdb->user()->login( $table_name, $inquiries, $data ); } $is_login = $this->exdb->user()->is_login($table_name); if( $is_login ){ // ログイン処理済みなら終了 return true; } $table_definition = $this->exdb->get_table_definition($table_name); // var_dump($table_definition->columns); $rtn = ''; foreach( $inquiries as $column_name ){ $column_definition = $table_definition->columns->{$column_name}; $type_info = $this->exdb->form_elements()->get_type_info($column_definition->type); $form_elm = $this->render( $type_info['templates']['preview'], array( 'value'=>@$list[0][$column_definition->name], 'name'=>@$column_definition->name, 'def'=>@$column_definition, ) ); $rtn .= $this->render( 'form_elms_unit.html', array( 'label'=>@$column_definition->label, 'content'=>$form_elm, 'error'=>null, ) ); } $rtn = $this->render( 'form_login.html', array( 'is_error'=>(@$this->query_options['action'] == 'login'), 'content'=>$rtn, ) ); // var_dump($table_list); $rtn = $this->wrap_theme($rtn); echo $rtn; return false; }
php
public function auth($table_name, $inquiries){ $options = $this->get_options(); $data = $options['post_params']; if(@$this->query_options['action'] == 'login'){ // ログインを試みる $result = $this->exdb->user()->login( $table_name, $inquiries, $data ); } $is_login = $this->exdb->user()->is_login($table_name); if( $is_login ){ // ログイン処理済みなら終了 return true; } $table_definition = $this->exdb->get_table_definition($table_name); // var_dump($table_definition->columns); $rtn = ''; foreach( $inquiries as $column_name ){ $column_definition = $table_definition->columns->{$column_name}; $type_info = $this->exdb->form_elements()->get_type_info($column_definition->type); $form_elm = $this->render( $type_info['templates']['preview'], array( 'value'=>@$list[0][$column_definition->name], 'name'=>@$column_definition->name, 'def'=>@$column_definition, ) ); $rtn .= $this->render( 'form_elms_unit.html', array( 'label'=>@$column_definition->label, 'content'=>$form_elm, 'error'=>null, ) ); } $rtn = $this->render( 'form_login.html', array( 'is_error'=>(@$this->query_options['action'] == 'login'), 'content'=>$rtn, ) ); // var_dump($table_list); $rtn = $this->wrap_theme($rtn); echo $rtn; return false; }
[ "public", "function", "auth", "(", "$", "table_name", ",", "$", "inquiries", ")", "{", "$", "options", "=", "$", "this", "->", "get_options", "(", ")", ";", "$", "data", "=", "$", "options", "[", "'post_params'", "]", ";", "if", "(", "@", "$", "thi...
Execute Automatic Auth form @param string $table_name テーブル名 @param array $inquiries 照会するカラム名 @return boolean Success to `true`, Failed, or NOT Login to `false`.
[ "Execute", "Automatic", "Auth", "form" ]
deeacf64c090fc5647267a06f97c3fb60fdf8f68
https://github.com/tomk79/php-excellent-db/blob/deeacf64c090fc5647267a06f97c3fb60fdf8f68/php/endpoint/form.php#L269-L322
train
dotfilesphp/core
Processor/ProcessRunner.php
ProcessRunner.run
public function run($commandline, callable $callback = null, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { $process = new Process( $commandline, $cwd, $env, $input, $timeout ); $helper = new DebugFormatterHelper(); $output = $this->output; $output->writeln($helper->start( spl_object_hash($process), 'Executing: '.$commandline, 'STARTED' )); $process->run(function ($type, $buffer) use ($helper,$output,$process,$callback) { if (is_callable($callback)) { call_user_func($callback, $type, $buffer); } $contents = $helper->progress( spl_object_hash($process), $buffer, Process::ERR === $type ); $output->write($contents); }); return $process; }
php
public function run($commandline, callable $callback = null, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { $process = new Process( $commandline, $cwd, $env, $input, $timeout ); $helper = new DebugFormatterHelper(); $output = $this->output; $output->writeln($helper->start( spl_object_hash($process), 'Executing: '.$commandline, 'STARTED' )); $process->run(function ($type, $buffer) use ($helper,$output,$process,$callback) { if (is_callable($callback)) { call_user_func($callback, $type, $buffer); } $contents = $helper->progress( spl_object_hash($process), $buffer, Process::ERR === $type ); $output->write($contents); }); return $process; }
[ "public", "function", "run", "(", "$", "commandline", ",", "callable", "$", "callback", "=", "null", ",", "string", "$", "cwd", "=", "null", ",", "array", "$", "env", "=", "null", ",", "$", "input", "=", "null", ",", "?", "float", "$", "timeout", "...
Creates process and run with predefined DebugFormatterHelper. @param string $commandline @param callable|null $callback @param string|null $cwd @param array|null $env @param null $input @param int|float|null $timeout The timeout in seconds or null to disable @see Process @return Process
[ "Creates", "process", "and", "run", "with", "predefined", "DebugFormatterHelper", "." ]
d55e44449cf67e9d56a22863447fd782c88d9b2d
https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/Processor/ProcessRunner.php#L66-L96
train
nirix/radium
src/Language/Translation.php
Translation.translate
public function translate($string, Array $vars = array()) { // Use custom translator if ($this->translator) { return $this->translator($this->getString($string), $vars); } return $this->compileString($this->getString($string), $vars); }
php
public function translate($string, Array $vars = array()) { // Use custom translator if ($this->translator) { return $this->translator($this->getString($string), $vars); } return $this->compileString($this->getString($string), $vars); }
[ "public", "function", "translate", "(", "$", "string", ",", "Array", "$", "vars", "=", "array", "(", ")", ")", "{", "// Use custom translator", "if", "(", "$", "this", "->", "translator", ")", "{", "return", "$", "this", "->", "translator", "(", "$", "...
Translates the specified string. @return string
[ "Translates", "the", "specified", "string", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Language/Translation.php#L55-L63
train
nirix/radium
src/Language/Translation.php
Translation.getString
public function getString($string) { // Exact match? if (isset($this->strings[$string])) { return $this->strings[$string]; } else { return $string; } }
php
public function getString($string) { // Exact match? if (isset($this->strings[$string])) { return $this->strings[$string]; } else { return $string; } }
[ "public", "function", "getString", "(", "$", "string", ")", "{", "// Exact match?", "if", "(", "isset", "(", "$", "this", "->", "strings", "[", "$", "string", "]", ")", ")", "{", "return", "$", "this", "->", "strings", "[", "$", "string", "]", ";", ...
Fetches the translation for the specified string. @param string $string @return string
[ "Fetches", "the", "translation", "for", "the", "specified", "string", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Language/Translation.php#L83-L91
train
nirix/radium
src/Language/Translation.php
Translation.calculateNumeral
public function calculateNumeral($numeral) { // Use custom enumerator if ($this->enumerator) { return $this->enumerator($numeral); } return ($numeral > 1 or $numeral < -1 or $numeral == 0) ? 1 : 0; }
php
public function calculateNumeral($numeral) { // Use custom enumerator if ($this->enumerator) { return $this->enumerator($numeral); } return ($numeral > 1 or $numeral < -1 or $numeral == 0) ? 1 : 0; }
[ "public", "function", "calculateNumeral", "(", "$", "numeral", ")", "{", "// Use custom enumerator", "if", "(", "$", "this", "->", "enumerator", ")", "{", "return", "$", "this", "->", "enumerator", "(", "$", "numeral", ")", ";", "}", "return", "(", "$", ...
Determines which replacement to use for plurals. @param integer $numeral @return integer
[ "Determines", "which", "replacement", "to", "use", "for", "plurals", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Language/Translation.php#L100-L108
train
nirix/radium
src/Language/Translation.php
Translation.compileString
protected function compileString($string, $vars) { $translation = $string; // Loop through and replace the placeholders // with the values from the $vars array. $count = 0; foreach ($vars as $key => $val) { $count++; // If array key is an integer, // use the counter to avoid clashes // with numbered placeholders. if (is_integer($key)) { $key = $count; } // Replace placeholder with value $translation = str_replace(array("{{$key}}", "{{$count}}"), $val, $translation); } // Match plural:n,{x, y} if (preg_match_all("/{plural:(?<value>-{0,1}\d+)(,|, ){(?<replacements>.*?)}}/i", $translation, $matches)) { foreach($matches[0] as $id => $match) { // Split the replacements into an array. // There's an extra | at the start to allow for better matching // with values. $replacements = explode('|', $matches['replacements'][$id]); // Get the value $value = $matches['value'][$id]; // Check what replacement to use... $replacement_id = $this->calculateNumeral($value); if ($replacement_id !== false) { $translation = str_replace($match, $replacements[$replacement_id], $translation); } // Get the last value then else { $translation = str_replace($match, end($replacements), $translation); } } } // We're done here. return $translation; }
php
protected function compileString($string, $vars) { $translation = $string; // Loop through and replace the placeholders // with the values from the $vars array. $count = 0; foreach ($vars as $key => $val) { $count++; // If array key is an integer, // use the counter to avoid clashes // with numbered placeholders. if (is_integer($key)) { $key = $count; } // Replace placeholder with value $translation = str_replace(array("{{$key}}", "{{$count}}"), $val, $translation); } // Match plural:n,{x, y} if (preg_match_all("/{plural:(?<value>-{0,1}\d+)(,|, ){(?<replacements>.*?)}}/i", $translation, $matches)) { foreach($matches[0] as $id => $match) { // Split the replacements into an array. // There's an extra | at the start to allow for better matching // with values. $replacements = explode('|', $matches['replacements'][$id]); // Get the value $value = $matches['value'][$id]; // Check what replacement to use... $replacement_id = $this->calculateNumeral($value); if ($replacement_id !== false) { $translation = str_replace($match, $replacements[$replacement_id], $translation); } // Get the last value then else { $translation = str_replace($match, end($replacements), $translation); } } } // We're done here. return $translation; }
[ "protected", "function", "compileString", "(", "$", "string", ",", "$", "vars", ")", "{", "$", "translation", "=", "$", "string", ";", "// Loop through and replace the placeholders", "// with the values from the $vars array.", "$", "count", "=", "0", ";", "foreach", ...
Compiles the translated string with the variables. @example compileString('{plural:$1, {$1 post|$1 posts}}', array(1)); will become "1 post" @param string $string @param array $vars @return string
[ "Compiles", "the", "translated", "string", "with", "the", "variables", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Language/Translation.php#L122-L168
train
gossi/trixionary
src/model/Base/Sport.php
Sport.initObjects
public function initObjects($overrideExisting = true) { if (null !== $this->collObjects && !$overrideExisting) { return; } $this->collObjects = new ObjectCollection(); $this->collObjects->setModel('\gossi\trixionary\model\Object'); }
php
public function initObjects($overrideExisting = true) { if (null !== $this->collObjects && !$overrideExisting) { return; } $this->collObjects = new ObjectCollection(); $this->collObjects->setModel('\gossi\trixionary\model\Object'); }
[ "public", "function", "initObjects", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collObjects", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collObjects", "=",...
Initializes the collObjects collection. By default this just sets the collObjects collection to an empty array (like clearcollObjects()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collObjects", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2518-L2525
train
gossi/trixionary
src/model/Base/Sport.php
Sport.getObjects
public function getObjects(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collObjectsPartial && !$this->isNew(); if (null === $this->collObjects || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collObjects) { // return empty collection $this->initObjects(); } else { $collObjects = ChildObjectQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collObjectsPartial && count($collObjects)) { $this->initObjects(false); foreach ($collObjects as $obj) { if (false == $this->collObjects->contains($obj)) { $this->collObjects->append($obj); } } $this->collObjectsPartial = true; } return $collObjects; } if ($partial && $this->collObjects) { foreach ($this->collObjects as $obj) { if ($obj->isNew()) { $collObjects[] = $obj; } } } $this->collObjects = $collObjects; $this->collObjectsPartial = false; } } return $this->collObjects; }
php
public function getObjects(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collObjectsPartial && !$this->isNew(); if (null === $this->collObjects || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collObjects) { // return empty collection $this->initObjects(); } else { $collObjects = ChildObjectQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collObjectsPartial && count($collObjects)) { $this->initObjects(false); foreach ($collObjects as $obj) { if (false == $this->collObjects->contains($obj)) { $this->collObjects->append($obj); } } $this->collObjectsPartial = true; } return $collObjects; } if ($partial && $this->collObjects) { foreach ($this->collObjects as $obj) { if ($obj->isNew()) { $collObjects[] = $obj; } } } $this->collObjects = $collObjects; $this->collObjectsPartial = false; } } return $this->collObjects; }
[ "public", "function", "getObjects", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collObjectsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")...
Gets an array of ChildObject objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildSport is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildObject[] List of ChildObject objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildObject", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2541-L2583
train
gossi/trixionary
src/model/Base/Sport.php
Sport.countObjects
public function countObjects(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collObjectsPartial && !$this->isNew(); if (null === $this->collObjects || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collObjects) { return 0; } if ($partial && !$criteria) { return count($this->getObjects()); } $query = ChildObjectQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySport($this) ->count($con); } return count($this->collObjects); }
php
public function countObjects(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collObjectsPartial && !$this->isNew(); if (null === $this->collObjects || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collObjects) { return 0; } if ($partial && !$criteria) { return count($this->getObjects()); } $query = ChildObjectQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySport($this) ->count($con); } return count($this->collObjects); }
[ "public", "function", "countObjects", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collObjectsPartial", "&&", "!",...
Returns the number of related Object objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Object objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Object", "objects", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2627-L2650
train
gossi/trixionary
src/model/Base/Sport.php
Sport.addObject
public function addObject(ChildObject $l) { if ($this->collObjects === null) { $this->initObjects(); $this->collObjectsPartial = true; } if (!$this->collObjects->contains($l)) { $this->doAddObject($l); } return $this; }
php
public function addObject(ChildObject $l) { if ($this->collObjects === null) { $this->initObjects(); $this->collObjectsPartial = true; } if (!$this->collObjects->contains($l)) { $this->doAddObject($l); } return $this; }
[ "public", "function", "addObject", "(", "ChildObject", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collObjects", "===", "null", ")", "{", "$", "this", "->", "initObjects", "(", ")", ";", "$", "this", "->", "collObjectsPartial", "=", "true", ";",...
Method called to associate a ChildObject object to this object through the ChildObject foreign key attribute. @param ChildObject $l ChildObject @return $this|\gossi\trixionary\model\Sport The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildObject", "object", "to", "this", "object", "through", "the", "ChildObject", "foreign", "key", "attribute", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2659-L2671
train
gossi/trixionary
src/model/Base/Sport.php
Sport.initPositions
public function initPositions($overrideExisting = true) { if (null !== $this->collPositions && !$overrideExisting) { return; } $this->collPositions = new ObjectCollection(); $this->collPositions->setModel('\gossi\trixionary\model\Position'); }
php
public function initPositions($overrideExisting = true) { if (null !== $this->collPositions && !$overrideExisting) { return; } $this->collPositions = new ObjectCollection(); $this->collPositions->setModel('\gossi\trixionary\model\Position'); }
[ "public", "function", "initPositions", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collPositions", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collPositions", ...
Initializes the collPositions collection. By default this just sets the collPositions collection to an empty array (like clearcollPositions()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collPositions", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2736-L2743
train
gossi/trixionary
src/model/Base/Sport.php
Sport.getPositions
public function getPositions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPositionsPartial && !$this->isNew(); if (null === $this->collPositions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPositions) { // return empty collection $this->initPositions(); } else { $collPositions = ChildPositionQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPositionsPartial && count($collPositions)) { $this->initPositions(false); foreach ($collPositions as $obj) { if (false == $this->collPositions->contains($obj)) { $this->collPositions->append($obj); } } $this->collPositionsPartial = true; } return $collPositions; } if ($partial && $this->collPositions) { foreach ($this->collPositions as $obj) { if ($obj->isNew()) { $collPositions[] = $obj; } } } $this->collPositions = $collPositions; $this->collPositionsPartial = false; } } return $this->collPositions; }
php
public function getPositions(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collPositionsPartial && !$this->isNew(); if (null === $this->collPositions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPositions) { // return empty collection $this->initPositions(); } else { $collPositions = ChildPositionQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collPositionsPartial && count($collPositions)) { $this->initPositions(false); foreach ($collPositions as $obj) { if (false == $this->collPositions->contains($obj)) { $this->collPositions->append($obj); } } $this->collPositionsPartial = true; } return $collPositions; } if ($partial && $this->collPositions) { foreach ($this->collPositions as $obj) { if ($obj->isNew()) { $collPositions[] = $obj; } } } $this->collPositions = $collPositions; $this->collPositionsPartial = false; } } return $this->collPositions; }
[ "public", "function", "getPositions", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPositionsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ...
Gets an array of ChildPosition objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildSport is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildPosition[] List of ChildPosition objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildPosition", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2759-L2801
train
gossi/trixionary
src/model/Base/Sport.php
Sport.countPositions
public function countPositions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPositionsPartial && !$this->isNew(); if (null === $this->collPositions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPositions) { return 0; } if ($partial && !$criteria) { return count($this->getPositions()); } $query = ChildPositionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySport($this) ->count($con); } return count($this->collPositions); }
php
public function countPositions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collPositionsPartial && !$this->isNew(); if (null === $this->collPositions || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collPositions) { return 0; } if ($partial && !$criteria) { return count($this->getPositions()); } $query = ChildPositionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterBySport($this) ->count($con); } return count($this->collPositions); }
[ "public", "function", "countPositions", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collPositionsPartial", "&&", ...
Returns the number of related Position objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Position objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Position", "objects", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2845-L2868
train
gossi/trixionary
src/model/Base/Sport.php
Sport.addPosition
public function addPosition(ChildPosition $l) { if ($this->collPositions === null) { $this->initPositions(); $this->collPositionsPartial = true; } if (!$this->collPositions->contains($l)) { $this->doAddPosition($l); } return $this; }
php
public function addPosition(ChildPosition $l) { if ($this->collPositions === null) { $this->initPositions(); $this->collPositionsPartial = true; } if (!$this->collPositions->contains($l)) { $this->doAddPosition($l); } return $this; }
[ "public", "function", "addPosition", "(", "ChildPosition", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collPositions", "===", "null", ")", "{", "$", "this", "->", "initPositions", "(", ")", ";", "$", "this", "->", "collPositionsPartial", "=", "tru...
Method called to associate a ChildPosition object to this object through the ChildPosition foreign key attribute. @param ChildPosition $l ChildPosition @return $this|\gossi\trixionary\model\Sport The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildPosition", "object", "to", "this", "object", "through", "the", "ChildPosition", "foreign", "key", "attribute", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L2877-L2889
train
gossi/trixionary
src/model/Base/Sport.php
Sport.getSkillsJoinObject
public function getSkillsJoinObject(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Object', $joinBehavior); return $this->getSkills($query, $con); }
php
public function getSkillsJoinObject(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Object', $joinBehavior); return $this->getSkills($query, $con); }
[ "public", "function", "getSkillsJoinObject", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillQuery", "::",...
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Sport is new, it will return an empty collection; or if this Sport has previously been saved, it will retrieve related Skills from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Sport. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Sport", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", ...
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L3205-L3211
train
gossi/trixionary
src/model/Base/Sport.php
Sport.initGroups
public function initGroups($overrideExisting = true) { if (null !== $this->collGroups && !$overrideExisting) { return; } $this->collGroups = new ObjectCollection(); $this->collGroups->setModel('\gossi\trixionary\model\Group'); }
php
public function initGroups($overrideExisting = true) { if (null !== $this->collGroups && !$overrideExisting) { return; } $this->collGroups = new ObjectCollection(); $this->collGroups->setModel('\gossi\trixionary\model\Group'); }
[ "public", "function", "initGroups", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collGroups", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collGroups", "=", ...
Initializes the collGroups collection. By default this just sets the collGroups collection to an empty array (like clearcollGroups()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collGroups", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L3422-L3429
train
gossi/trixionary
src/model/Base/Sport.php
Sport.getGroups
public function getGroups(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupsPartial && !$this->isNew(); if (null === $this->collGroups || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroups) { // return empty collection $this->initGroups(); } else { $collGroups = ChildGroupQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collGroupsPartial && count($collGroups)) { $this->initGroups(false); foreach ($collGroups as $obj) { if (false == $this->collGroups->contains($obj)) { $this->collGroups->append($obj); } } $this->collGroupsPartial = true; } return $collGroups; } if ($partial && $this->collGroups) { foreach ($this->collGroups as $obj) { if ($obj->isNew()) { $collGroups[] = $obj; } } } $this->collGroups = $collGroups; $this->collGroupsPartial = false; } } return $this->collGroups; }
php
public function getGroups(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupsPartial && !$this->isNew(); if (null === $this->collGroups || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collGroups) { // return empty collection $this->initGroups(); } else { $collGroups = ChildGroupQuery::create(null, $criteria) ->filterBySport($this) ->find($con); if (null !== $criteria) { if (false !== $this->collGroupsPartial && count($collGroups)) { $this->initGroups(false); foreach ($collGroups as $obj) { if (false == $this->collGroups->contains($obj)) { $this->collGroups->append($obj); } } $this->collGroupsPartial = true; } return $collGroups; } if ($partial && $this->collGroups) { foreach ($this->collGroups as $obj) { if ($obj->isNew()) { $collGroups[] = $obj; } } } $this->collGroups = $collGroups; $this->collGroupsPartial = false; } } return $this->collGroups; }
[ "public", "function", "getGroups", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collGroupsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")",...
Gets an array of ChildGroup objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildSport is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildGroup[] List of ChildGroup objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildGroup", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L3445-L3487
train
gossi/trixionary
src/model/Base/Sport.php
Sport.addGroup
public function addGroup(ChildGroup $l) { if ($this->collGroups === null) { $this->initGroups(); $this->collGroupsPartial = true; } if (!$this->collGroups->contains($l)) { $this->doAddGroup($l); } return $this; }
php
public function addGroup(ChildGroup $l) { if ($this->collGroups === null) { $this->initGroups(); $this->collGroupsPartial = true; } if (!$this->collGroups->contains($l)) { $this->doAddGroup($l); } return $this; }
[ "public", "function", "addGroup", "(", "ChildGroup", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collGroups", "===", "null", ")", "{", "$", "this", "->", "initGroups", "(", ")", ";", "$", "this", "->", "collGroupsPartial", "=", "true", ";", "}...
Method called to associate a ChildGroup object to this object through the ChildGroup foreign key attribute. @param ChildGroup $l ChildGroup @return $this|\gossi\trixionary\model\Sport The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildGroup", "object", "to", "this", "object", "through", "the", "ChildGroup", "foreign", "key", "attribute", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L3563-L3575
train
netgloo/benjamin_core
src/Http/Controllers/Api/PagesController.php
PagesController.getAll
public function getAll(Request $request) { // Get the views' directory $viewsPath = base_path() . '/resources/views/'; if (!is_dir($viewsPath)) { error_log("The directory /resources/views/ doesn't exists."); throw new PathNotFoundException(); } // Get the lang' directory $langPath = base_path() . '/resources/lang/'; if (!is_dir($langPath)) { error_log("The directory /resources/lang/ doesn't exists."); throw new PathNotFoundException(); } // Get the language directory from the current url $path = $request->input('path'); $pathInfo = LocaleService::parsePath($path); // Set the active language LocaleService::setLang($pathInfo->lang); // Init the response object $resp = new \stdClass(); $resp->langDir = $pathInfo->langDir; $resp->pages = null; // Get last modification time on views or lang's messages $pagesLastMod = max( self::getLastMod($viewsPath), self::getLastMod($langPath) ); // Init current cache keys (language-dependent) $pagesKey = "pages.{$pathInfo->lang}"; $pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp"; // Check if the cache is enabled $cacheEnabled = false; if (env('CACHE_DRIVER') !== null) { $cacheEnabled = true; } // If the cache is valid return the cached value if ($cacheEnabled) { $pagesLastCache = Cache::get($pagesTimestampKey); if ($pagesLastCache !== null && $pagesLastCache >= $pagesLastMod) { $resp->pages = Cache::get($pagesKey); return response()->json($resp); } } // Get the list of views $viewsList = self::getViewsList($viewsPath); // Initialize the LocaleLinkService used inside views to set links LocaleLinkService::setLang($pathInfo->lang); LocaleLinkService::setLangDir($pathInfo->langDir); // Fill the $pages array, containing all the pages' content $pages = []; foreach ($viewsList as $viewName) { $page = new \stdClass(); // Page path $page->path = ($viewName === 'index') ? '' : $viewName; $page->path = '/' . str_replace('.', '/', $page->path); // Set the page's path inside the LocaleLinkService LocaleLinkService::setPagePath($page->path); // Page title $page->title = view( $viewName, [ 'benjamin' => 'benjamin::title', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); // Page body $page->body = view( $viewName, [ 'benjamin' => 'benjamin::body', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); // bodyClass $page->bodyClass = view( $viewName, [ 'benjamin' => 'benjamin::bodyClass', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); $pages[] = $page; } // Cache the value if ($cacheEnabled) { Cache::forever($pagesKey, $pages); Cache::forever($pagesTimestampKey, time()); } // Response $resp->pages = $pages; return response()->json($resp); }
php
public function getAll(Request $request) { // Get the views' directory $viewsPath = base_path() . '/resources/views/'; if (!is_dir($viewsPath)) { error_log("The directory /resources/views/ doesn't exists."); throw new PathNotFoundException(); } // Get the lang' directory $langPath = base_path() . '/resources/lang/'; if (!is_dir($langPath)) { error_log("The directory /resources/lang/ doesn't exists."); throw new PathNotFoundException(); } // Get the language directory from the current url $path = $request->input('path'); $pathInfo = LocaleService::parsePath($path); // Set the active language LocaleService::setLang($pathInfo->lang); // Init the response object $resp = new \stdClass(); $resp->langDir = $pathInfo->langDir; $resp->pages = null; // Get last modification time on views or lang's messages $pagesLastMod = max( self::getLastMod($viewsPath), self::getLastMod($langPath) ); // Init current cache keys (language-dependent) $pagesKey = "pages.{$pathInfo->lang}"; $pagesTimestampKey = "pages.{$pathInfo->lang}.timestamp"; // Check if the cache is enabled $cacheEnabled = false; if (env('CACHE_DRIVER') !== null) { $cacheEnabled = true; } // If the cache is valid return the cached value if ($cacheEnabled) { $pagesLastCache = Cache::get($pagesTimestampKey); if ($pagesLastCache !== null && $pagesLastCache >= $pagesLastMod) { $resp->pages = Cache::get($pagesKey); return response()->json($resp); } } // Get the list of views $viewsList = self::getViewsList($viewsPath); // Initialize the LocaleLinkService used inside views to set links LocaleLinkService::setLang($pathInfo->lang); LocaleLinkService::setLangDir($pathInfo->langDir); // Fill the $pages array, containing all the pages' content $pages = []; foreach ($viewsList as $viewName) { $page = new \stdClass(); // Page path $page->path = ($viewName === 'index') ? '' : $viewName; $page->path = '/' . str_replace('.', '/', $page->path); // Set the page's path inside the LocaleLinkService LocaleLinkService::setPagePath($page->path); // Page title $page->title = view( $viewName, [ 'benjamin' => 'benjamin::title', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); // Page body $page->body = view( $viewName, [ 'benjamin' => 'benjamin::body', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); // bodyClass $page->bodyClass = view( $viewName, [ 'benjamin' => 'benjamin::bodyClass', 'activeLang' => LocaleService::getActiveLang(), ] )->render(); $pages[] = $page; } // Cache the value if ($cacheEnabled) { Cache::forever($pagesKey, $pages); Cache::forever($pagesTimestampKey, time()); } // Response $resp->pages = $pages; return response()->json($resp); }
[ "public", "function", "getAll", "(", "Request", "$", "request", ")", "{", "// Get the views' directory", "$", "viewsPath", "=", "base_path", "(", ")", ".", "'/resources/views/'", ";", "if", "(", "!", "is_dir", "(", "$", "viewsPath", ")", ")", "{", "error_log...
Return a JSON object containing the content of all the pages. The returned object will have this structure: { langDir: 'en', pages: [{ path: '/', title: 'Home', body: '<div> ... </div>' bodyClass: 'some-class' }, { path: '/...', title: '...', body: '...' bodyClass: '...' }, ... ] } @return JSON
[ "Return", "a", "JSON", "object", "containing", "the", "content", "of", "all", "the", "pages", "." ]
8f5000e626104ab2c5e7d003b1e8f420937e8a44
https://github.com/netgloo/benjamin_core/blob/8f5000e626104ab2c5e7d003b1e8f420937e8a44/src/Http/Controllers/Api/PagesController.php#L42-L154
train
netgloo/benjamin_core
src/Http/Controllers/Api/PagesController.php
PagesController.getLastMod
private function getLastMod($dirPath) { $dirInfo = new \SplFileInfo($dirPath); $lastMod = $dirInfo->getMTime(); // Check files and subdirectories $iter = new \FilesystemIterator($dirPath); foreach ($iter as $fileInfo) { if ($fileInfo->isDir()) { $mtime = self::getLastMod($fileInfo->getPathname()); } else { $mtime = $fileInfo->getMTime(); } if ($mtime > $lastMod) { $lastMod = $mtime; } } return $lastMod; }
php
private function getLastMod($dirPath) { $dirInfo = new \SplFileInfo($dirPath); $lastMod = $dirInfo->getMTime(); // Check files and subdirectories $iter = new \FilesystemIterator($dirPath); foreach ($iter as $fileInfo) { if ($fileInfo->isDir()) { $mtime = self::getLastMod($fileInfo->getPathname()); } else { $mtime = $fileInfo->getMTime(); } if ($mtime > $lastMod) { $lastMod = $mtime; } } return $lastMod; }
[ "private", "function", "getLastMod", "(", "$", "dirPath", ")", "{", "$", "dirInfo", "=", "new", "\\", "SplFileInfo", "(", "$", "dirPath", ")", ";", "$", "lastMod", "=", "$", "dirInfo", "->", "getMTime", "(", ")", ";", "// Check files and subdirectories", "...
Returns the last modification time for all files and directories inside the given directory. @param $dirPath (String) @param $cacheTime (String) @return (int) The unix timestamp for the last modification
[ "Returns", "the", "last", "modification", "time", "for", "all", "files", "and", "directories", "inside", "the", "given", "directory", "." ]
8f5000e626104ab2c5e7d003b1e8f420937e8a44
https://github.com/netgloo/benjamin_core/blob/8f5000e626104ab2c5e7d003b1e8f420937e8a44/src/Http/Controllers/Api/PagesController.php#L169-L191
train
netgloo/benjamin_core
src/Http/Controllers/Api/PagesController.php
PagesController.getViewsList
private function getViewsList($dirPath, $checkSubDir = true) { $viewsList = []; $iter = new \FilesystemIterator($dirPath); foreach ($iter as $fileInfo) { $filename = $fileInfo->getFilename(); if ($filename[0] === '_') { continue; } // Directories if ($fileInfo->isDir()) { if (!$checkSubDir) { continue; } if ($filename === 'errors' || $filename === 'layouts' || $filename === 'templates' || $filename === 'vendor') { continue; } // $subViews = self::getViewsList($fileInfo->getPathname(), false); $subViews = self::getViewsList($fileInfo->getPathname()); // Prepend directory name and add the view name to current list foreach ($subViews as $subViewName) { $viewsList[] = $filename . '.' . $subViewName; } continue; } // Files if (substr($filename, -10) !== '.blade.php') { continue; } $viewName = substr($filename, 0, -10); $viewsList[] = $viewName; } return $viewsList; }
php
private function getViewsList($dirPath, $checkSubDir = true) { $viewsList = []; $iter = new \FilesystemIterator($dirPath); foreach ($iter as $fileInfo) { $filename = $fileInfo->getFilename(); if ($filename[0] === '_') { continue; } // Directories if ($fileInfo->isDir()) { if (!$checkSubDir) { continue; } if ($filename === 'errors' || $filename === 'layouts' || $filename === 'templates' || $filename === 'vendor') { continue; } // $subViews = self::getViewsList($fileInfo->getPathname(), false); $subViews = self::getViewsList($fileInfo->getPathname()); // Prepend directory name and add the view name to current list foreach ($subViews as $subViewName) { $viewsList[] = $filename . '.' . $subViewName; } continue; } // Files if (substr($filename, -10) !== '.blade.php') { continue; } $viewName = substr($filename, 0, -10); $viewsList[] = $viewName; } return $viewsList; }
[ "private", "function", "getViewsList", "(", "$", "dirPath", ",", "$", "checkSubDir", "=", "true", ")", "{", "$", "viewsList", "=", "[", "]", ";", "$", "iter", "=", "new", "\\", "FilesystemIterator", "(", "$", "dirPath", ")", ";", "foreach", "(", "$", ...
Return a list of all available views in the given directory. These files will be skipped: - Each file or directory starting with '_' - Directory /errors - Directory /layouts - Directory /templates - Directory /vendor - Files not ending with '.blade.php' @param $dirPath (String) @param $checkSubDir (Boolean) Default true. If false, all subdirectories inside the current directory ($dirPath) will be skipped. @return Array
[ "Return", "a", "list", "of", "all", "available", "views", "in", "the", "given", "directory", "." ]
8f5000e626104ab2c5e7d003b1e8f420937e8a44
https://github.com/netgloo/benjamin_core/blob/8f5000e626104ab2c5e7d003b1e8f420937e8a44/src/Http/Controllers/Api/PagesController.php#L210-L250
train
khanhicetea/sifoni
src/Sifoni/Engine.php
Engine.loadLanguages
private function loadLanguages() { $app = $this->app; $engine = $this; $languages = $app['config.app.languages']; $app['multi_languages'] = count($languages) > 1; $app->register(new LocaleServiceProvider()); $app->register(new TranslationServiceProvider(), [ 'locale_fallbacks' => $languages, ]); $app['translator.domains'] = function () use ($app, $engine) { $translator_domains = [ 'messages' => [], 'validators' => [], ]; $languages = $app['config.app.languages']; foreach ($languages as $language) { if (is_readable($engine->getAppPath('language').DIRECTORY_SEPARATOR.strtolower($language).'.php')) { $trans = include $engine->getAppPath('language').DIRECTORY_SEPARATOR.strtolower($language).'.php'; $translator_domains['messages'][$language] = isset($trans['messages']) ? $trans['messages'] : []; $translator_domains['validators'][$language] = isset($trans['validators']) ? $trans['validators'] : []; } } return $translator_domains; }; }
php
private function loadLanguages() { $app = $this->app; $engine = $this; $languages = $app['config.app.languages']; $app['multi_languages'] = count($languages) > 1; $app->register(new LocaleServiceProvider()); $app->register(new TranslationServiceProvider(), [ 'locale_fallbacks' => $languages, ]); $app['translator.domains'] = function () use ($app, $engine) { $translator_domains = [ 'messages' => [], 'validators' => [], ]; $languages = $app['config.app.languages']; foreach ($languages as $language) { if (is_readable($engine->getAppPath('language').DIRECTORY_SEPARATOR.strtolower($language).'.php')) { $trans = include $engine->getAppPath('language').DIRECTORY_SEPARATOR.strtolower($language).'.php'; $translator_domains['messages'][$language] = isset($trans['messages']) ? $trans['messages'] : []; $translator_domains['validators'][$language] = isset($trans['validators']) ? $trans['validators'] : []; } } return $translator_domains; }; }
[ "private", "function", "loadLanguages", "(", ")", "{", "$", "app", "=", "$", "this", "->", "app", ";", "$", "engine", "=", "$", "this", ";", "$", "languages", "=", "$", "app", "[", "'config.app.languages'", "]", ";", "$", "app", "[", "'multi_languages'...
Load languages.
[ "Load", "languages", "." ]
e32a2d2cb16a2bb7939250372bd74ca3ca7eba58
https://github.com/khanhicetea/sifoni/blob/e32a2d2cb16a2bb7939250372bd74ca3ca7eba58/src/Sifoni/Engine.php#L250-L279
train
khanhicetea/sifoni
src/Sifoni/Engine.php
Engine.loadRouting
private function loadRouting() { $app = $this->app; $maps = []; $routing_file_path = $this->getAppPath('config').DIRECTORY_SEPARATOR.'routing.php'; if (is_readable($routing_file_path)) { $maps = require $routing_file_path; } if ($maps) { $prefix_locale = $app['multi_languages'] ? '/{_locale}' : ''; $app_controller_prefix = $app['app.vendor_name'].'\\Controller\\'; foreach ($maps as $prefix => $routes) { $map = $this->app['controllers_factory']; foreach ($routes as $pattern => $target) { if ($pattern == '.' && is_callable($target)) { call_user_func($target, $map); } else { $params = is_array($target) ? $target : explode(':', $target); $controller_name = $app_controller_prefix.$params[0]; $action = $params[1].'Action'; $bind_name = isset($params[2]) ? $params[2] : false; $method = isset($params[4]) ? strtolower($params[4]) : 'get|post'; $tmp = $map->match($pattern, $controller_name.'::'.$action)->method($method); if ($bind_name) { $tmp->bind($bind_name); } if (!empty($params[3])) { if (is_array($params[3])) { foreach ($params[3] as $key => $value) { $tmp->value($key, $value); } } else { $defaults = explode(',', $params[3]); foreach ($defaults as $default) { $values = explode('=', $default); $tmp->value($values[0], $values[1]); } } } if ($prefix_locale != '' && $prefix == '/' && $pattern == '/') { $app->match('/', $controller_name.'::'.$action)->method($method); } } } $app->mount($prefix_locale.$prefix, $map); } } }
php
private function loadRouting() { $app = $this->app; $maps = []; $routing_file_path = $this->getAppPath('config').DIRECTORY_SEPARATOR.'routing.php'; if (is_readable($routing_file_path)) { $maps = require $routing_file_path; } if ($maps) { $prefix_locale = $app['multi_languages'] ? '/{_locale}' : ''; $app_controller_prefix = $app['app.vendor_name'].'\\Controller\\'; foreach ($maps as $prefix => $routes) { $map = $this->app['controllers_factory']; foreach ($routes as $pattern => $target) { if ($pattern == '.' && is_callable($target)) { call_user_func($target, $map); } else { $params = is_array($target) ? $target : explode(':', $target); $controller_name = $app_controller_prefix.$params[0]; $action = $params[1].'Action'; $bind_name = isset($params[2]) ? $params[2] : false; $method = isset($params[4]) ? strtolower($params[4]) : 'get|post'; $tmp = $map->match($pattern, $controller_name.'::'.$action)->method($method); if ($bind_name) { $tmp->bind($bind_name); } if (!empty($params[3])) { if (is_array($params[3])) { foreach ($params[3] as $key => $value) { $tmp->value($key, $value); } } else { $defaults = explode(',', $params[3]); foreach ($defaults as $default) { $values = explode('=', $default); $tmp->value($values[0], $values[1]); } } } if ($prefix_locale != '' && $prefix == '/' && $pattern == '/') { $app->match('/', $controller_name.'::'.$action)->method($method); } } } $app->mount($prefix_locale.$prefix, $map); } } }
[ "private", "function", "loadRouting", "(", ")", "{", "$", "app", "=", "$", "this", "->", "app", ";", "$", "maps", "=", "[", "]", ";", "$", "routing_file_path", "=", "$", "this", "->", "getAppPath", "(", "'config'", ")", ".", "DIRECTORY_SEPARATOR", ".",...
Load routing.
[ "Load", "routing", "." ]
e32a2d2cb16a2bb7939250372bd74ca3ca7eba58
https://github.com/khanhicetea/sifoni/blob/e32a2d2cb16a2bb7939250372bd74ca3ca7eba58/src/Sifoni/Engine.php#L284-L339
train
petitchevalroux/php-configuration-factory
src/Factory.php
Factory.setLoader
public function setLoader(Loader $loader) { $this->loader = $loader; $this->loader->setNamespace($this->getNamespace()); }
php
public function setLoader(Loader $loader) { $this->loader = $loader; $this->loader->setNamespace($this->getNamespace()); }
[ "public", "function", "setLoader", "(", "Loader", "$", "loader", ")", "{", "$", "this", "->", "loader", "=", "$", "loader", ";", "$", "this", "->", "loader", "->", "setNamespace", "(", "$", "this", "->", "getNamespace", "(", ")", ")", ";", "}" ]
Set configuration factory loader. @param Loader $loader
[ "Set", "configuration", "factory", "loader", "." ]
94dfa809f0739dfbcb0d8996ba22af6afe786428
https://github.com/petitchevalroux/php-configuration-factory/blob/94dfa809f0739dfbcb0d8996ba22af6afe786428/src/Factory.php#L23-L27
train
lukaszmakuch/haringo
src/Builder/Impl/HaringoBuilderImpl.php
HaringoBuilderImpl.getSerializerValSourceExtBasedOn
private function getSerializerValSourceExtBasedOn(ValueSourceExtension $ext) { return new SerializerValueSourceExtensionImpl( $ext->getMapper(), $ext->getSupportedValueSourceClass(), $ext->getUniqueExtensionId() ); }
php
private function getSerializerValSourceExtBasedOn(ValueSourceExtension $ext) { return new SerializerValueSourceExtensionImpl( $ext->getMapper(), $ext->getSupportedValueSourceClass(), $ext->getUniqueExtensionId() ); }
[ "private", "function", "getSerializerValSourceExtBasedOn", "(", "ValueSourceExtension", "$", "ext", ")", "{", "return", "new", "SerializerValueSourceExtensionImpl", "(", "$", "ext", "->", "getMapper", "(", ")", ",", "$", "ext", "->", "getSupportedValueSourceClass", "(...
Converts a general value source extension into an extension accepted by the mapper. @param ValueSourceExtension $ext @return SerializerValueSourceExtensionImpl
[ "Converts", "a", "general", "value", "source", "extension", "into", "an", "extension", "accepted", "by", "the", "mapper", "." ]
7a2ff30f4e7b215b2573a9562ed449f6495d303d
https://github.com/lukaszmakuch/haringo/blob/7a2ff30f4e7b215b2573a9562ed449f6495d303d/src/Builder/Impl/HaringoBuilderImpl.php#L98-L105
train
phlexible/phlexible
src/Phlexible/Component/MediaType/Model/MediaType.php
MediaType.getTitle
public function getTitle($code) { if (!isset($this->titles[$code])) { $code = key($this->getTitles()); } return $this->titles[$code]; }
php
public function getTitle($code) { if (!isset($this->titles[$code])) { $code = key($this->getTitles()); } return $this->titles[$code]; }
[ "public", "function", "getTitle", "(", "$", "code", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "titles", "[", "$", "code", "]", ")", ")", "{", "$", "code", "=", "key", "(", "$", "this", "->", "getTitles", "(", ")", ")", ";", "...
Return localized title. @param string $code @return string
[ "Return", "localized", "title", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MediaType/Model/MediaType.php#L113-L120
train
Flowpack/Flowpack.SingleSignOn.Client
Classes/Flowpack/SingleSignOn/Client/Security/RequestSigner.php
RequestSigner.getSignatureContent
public function getSignatureContent(\TYPO3\Flow\Http\Request $httpRequest) { $date = $httpRequest->getHeader('Date'); $dateValue = $date instanceof \DateTime ? $date->format(DATE_RFC2822) : ''; $signData = $httpRequest->getMethod() . chr(10) . sha1($httpRequest->getContent()) . chr(10) . $httpRequest->getHeader('Content-Type') . chr(10) . $dateValue . chr(10) . $httpRequest->getUri(); return $signData; }
php
public function getSignatureContent(\TYPO3\Flow\Http\Request $httpRequest) { $date = $httpRequest->getHeader('Date'); $dateValue = $date instanceof \DateTime ? $date->format(DATE_RFC2822) : ''; $signData = $httpRequest->getMethod() . chr(10) . sha1($httpRequest->getContent()) . chr(10) . $httpRequest->getHeader('Content-Type') . chr(10) . $dateValue . chr(10) . $httpRequest->getUri(); return $signData; }
[ "public", "function", "getSignatureContent", "(", "\\", "TYPO3", "\\", "Flow", "\\", "Http", "\\", "Request", "$", "httpRequest", ")", "{", "$", "date", "=", "$", "httpRequest", "->", "getHeader", "(", "'Date'", ")", ";", "$", "dateValue", "=", "$", "dat...
Get the content for the signature from the given request @param \TYPO3\Flow\Http\Request $httpRequest @return string
[ "Get", "the", "content", "for", "the", "signature", "from", "the", "given", "request" ]
0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00
https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Security/RequestSigner.php#L43-L52
train
rseyferth/activerecord
lib/Model.php
Model.assignAttribute
public function assignAttribute($name, $value) { $table = static::table(); if (!is_object($value)) { if (array_key_exists($name, $table->columns)) { $value = $table->columns[$name]->cast($value, static::connection()); } else { $col = $table->getColumnByInflectedName($name); if (!is_null($col)){ $value = $col->cast($value, static::connection()); } } } // convert php's \DateTime to ours if ($value instanceof \DateTime) { $value = new DateTime($value->format('Y-m-d H:i:s T')); } // make sure DateTime values know what model they belong to so // dirty stuff works when calling set methods on the DateTime object if ($value instanceof DateTime) { $value->attributeOf($this, $name); } $this->_attributes[$name] = $value; $this->flagDirty($name); return $value; }
php
public function assignAttribute($name, $value) { $table = static::table(); if (!is_object($value)) { if (array_key_exists($name, $table->columns)) { $value = $table->columns[$name]->cast($value, static::connection()); } else { $col = $table->getColumnByInflectedName($name); if (!is_null($col)){ $value = $col->cast($value, static::connection()); } } } // convert php's \DateTime to ours if ($value instanceof \DateTime) { $value = new DateTime($value->format('Y-m-d H:i:s T')); } // make sure DateTime values know what model they belong to so // dirty stuff works when calling set methods on the DateTime object if ($value instanceof DateTime) { $value->attributeOf($this, $name); } $this->_attributes[$name] = $value; $this->flagDirty($name); return $value; }
[ "public", "function", "assignAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "$", "table", "=", "static", "::", "table", "(", ")", ";", "if", "(", "!", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "array_key_exists", "(", "$...
Assign a value to an attribute. @param string $name Name of the attribute @param mixed &$value Value of the attribute @return mixed the attribute value
[ "Assign", "a", "value", "to", "an", "attribute", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L462-L490
train
rseyferth/activerecord
lib/Model.php
Model.&
public function &readAttribute($name) { // check for aliased attribute if (array_key_exists($name, static::$aliasAttribute)) $name = static::$aliasAttribute[$name]; // check for attribute if (array_key_exists($name,$this->_attributes)) return $this->_attributes[$name]; // check relationships if no attribute if (array_key_exists($name,$this->_relationships)) return $this->_relationships[$name]; $table = static::table(); // this may be first access to the relationship so check Table if (($relationship = $table->getRelationship($name))) { $this->_relationships[$name] = $relationship->load($this); return $this->_relationships[$name]; } // Shortcut to get primary key if ($name == 'id') { $pk = $this->getPrimaryKey(true); if (isset($this->_attributes[$pk])) return $this->_attributes[$pk]; } //do not remove - have to return null by reference in strict mode $null = null; foreach (static::$delegate as &$item) { if (($delegated_name = $this->isDelegated($name, $item))) { $to = $item['to']; if ($this->$to) { $val =& $this->$to->__get($delegated_name); return $val; } else { return $null; } } } throw new UndefinedPropertyException(get_called_class(),$name); }
php
public function &readAttribute($name) { // check for aliased attribute if (array_key_exists($name, static::$aliasAttribute)) $name = static::$aliasAttribute[$name]; // check for attribute if (array_key_exists($name,$this->_attributes)) return $this->_attributes[$name]; // check relationships if no attribute if (array_key_exists($name,$this->_relationships)) return $this->_relationships[$name]; $table = static::table(); // this may be first access to the relationship so check Table if (($relationship = $table->getRelationship($name))) { $this->_relationships[$name] = $relationship->load($this); return $this->_relationships[$name]; } // Shortcut to get primary key if ($name == 'id') { $pk = $this->getPrimaryKey(true); if (isset($this->_attributes[$pk])) return $this->_attributes[$pk]; } //do not remove - have to return null by reference in strict mode $null = null; foreach (static::$delegate as &$item) { if (($delegated_name = $this->isDelegated($name, $item))) { $to = $item['to']; if ($this->$to) { $val =& $this->$to->__get($delegated_name); return $val; } else { return $null; } } } throw new UndefinedPropertyException(get_called_class(),$name); }
[ "public", "function", "&", "readAttribute", "(", "$", "name", ")", "{", "// check for aliased attribute", "if", "(", "array_key_exists", "(", "$", "name", ",", "static", "::", "$", "aliasAttribute", ")", ")", "$", "name", "=", "static", "::", "$", "aliasAttr...
Retrieves an attribute's value or a relationship object based on the name passed. If the attribute accessed is 'id' then it will return the model's primary key no matter what the actual attribute name is for the primary key. @param string $name Name of an attribute @return mixed The value of the attribute @throws {@link UndefinedPropertyException} if name could not be resolved to an attribute, relationship, ...
[ "Retrieves", "an", "attribute", "s", "value", "or", "a", "relationship", "object", "based", "on", "the", "name", "passed", ".", "If", "the", "attribute", "accessed", "is", "id", "then", "it", "will", "return", "the", "model", "s", "primary", "key", "no", ...
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L501-L544
train
rseyferth/activerecord
lib/Model.php
Model.hasAttribute
public function hasAttribute($attrName) { // In default attributes if (array_key_exists($attrName, $this->_attributes)) return true; // A getter available? if (method_exists($this, "__get_$attrName")) return true; return false; }
php
public function hasAttribute($attrName) { // In default attributes if (array_key_exists($attrName, $this->_attributes)) return true; // A getter available? if (method_exists($this, "__get_$attrName")) return true; return false; }
[ "public", "function", "hasAttribute", "(", "$", "attrName", ")", "{", "// In default attributes", "if", "(", "array_key_exists", "(", "$", "attrName", ",", "$", "this", "->", "_attributes", ")", ")", "return", "true", ";", "// A getter available?", "if", "(", ...
Check if given attribute exists @param string Attribute name @return boolean True or false
[ "Check", "if", "given", "attribute", "exists" ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L551-L563
train
rseyferth/activerecord
lib/Model.php
Model.flagDirty
public function flagDirty($name, $dirty = true) { if (!$this->_dirty) $this->_dirty = array(); if ($dirty) { $this->_dirty[$name] = true; } else { if (array_key_exists($name, $this->_dirty)) { unset($this->_dirty[$name]); } } }
php
public function flagDirty($name, $dirty = true) { if (!$this->_dirty) $this->_dirty = array(); if ($dirty) { $this->_dirty[$name] = true; } else { if (array_key_exists($name, $this->_dirty)) { unset($this->_dirty[$name]); } } }
[ "public", "function", "flagDirty", "(", "$", "name", ",", "$", "dirty", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "_dirty", ")", "$", "this", "->", "_dirty", "=", "array", "(", ")", ";", "if", "(", "$", "dirty", ")", "{", "$", ...
Flags an attribute as dirty. @param string $name Attribute name
[ "Flags", "an", "attribute", "as", "dirty", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L570-L580
train
rseyferth/activerecord
lib/Model.php
Model.dirtyAttributes
public function dirtyAttributes() { if (!$this->_dirty) return null; $dirty = array_intersect_key($this->_attributes, $this->_dirty); return !empty($dirty) ? $dirty : null; }
php
public function dirtyAttributes() { if (!$this->_dirty) return null; $dirty = array_intersect_key($this->_attributes, $this->_dirty); return !empty($dirty) ? $dirty : null; }
[ "public", "function", "dirtyAttributes", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_dirty", ")", "return", "null", ";", "$", "dirty", "=", "array_intersect_key", "(", "$", "this", "->", "_attributes", ",", "$", "this", "->", "_dirty", ")", ";"...
Returns hash of attributes that have been modified since loading the model. @return mixed null if no dirty attributes otherwise returns array of dirty attributes.
[ "Returns", "hash", "of", "attributes", "that", "have", "been", "modified", "since", "loading", "the", "model", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L587-L594
train
rseyferth/activerecord
lib/Model.php
Model.attributeIsDirty
public function attributeIsDirty($attribute) { return $this->_dirty && isset($this->_dirty[$attribute]) && array_key_exists($attribute, $this->_attributes); }
php
public function attributeIsDirty($attribute) { return $this->_dirty && isset($this->_dirty[$attribute]) && array_key_exists($attribute, $this->_attributes); }
[ "public", "function", "attributeIsDirty", "(", "$", "attribute", ")", "{", "return", "$", "this", "->", "_dirty", "&&", "isset", "(", "$", "this", "->", "_dirty", "[", "$", "attribute", "]", ")", "&&", "array_key_exists", "(", "$", "attribute", ",", "$",...
Check if a particular attribute has been modified since loading the model. @param string $attribute Name of the attribute @return boolean TRUE if it has been modified.
[ "Check", "if", "a", "particular", "attribute", "has", "been", "modified", "since", "loading", "the", "model", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L601-L604
train
rseyferth/activerecord
lib/Model.php
Model.create
public static function create($attributes, $validate = true, $guardAttributes=true) { // Get class and instantiate it $className = get_called_class(); $model = new $className($attributes, $guardAttributes); $model->save($validate); return $model; }
php
public static function create($attributes, $validate = true, $guardAttributes=true) { // Get class and instantiate it $className = get_called_class(); $model = new $className($attributes, $guardAttributes); $model->save($validate); return $model; }
[ "public", "static", "function", "create", "(", "$", "attributes", ",", "$", "validate", "=", "true", ",", "$", "guardAttributes", "=", "true", ")", "{", "// Get class and instantiate it", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "model", ...
Creates a model and saves it to the database. @param array $attributes Array of the models attributes @param boolean $validate True if the validators should be run @param boolean $guard_attributes Set to true to guard protected/non-accessible attributes @return Model
[ "Creates", "a", "model", "and", "saves", "it", "to", "the", "database", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L802-L809
train
rseyferth/activerecord
lib/Model.php
Model.insert
private function insert($validate = true) { $this->verifyNotReadonly('insert'); // Check if validation or beforeCreate returns false. if (($validate && !$this->_validate() || !$this->invokeCallback('beforeCreate',false))) { return false; } $table = static::table(); // Get dirty attributes, or when nothing is dirty we just take all atrributes if (!($attributes = $this->dirtyAttributes())) { $attributes = $this->_attributes; } $pk = $this->getPrimaryKey(true); $useSequence = false; if ($table->sequence && !isset($attributes[$pk])) { if (($conn = static::connection()) instanceof OciAdapter) { // terrible oracle makes us select the nextval first $attributes[$pk] = $conn->getNextSequenceValue($table->sequence); $table->insert($attributes); $this->_attributes[$pk] = $attributes[$pk]; } else { // unset pk that was set to null if (array_key_exists($pk, $attributes)) { unset($attributes[$pk]); } $table->insert($attributes, $pk, $table->sequence); $useSequence = true; } } else { // Simple insert $table->insert($attributes); } // if we've got an autoincrementing/sequenced pk set it // don't need this check until the day comes that we decide to support composite pks // if (count($pk) == 1) { $column = $table->getColumnByInflectedName($pk); if ($column->autoIncrement || $useSequence) { $this->_attributes[$pk] = static::connection()->insertId($table->sequence); } } $this->_newRecord = false; $this->invokeCallback('afterCreate', false); return true; }
php
private function insert($validate = true) { $this->verifyNotReadonly('insert'); // Check if validation or beforeCreate returns false. if (($validate && !$this->_validate() || !$this->invokeCallback('beforeCreate',false))) { return false; } $table = static::table(); // Get dirty attributes, or when nothing is dirty we just take all atrributes if (!($attributes = $this->dirtyAttributes())) { $attributes = $this->_attributes; } $pk = $this->getPrimaryKey(true); $useSequence = false; if ($table->sequence && !isset($attributes[$pk])) { if (($conn = static::connection()) instanceof OciAdapter) { // terrible oracle makes us select the nextval first $attributes[$pk] = $conn->getNextSequenceValue($table->sequence); $table->insert($attributes); $this->_attributes[$pk] = $attributes[$pk]; } else { // unset pk that was set to null if (array_key_exists($pk, $attributes)) { unset($attributes[$pk]); } $table->insert($attributes, $pk, $table->sequence); $useSequence = true; } } else { // Simple insert $table->insert($attributes); } // if we've got an autoincrementing/sequenced pk set it // don't need this check until the day comes that we decide to support composite pks // if (count($pk) == 1) { $column = $table->getColumnByInflectedName($pk); if ($column->autoIncrement || $useSequence) { $this->_attributes[$pk] = static::connection()->insertId($table->sequence); } } $this->_newRecord = false; $this->invokeCallback('afterCreate', false); return true; }
[ "private", "function", "insert", "(", "$", "validate", "=", "true", ")", "{", "$", "this", "->", "verifyNotReadonly", "(", "'insert'", ")", ";", "// Check if validation or beforeCreate returns false.", "if", "(", "(", "$", "validate", "&&", "!", "$", "this", "...
Issue an INSERT sql statement for this model's attribute. @see save @param boolean $validate Set to true or false depending on if you want the validators to run or not @return boolean True if the model was saved to the database otherwise false
[ "Issue", "an", "INSERT", "sql", "statement", "for", "this", "model", "s", "attribute", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L836-L895
train
rseyferth/activerecord
lib/Model.php
Model.update
private function update($validate = true) { $this->verifyNotReadonly('update'); // Valid record? if ($validate && !$this->_validate()) { return false; } // Anything to update? if ($this->isDirty()) { // Check my primary key $pk = $this->valuesForPk(); if (empty($pk)) { throw new ActiveRecordException("Cannot update, no primary key defined for: " . get_called_class()); } // Check callback if (!$this->invokeCallback('beforeUpdate',false)) { return false; } // Do the update $dirty = $this->dirtyAttributes(); static::table()->update($dirty, $pk); $this->invokeCallback('afterUpdate',false); } return true; }
php
private function update($validate = true) { $this->verifyNotReadonly('update'); // Valid record? if ($validate && !$this->_validate()) { return false; } // Anything to update? if ($this->isDirty()) { // Check my primary key $pk = $this->valuesForPk(); if (empty($pk)) { throw new ActiveRecordException("Cannot update, no primary key defined for: " . get_called_class()); } // Check callback if (!$this->invokeCallback('beforeUpdate',false)) { return false; } // Do the update $dirty = $this->dirtyAttributes(); static::table()->update($dirty, $pk); $this->invokeCallback('afterUpdate',false); } return true; }
[ "private", "function", "update", "(", "$", "validate", "=", "true", ")", "{", "$", "this", "->", "verifyNotReadonly", "(", "'update'", ")", ";", "// Valid record?", "if", "(", "$", "validate", "&&", "!", "$", "this", "->", "_validate", "(", ")", ")", "...
Issue an UPDATE sql statement for this model's dirty attributes. @see save @param boolean $validate Set to true or false depending on if you want the validators to run or not @return boolean True if the model was saved to the database otherwise false
[ "Issue", "an", "UPDATE", "sql", "statement", "for", "this", "model", "s", "dirty", "attributes", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L904-L934
train
rseyferth/activerecord
lib/Model.php
Model.delete
public function delete() { $this->verifyNotReadonly('delete'); $pk = $this->valuesForPk(); if (empty($pk)) throw new ActiveRecordException("Cannot delete, no primary key defined for: " . get_called_class()); if (!$this->invokeCallback('beforeDestroy',false)) return false; static::table()->delete($pk); $this->invokeCallback('afterDestroy',false); return true; }
php
public function delete() { $this->verifyNotReadonly('delete'); $pk = $this->valuesForPk(); if (empty($pk)) throw new ActiveRecordException("Cannot delete, no primary key defined for: " . get_called_class()); if (!$this->invokeCallback('beforeDestroy',false)) return false; static::table()->delete($pk); $this->invokeCallback('afterDestroy',false); return true; }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "verifyNotReadonly", "(", "'delete'", ")", ";", "$", "pk", "=", "$", "this", "->", "valuesForPk", "(", ")", ";", "if", "(", "empty", "(", "$", "pk", ")", ")", "throw", "new", "Active...
Deletes this model from the database and returns true if successful. @return boolean
[ "Deletes", "this", "model", "from", "the", "database", "and", "returns", "true", "if", "successful", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1062-L1078
train
rseyferth/activerecord
lib/Model.php
Model.valuesFor
public function valuesFor($attributeNames) { $filter = array(); foreach ($attributeNames as $name) $filter[$name] = $this->$name; return $filter; }
php
public function valuesFor($attributeNames) { $filter = array(); foreach ($attributeNames as $name) $filter[$name] = $this->$name; return $filter; }
[ "public", "function", "valuesFor", "(", "$", "attributeNames", ")", "{", "$", "filter", "=", "array", "(", ")", ";", "foreach", "(", "$", "attributeNames", "as", "$", "name", ")", "$", "filter", "[", "$", "name", "]", "=", "$", "this", "->", "$", "...
Helper to return a hash of values for the specified attributes. @param array $attribute_names Array of attribute names @return array An array in the form array(name => value, ...)
[ "Helper", "to", "return", "a", "hash", "of", "values", "for", "the", "specified", "attributes", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1096-L1104
train
rseyferth/activerecord
lib/Model.php
Model._validate
protected function _validate() { // Check if validation is necessary and parsed if (static::$validates === false) return true; if (is_null(static::$_validation)) { require_once("Validation/Validation.php"); static::$_validation = Validation\Validation::onModel(get_called_class()); } // Go validate! $result = static::$_validation->validate($this); // Success? if ($result->success == false) { // Store errors $this->_errors = $result->errors; return false; } else { // Clear errors $this->_errors = null; } // True return true; }
php
protected function _validate() { // Check if validation is necessary and parsed if (static::$validates === false) return true; if (is_null(static::$_validation)) { require_once("Validation/Validation.php"); static::$_validation = Validation\Validation::onModel(get_called_class()); } // Go validate! $result = static::$_validation->validate($this); // Success? if ($result->success == false) { // Store errors $this->_errors = $result->errors; return false; } else { // Clear errors $this->_errors = null; } // True return true; }
[ "protected", "function", "_validate", "(", ")", "{", "// Check if validation is necessary and parsed", "if", "(", "static", "::", "$", "validates", "===", "false", ")", "return", "true", ";", "if", "(", "is_null", "(", "static", "::", "$", "_validation", ")", ...
Validates the model. @return boolean True if passed validators otherwise false
[ "Validates", "the", "model", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1111-L1142
train
rseyferth/activerecord
lib/Model.php
Model.setTimestamps
public function setTimestamps() { $now = date('Y-m-d H:i:s'); if (isset($this->updated_at)) $this->updated_at = $now; if (isset($this->created_at) && $this->isNewRecord()) $this->created_at = $now; }
php
public function setTimestamps() { $now = date('Y-m-d H:i:s'); if (isset($this->updated_at)) $this->updated_at = $now; if (isset($this->created_at) && $this->isNewRecord()) $this->created_at = $now; }
[ "public", "function", "setTimestamps", "(", ")", "{", "$", "now", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "updated_at", ")", ")", "$", "this", "->", "updated_at", "=", "$", "now", ";", "if", "(", "is...
Updates a model's timestamps.
[ "Updates", "a", "model", "s", "timestamps", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1189-L1198
train
rseyferth/activerecord
lib/Model.php
Model.updateAttribute
public function updateAttribute($name, $value) { $this->__set($name, $value); return $this->update(false); }
php
public function updateAttribute($name, $value) { $this->__set($name, $value); return $this->update(false); }
[ "public", "function", "updateAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "__set", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", "->", "update", "(", "false", ")", ";", "}" ]
Updates a single attribute and saves the record without going through the normal validation procedure. @param string $name Name of attribute @param mixed $value Value of the attribute @return boolean True if successful otherwise false
[ "Updates", "a", "single", "attribute", "and", "saves", "the", "record", "without", "going", "through", "the", "normal", "validation", "procedure", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1219-L1223
train
rseyferth/activerecord
lib/Model.php
Model.reload
public function reload() { $this->_relationships = array(); $pk = array_values($this->getValuesFor($this->getPrimaryKey())); $this->setAttributesViaMassAssignment($this->find($pk)->attributes, false); $this->resetDirty(); return $this; }
php
public function reload() { $this->_relationships = array(); $pk = array_values($this->getValuesFor($this->getPrimaryKey())); $this->setAttributesViaMassAssignment($this->find($pk)->attributes, false); $this->resetDirty(); return $this; }
[ "public", "function", "reload", "(", ")", "{", "$", "this", "->", "_relationships", "=", "array", "(", ")", ";", "$", "pk", "=", "array_values", "(", "$", "this", "->", "getValuesFor", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ")", ")", ";",...
Reloads the attributes and relationships of this object from the database. @return Model
[ "Reloads", "the", "attributes", "and", "relationships", "of", "this", "object", "from", "the", "database", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1324-L1333
train
rseyferth/activerecord
lib/Model.php
Model.count
public static function count(/* ... */) { $args = func_get_args(); $options = static::extractAndValidateOptions($args); $options['select'] = 'COUNT(*)'; if (!empty($args) && !is_null($args[0]) && !empty($args[0])) { if (is_hash($args[0])) $options['conditions'] = $args[0]; else $options['conditions'] = call_user_func_array('static::pk_conditions',$args); } $table = static::table(); $sql = $table->options_to_sql($options); $values = $sql->get_where_values(); return static::connection()->query_and_fetch_one($sql->to_s(),$values); }
php
public static function count(/* ... */) { $args = func_get_args(); $options = static::extractAndValidateOptions($args); $options['select'] = 'COUNT(*)'; if (!empty($args) && !is_null($args[0]) && !empty($args[0])) { if (is_hash($args[0])) $options['conditions'] = $args[0]; else $options['conditions'] = call_user_func_array('static::pk_conditions',$args); } $table = static::table(); $sql = $table->options_to_sql($options); $values = $sql->get_where_values(); return static::connection()->query_and_fetch_one($sql->to_s(),$values); }
[ "public", "static", "function", "count", "(", "/* ... */", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "options", "=", "static", "::", "extractAndValidateOptions", "(", "$", "args", ")", ";", "$", "options", "[", "'select'", "]", "="...
Get a count of qualifying records. <code> YourModel::count(array('conditions' => 'amount > 3.14159265')); </code> @see find @return int Number of records that matched the query
[ "Get", "a", "count", "of", "qualifying", "records", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1499-L1517
train
rseyferth/activerecord
lib/Model.php
Model.find
public static function find(/* $type, $options */) { $class = get_called_class(); if (func_num_args() <= 0) throw new RecordNotFound("Couldn't find $class without an ID"); $args = func_get_args(); $options = static::extractAndValidateOptions($args); $num_args = count($args); $single = true; if ($num_args > 0 && ($args[0] === 'all' || $args[0] === 'first' || $args[0] === 'last')) { switch ($args[0]) { case 'all': $single = false; break; case 'last': if (!array_key_exists('order',$options)) $options['order'] = join(' DESC, ', static::table()->pk) . ' DESC'; else $options['order'] = SQLBuilder::reverseOrder($options['order']); // fall thru case 'first': $options['limit'] = 1; $options['offset'] = 0; break; } $args = array_slice($args,1); $num_args--; } //find by pk elseif (1 === count($args) && 1 == $num_args) $args = $args[0]; // anything left in $args is a find by pk if ($num_args > 0 && !isset($options['conditions'])) return static::findByPk($args, $options); $options['mappedNames'] = static::$aliasAttribute; $list = static::table()->find($options); return $single ? (!empty($list) ? $list[0] : null) : $list; }
php
public static function find(/* $type, $options */) { $class = get_called_class(); if (func_num_args() <= 0) throw new RecordNotFound("Couldn't find $class without an ID"); $args = func_get_args(); $options = static::extractAndValidateOptions($args); $num_args = count($args); $single = true; if ($num_args > 0 && ($args[0] === 'all' || $args[0] === 'first' || $args[0] === 'last')) { switch ($args[0]) { case 'all': $single = false; break; case 'last': if (!array_key_exists('order',$options)) $options['order'] = join(' DESC, ', static::table()->pk) . ' DESC'; else $options['order'] = SQLBuilder::reverseOrder($options['order']); // fall thru case 'first': $options['limit'] = 1; $options['offset'] = 0; break; } $args = array_slice($args,1); $num_args--; } //find by pk elseif (1 === count($args) && 1 == $num_args) $args = $args[0]; // anything left in $args is a find by pk if ($num_args > 0 && !isset($options['conditions'])) return static::findByPk($args, $options); $options['mappedNames'] = static::$aliasAttribute; $list = static::table()->find($options); return $single ? (!empty($list) ? $list[0] : null) : $list; }
[ "public", "static", "function", "find", "(", "/* $type, $options */", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "func_num_args", "(", ")", "<=", "0", ")", "throw", "new", "RecordNotFound", "(", "\"Couldn't find $class without an ...
Find records in the database. Finding by the primary key: <code> # queries for the model with id=123 YourModel::find(123); # queries for model with id in(1,2,3) YourModel::find(1,2,3); # finding by pk accepts an options array YourModel::find(123,array('order' => 'name desc')); </code> Finding by using a conditions array: <code> YourModel::find('first', array('conditions' => array('name=?','Tito'), 'order' => 'name asc')) YourModel::find('all', array('conditions' => 'amount > 3.14159265')); YourModel::find('all', array('conditions' => array('id in(?)', array(1,2,3)))); </code> Finding by using a hash: <code> YourModel::find(array('name' => 'Tito', 'id' => 1)); YourModel::find('first',array('name' => 'Tito', 'id' => 1)); YourModel::find('all',array('name' => 'Tito', 'id' => 1)); </code> An options array can take the following parameters: <ul> <li><b>select:</b> A SQL fragment for what fields to return such as: '*', 'people.*', 'first_name, last_name, id'</li> <li><b>joins:</b> A SQL join fragment such as: 'JOIN roles ON(roles.user_id=user.id)' or a named association on the model</li> <li><b>include:</b> TODO not implemented yet</li> <li><b>conditions:</b> A SQL fragment such as: 'id=1', array('id=1'), array('name=? and id=?','Tito',1), array('name IN(?)', array('Tito','Bob')), array('name' => 'Tito', 'id' => 1)</li> <li><b>limit:</b> Number of records to limit the query to</li> <li><b>offset:</b> The row offset to return results from for the query</li> <li><b>order:</b> A SQL fragment for order such as: 'name asc', 'name asc, id desc'</li> <li><b>readonly:</b> Return all the models in readonly mode</li> <li><b>group:</b> A SQL group by fragment</li> </ul> @throws {@link RecordNotFound} if no options are passed or finding by pk and no records matched @return mixed An array of records found if doing a find_all otherwise a single Model object or null if it wasn't found. NULL is only return when doing a first/last find. If doing an all find and no records matched this will return an empty array.
[ "Find", "records", "in", "the", "database", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1612-L1661
train
rseyferth/activerecord
lib/Model.php
Model.findByPk
public static function findByPk($values, $options) { $options['conditions'] = static::pkConditions($values); $list = static::table()->find($options); $results = count($list); if ($results != ($expected = count($values))) { $class = get_called_class(); if ($expected == 1) { if (!is_array($values)) $values = array($values); throw new RecordNotFound("Couldn't find $class with ID=" . join(',',$values)); } $values = join(',',$values); throw new RecordNotFound("Couldn't find all $class with IDs ($values) (found $results, but was looking for $expected)"); } return $expected == 1 ? $list[0] : $list; }
php
public static function findByPk($values, $options) { $options['conditions'] = static::pkConditions($values); $list = static::table()->find($options); $results = count($list); if ($results != ($expected = count($values))) { $class = get_called_class(); if ($expected == 1) { if (!is_array($values)) $values = array($values); throw new RecordNotFound("Couldn't find $class with ID=" . join(',',$values)); } $values = join(',',$values); throw new RecordNotFound("Couldn't find all $class with IDs ($values) (found $results, but was looking for $expected)"); } return $expected == 1 ? $list[0] : $list; }
[ "public", "static", "function", "findByPk", "(", "$", "values", ",", "$", "options", ")", "{", "$", "options", "[", "'conditions'", "]", "=", "static", "::", "pkConditions", "(", "$", "values", ")", ";", "$", "list", "=", "static", "::", "table", "(", ...
Finder method which will find by a single or array of primary keys for this model. @see find @param array $values An array containing values for the pk @param array $options An options array @return Model @throws {@link RecordNotFound} if a record could not be found
[ "Finder", "method", "which", "will", "find", "by", "a", "single", "or", "array", "of", "primary", "keys", "for", "this", "model", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1672-L1694
train
rseyferth/activerecord
lib/Model.php
Model.isOptionsHash
public static function isOptionsHash($array, $throw = true) { if (Arry::isHash($array)) { $keys = array_keys($array); $diff = array_diff($keys,self::$validOptions); if (!empty($diff) && $throw) { throw new ActiveRecordException("Unknown key(s): " . join(', ',$diff)); } $intersect = array_intersect($keys,self::$validOptions); if (!empty($intersect)) { return true; } } return false; }
php
public static function isOptionsHash($array, $throw = true) { if (Arry::isHash($array)) { $keys = array_keys($array); $diff = array_diff($keys,self::$validOptions); if (!empty($diff) && $throw) { throw new ActiveRecordException("Unknown key(s): " . join(', ',$diff)); } $intersect = array_intersect($keys,self::$validOptions); if (!empty($intersect)) { return true; } } return false; }
[ "public", "static", "function", "isOptionsHash", "(", "$", "array", ",", "$", "throw", "=", "true", ")", "{", "if", "(", "Arry", "::", "isHash", "(", "$", "array", ")", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "array", ")", ";", "$", "...
Determines if the specified array is a valid ActiveRecord options array. @param array $array An options array @param bool $throw True to throw an exception if not valid @return boolean True if valid otherwise valse @throws {@link ActiveRecordException} if the array contained any invalid options
[ "Determines", "if", "the", "specified", "array", "is", "a", "valid", "ActiveRecord", "options", "array", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1733-L1751
train
rseyferth/activerecord
lib/Model.php
Model.invokeCallback
private function invokeCallback($method_name, $must_exist=true) { return static::table()->callback->invoke($this,$method_name,$must_exist); }
php
private function invokeCallback($method_name, $must_exist=true) { return static::table()->callback->invoke($this,$method_name,$must_exist); }
[ "private", "function", "invokeCallback", "(", "$", "method_name", ",", "$", "must_exist", "=", "true", ")", "{", "return", "static", "::", "table", "(", ")", "->", "callback", "->", "invoke", "(", "$", "this", ",", "$", "method_name", ",", "$", "must_exi...
Invokes the specified callback on this model. @param string $method_name Name of the call back to run. @param boolean $must_exist Set to true to raise an exception if the callback does not exist. @return boolean True if invoked or null if not
[ "Invokes", "the", "specified", "callback", "on", "this", "model", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1913-L1916
train
rseyferth/activerecord
lib/Model.php
Model.transaction
public static function transaction($closure) { $connection = static::connection(); try { $connection->transaction(); if ($closure() === false) { $connection->rollback(); return false; } else $connection->commit(); } catch (\Exception $e) { $connection->rollback(); throw $e; } return true; }
php
public static function transaction($closure) { $connection = static::connection(); try { $connection->transaction(); if ($closure() === false) { $connection->rollback(); return false; } else $connection->commit(); } catch (\Exception $e) { $connection->rollback(); throw $e; } return true; }
[ "public", "static", "function", "transaction", "(", "$", "closure", ")", "{", "$", "connection", "=", "static", "::", "connection", "(", ")", ";", "try", "{", "$", "connection", "->", "transaction", "(", ")", ";", "if", "(", "$", "closure", "(", ")", ...
Executes a block of code inside a database transaction. <code> YourModel::transaction(function() { YourModel::create(array("name" => "blah")); }); </code> If an exception is thrown inside the closure the transaction will automatically be rolled back. You can also return false from your closure to cause a rollback: <code> YourModel::transaction(function() { YourModel::create(array("name" => "blah")); throw new Exception("rollback!"); }); YourModel::transaction(function() { YourModel::create(array("name" => "blah")); return false; # rollback! }); </code> @param Closure $closure The closure to execute. To cause a rollback have your closure return false or throw an exception. @return boolean True if the transaction was committed, False if rolled back.
[ "Executes", "a", "block", "of", "code", "inside", "a", "database", "transaction", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1949-L1971
train
xloit/xloit-bridge-zend-mvc
src/Controller/Plugin/FlashData.php
FlashData.isFromRoute
public function isFromRoute($routeName) { $session = $this->getSession(); /** @noinspection PhpUndefinedFieldInspection */ if ($session->data === null || !is_array($session->source)) { return null; } /** @noinspection PhpUndefinedFieldInspection */ return $session->source['routeName'] === $routeName; }
php
public function isFromRoute($routeName) { $session = $this->getSession(); /** @noinspection PhpUndefinedFieldInspection */ if ($session->data === null || !is_array($session->source)) { return null; } /** @noinspection PhpUndefinedFieldInspection */ return $session->source['routeName'] === $routeName; }
[ "public", "function", "isFromRoute", "(", "$", "routeName", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "/** @noinspection PhpUndefinedFieldInspection */", "if", "(", "$", "session", "->", "data", "===", "null", "||", "!", ...
Indicates whether current data from the specified route name. @param string $routeName @return bool @throws \Zend\Session\Exception\InvalidArgumentException
[ "Indicates", "whether", "current", "data", "from", "the", "specified", "route", "name", "." ]
9991dc46f0b4b8831289ededc8ff0edaacffadd5
https://github.com/xloit/xloit-bridge-zend-mvc/blob/9991dc46f0b4b8831289ededc8ff0edaacffadd5/src/Controller/Plugin/FlashData.php#L152-L163
train
xloit/xloit-bridge-zend-mvc
src/Controller/Plugin/FlashData.php
FlashData.removeData
public function removeData() { $session = $this->getSession(); /** @noinspection PhpUndefinedFieldInspection */ if ($session->data !== null) { unset($session->data); return true; } return false; }
php
public function removeData() { $session = $this->getSession(); /** @noinspection PhpUndefinedFieldInspection */ if ($session->data !== null) { unset($session->data); return true; } return false; }
[ "public", "function", "removeData", "(", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "/** @noinspection PhpUndefinedFieldInspection */", "if", "(", "$", "session", "->", "data", "!==", "null", ")", "{", "unset", "(", "$", ...
Remove current route data. @return bool @throws \Zend\Session\Exception\InvalidArgumentException
[ "Remove", "current", "route", "data", "." ]
9991dc46f0b4b8831289ededc8ff0edaacffadd5
https://github.com/xloit/xloit-bridge-zend-mvc/blob/9991dc46f0b4b8831289ededc8ff0edaacffadd5/src/Controller/Plugin/FlashData.php#L199-L211
train
simple-php-mvc/installer-module
src/InstallerModule/Generator/DBALGenerator.php
DBALGenerator.generate
public function generate(Module $module, $modelName, array $arrayValues) { $modelClass = $module->getNamespace() . '\\Model\\' . $modelName; $modelPath = $module->getPath() . '/Model/' . str_replace('\\', '/', $modelName) . '.php'; $modelCode = $this->generateCode($module, $modelName, $arrayValues); if (file_exists($modelPath)) { throw new \RuntimeException(sprintf('Model "%s" already exists.', $modelClass)); } $this->explorer->mkdir(dirname($modelPath)); file_put_contents($modelPath, $modelCode); }
php
public function generate(Module $module, $modelName, array $arrayValues) { $modelClass = $module->getNamespace() . '\\Model\\' . $modelName; $modelPath = $module->getPath() . '/Model/' . str_replace('\\', '/', $modelName) . '.php'; $modelCode = $this->generateCode($module, $modelName, $arrayValues); if (file_exists($modelPath)) { throw new \RuntimeException(sprintf('Model "%s" already exists.', $modelClass)); } $this->explorer->mkdir(dirname($modelPath)); file_put_contents($modelPath, $modelCode); }
[ "public", "function", "generate", "(", "Module", "$", "module", ",", "$", "modelName", ",", "array", "$", "arrayValues", ")", "{", "$", "modelClass", "=", "$", "module", "->", "getNamespace", "(", ")", ".", "'\\\\Model\\\\'", ".", "$", "modelName", ";", ...
Generate PDO Model @param Module $module @param string $modelName @param array $arrayValues
[ "Generate", "PDO", "Model" ]
62bd5bac05418b5f712dfcead1edc75ef14d60e3
https://github.com/simple-php-mvc/installer-module/blob/62bd5bac05418b5f712dfcead1edc75ef14d60e3/src/InstallerModule/Generator/DBALGenerator.php#L58-L71
train
simple-php-mvc/installer-module
src/InstallerModule/Generator/DBALGenerator.php
DBALGenerator.generateCode
protected function generateCode(Module $module, $modelName, $arrayValues) { $replaces = array( '<namespace>' => 'namespace ' . $module->getNamespace() . '\\Model;', '<modelAnnotation>' => $this->generateDocBlock($modelName), '<modelClassName>' => $modelName, '<construct>' => self::$constructorMethodTemplate, '<modelBody>' => $this->generateBody($modelName, $arrayValues), '<spaces>' => " ", '<table>' => strtolower($modelName) ); $classTemplate = str_replace(array_keys($replaces), array_values($replaces), self::$classTemplate); return $classTemplate; }
php
protected function generateCode(Module $module, $modelName, $arrayValues) { $replaces = array( '<namespace>' => 'namespace ' . $module->getNamespace() . '\\Model;', '<modelAnnotation>' => $this->generateDocBlock($modelName), '<modelClassName>' => $modelName, '<construct>' => self::$constructorMethodTemplate, '<modelBody>' => $this->generateBody($modelName, $arrayValues), '<spaces>' => " ", '<table>' => strtolower($modelName) ); $classTemplate = str_replace(array_keys($replaces), array_values($replaces), self::$classTemplate); return $classTemplate; }
[ "protected", "function", "generateCode", "(", "Module", "$", "module", ",", "$", "modelName", ",", "$", "arrayValues", ")", "{", "$", "replaces", "=", "array", "(", "'<namespace>'", "=>", "'namespace '", ".", "$", "module", "->", "getNamespace", "(", ")", ...
Generate model class code @param Module $module @param string $modelName @param array $arrayValues @return string
[ "Generate", "model", "class", "code" ]
62bd5bac05418b5f712dfcead1edc75ef14d60e3
https://github.com/simple-php-mvc/installer-module/blob/62bd5bac05418b5f712dfcead1edc75ef14d60e3/src/InstallerModule/Generator/DBALGenerator.php#L81-L94
train
samurai-fw/samurai
src/Samurai/Component/Migration/Phinx/Helper.php
Helper.fileNameStrategy
public function fileNameStrategy($database, $name) { $name = join('_', array_map('lcfirst', preg_split('/(?=[A-Z])/', $name))); return $database . DS . $this->generateVersion() . $name . '.php'; }
php
public function fileNameStrategy($database, $name) { $name = join('_', array_map('lcfirst', preg_split('/(?=[A-Z])/', $name))); return $database . DS . $this->generateVersion() . $name . '.php'; }
[ "public", "function", "fileNameStrategy", "(", "$", "database", ",", "$", "name", ")", "{", "$", "name", "=", "join", "(", "'_'", ",", "array_map", "(", "'lcfirst'", ",", "preg_split", "(", "'/(?=[A-Z])/'", ",", "$", "name", ")", ")", ")", ";", "return...
migration file name adjusting add version prefix (YmdHis + index) @param string $database @param string $name @return string
[ "migration", "file", "name", "adjusting" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Migration/Phinx/Helper.php#L72-L76
train
jmpantoja/planb-utils
src/Beautifier/Template/Token.php
Token.style
public function style(): Style { $type = StyleType::get($this->style); return StyleFactory::factory($type) ->lineWidth($this->lineWidth); }
php
public function style(): Style { $type = StyleType::get($this->style); return StyleFactory::factory($type) ->lineWidth($this->lineWidth); }
[ "public", "function", "style", "(", ")", ":", "Style", "{", "$", "type", "=", "StyleType", "::", "get", "(", "$", "this", "->", "style", ")", ";", "return", "StyleFactory", "::", "factory", "(", "$", "type", ")", "->", "lineWidth", "(", "$", "this", ...
Devuelve el estilo @return \PlanB\Beautifier\Style\Style
[ "Devuelve", "el", "estilo" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Token.php#L100-L106
train
jmpantoja/planb-utils
src/Beautifier/Template/Token.php
Token.value
public function value(): ?string { if (is_empty($this->key)) { return $this->original; } $value = $this->replacements->get($this->key, null); return $this->convertToString($value); }
php
public function value(): ?string { if (is_empty($this->key)) { return $this->original; } $value = $this->replacements->get($this->key, null); return $this->convertToString($value); }
[ "public", "function", "value", "(", ")", ":", "?", "string", "{", "if", "(", "is_empty", "(", "$", "this", "->", "key", ")", ")", "{", "return", "$", "this", "->", "original", ";", "}", "$", "value", "=", "$", "this", "->", "replacements", "->", ...
Devuelve el valor @return null|string
[ "Devuelve", "el", "valor" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Token.php#L113-L122
train
jmpantoja/planb-utils
src/Beautifier/Template/Token.php
Token.width
public function width(): int { $lines = explode("\n", $this->value()); $width = []; foreach ($lines as $line) { $raw = strip_tags($line); $width[] = strlen(trim($raw)); } return max($width); }
php
public function width(): int { $lines = explode("\n", $this->value()); $width = []; foreach ($lines as $line) { $raw = strip_tags($line); $width[] = strlen(trim($raw)); } return max($width); }
[ "public", "function", "width", "(", ")", ":", "int", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "value", "(", ")", ")", ";", "$", "width", "=", "[", "]", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")",...
Devuelve el ancho del token @return int
[ "Devuelve", "el", "ancho", "del", "token" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Token.php#L143-L154
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setUserId
public function setUserId( $userId ) { $this->_user = null; $this->userId = ( (int) $userId ) ?: null; return $this; }
php
public function setUserId( $userId ) { $this->_user = null; $this->userId = ( (int) $userId ) ?: null; return $this; }
[ "public", "function", "setUserId", "(", "$", "userId", ")", "{", "$", "this", "->", "_user", "=", "null", ";", "$", "this", "->", "userId", "=", "(", "(", "int", ")", "$", "userId", ")", "?", ":", "null", ";", "return", "$", "this", ";", "}" ]
Set user-id @param int $userId @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "user", "-", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L294-L299
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.getUserMapper
protected function getUserMapper() { if ( null === $this->_userMapper ) { $mapper = $this->getMapper(); $this->_userMapper = $this->getServiceLocator() ->get( 'Di' ) ->get( 'Grid\User\Model\User\Mapper', array( 'dbAdapter' => $mapper->getDbAdapter(), 'dbSchema' => $mapper->getDbSchema(), ) ); } return $this->_userMapper; }
php
protected function getUserMapper() { if ( null === $this->_userMapper ) { $mapper = $this->getMapper(); $this->_userMapper = $this->getServiceLocator() ->get( 'Di' ) ->get( 'Grid\User\Model\User\Mapper', array( 'dbAdapter' => $mapper->getDbAdapter(), 'dbSchema' => $mapper->getDbSchema(), ) ); } return $this->_userMapper; }
[ "protected", "function", "getUserMapper", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "_userMapper", ")", "{", "$", "mapper", "=", "$", "this", "->", "getMapper", "(", ")", ";", "$", "this", "->", "_userMapper", "=", "$", "this", "->"...
Get user mapper @return \Grid\User\Model\User\Mapper
[ "Get", "user", "mapper" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L306-L321
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setPublishedFrom
public function setPublishedFrom( $date, $format = null ) { $this->publishedFrom = empty( $date ) ? null : $this->inputDate( $date, $format ); return $this; }
php
public function setPublishedFrom( $date, $format = null ) { $this->publishedFrom = empty( $date ) ? null : $this->inputDate( $date, $format ); return $this; }
[ "public", "function", "setPublishedFrom", "(", "$", "date", ",", "$", "format", "=", "null", ")", "{", "$", "this", "->", "publishedFrom", "=", "empty", "(", "$", "date", ")", "?", "null", ":", "$", "this", "->", "inputDate", "(", "$", "date", ",", ...
Set published-from date @param \DateTime|string $date @param string|null $format @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "published", "-", "from", "date" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L453-L457
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setPublishedTo
public function setPublishedTo( $date, $format = null ) { $this->publishedTo = empty( $date ) ? null : $this->inputDate( $date, $format ); return $this; }
php
public function setPublishedTo( $date, $format = null ) { $this->publishedTo = empty( $date ) ? null : $this->inputDate( $date, $format ); return $this; }
[ "public", "function", "setPublishedTo", "(", "$", "date", ",", "$", "format", "=", "null", ")", "{", "$", "this", "->", "publishedTo", "=", "empty", "(", "$", "date", ")", "?", "null", ":", "$", "this", "->", "inputDate", "(", "$", "date", ",", "$"...
Set published-to date @param \DateTime|string $date @param string|null $format @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "published", "-", "to", "date" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L466-L470
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.isPublished
public function isPublished( $now = null ) { if ( ! $this->published ) { return false; } if ( empty( $now ) ) { $now = new DateTime(); } else { $now = $this->inputDate( $now ); } if ( ! empty( $this->publishedTo ) && ! $this->publishedTo->diff( $now )->invert ) { return false; } if ( ! empty( $this->publishedFrom ) && $this->publishedFrom->diff( $now )->invert ) { return false; } return true; }
php
public function isPublished( $now = null ) { if ( ! $this->published ) { return false; } if ( empty( $now ) ) { $now = new DateTime(); } else { $now = $this->inputDate( $now ); } if ( ! empty( $this->publishedTo ) && ! $this->publishedTo->diff( $now )->invert ) { return false; } if ( ! empty( $this->publishedFrom ) && $this->publishedFrom->diff( $now )->invert ) { return false; } return true; }
[ "public", "function", "isPublished", "(", "$", "now", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "published", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "now", ")", ")", "{", "$", "now", "=", "new", "Dat...
Is published at a given time point @param int|string|\DateTime $now default: null @return bool
[ "Is", "published", "at", "a", "given", "time", "point" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L478-L507
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setAccessUsers
public function setAccessUsers( $users ) { $this->accessUsers = array_unique( is_array( $users ) ? $users : preg_split( '/[,\s]+/', $users ) ); return $this; }
php
public function setAccessUsers( $users ) { $this->accessUsers = array_unique( is_array( $users ) ? $users : preg_split( '/[,\s]+/', $users ) ); return $this; }
[ "public", "function", "setAccessUsers", "(", "$", "users", ")", "{", "$", "this", "->", "accessUsers", "=", "array_unique", "(", "is_array", "(", "$", "users", ")", "?", "$", "users", ":", "preg_split", "(", "'/[,\\s]+/'", ",", "$", "users", ")", ")", ...
Set access users @param array|string $users @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "access", "users" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L527-L534
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setAccessGroups
public function setAccessGroups( $groups ) { $this->accessGroups = array_unique( is_array( $groups ) ? $groups : preg_split( '/[,\s]+/', $groups ) ); return $this; }
php
public function setAccessGroups( $groups ) { $this->accessGroups = array_unique( is_array( $groups ) ? $groups : preg_split( '/[,\s]+/', $groups ) ); return $this; }
[ "public", "function", "setAccessGroups", "(", "$", "groups", ")", "{", "$", "this", "->", "accessGroups", "=", "array_unique", "(", "is_array", "(", "$", "groups", ")", "?", "$", "groups", ":", "preg_split", "(", "'/[,\\s]+/'", ",", "$", "groups", ")", "...
Set access groups @param array|string $groups @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "access", "groups" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L542-L549
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setEditUsers
public function setEditUsers( $users ) { $this->editUsers = array_unique( is_array( $users ) ? $users : preg_split( '/[,\s]+/', $users ) ); return $this; }
php
public function setEditUsers( $users ) { $this->editUsers = array_unique( is_array( $users ) ? $users : preg_split( '/[,\s]+/', $users ) ); return $this; }
[ "public", "function", "setEditUsers", "(", "$", "users", ")", "{", "$", "this", "->", "editUsers", "=", "array_unique", "(", "is_array", "(", "$", "users", ")", "?", "$", "users", ":", "preg_split", "(", "'/[,\\s]+/'", ",", "$", "users", ")", ")", ";",...
Set edit users @param array|string $users @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "edit", "users" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L557-L564
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.setEditGroups
public function setEditGroups( $groups ) { $this->editGroups = array_unique( is_array( $groups ) ? $groups : preg_split( '/[,\s]+/', $groups ) ); return $this; }
php
public function setEditGroups( $groups ) { $this->editGroups = array_unique( is_array( $groups ) ? $groups : preg_split( '/[,\s]+/', $groups ) ); return $this; }
[ "public", "function", "setEditGroups", "(", "$", "groups", ")", "{", "$", "this", "->", "editGroups", "=", "array_unique", "(", "is_array", "(", "$", "groups", ")", "?", "$", "groups", ":", "preg_split", "(", "'/[,\\s]+/'", ",", "$", "groups", ")", ")", ...
Set edit groups @param array|string $groups @return \Grid\Paragraph\Model\Paragraph\Structure\Content
[ "Set", "edit", "groups" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L572-L579
train
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php
Content.getSeoUri
public function getSeoUri() { if ( ! empty( $this->_seoUri ) ) { return $this->_seoUri; } if ( empty( $this->id ) ) { return ''; } if ( empty( $this->_seoUri ) ) { $this->_seoUriStructure = $this->getUriStructure( array( $this->getMapper() ->getLocale() ) ); if ( ! empty( $this->_seoUriStructure ) ) { $this->_seoUri = $this->_seoUriStructure->uri; } } return $this->_seoUri; }
php
public function getSeoUri() { if ( ! empty( $this->_seoUri ) ) { return $this->_seoUri; } if ( empty( $this->id ) ) { return ''; } if ( empty( $this->_seoUri ) ) { $this->_seoUriStructure = $this->getUriStructure( array( $this->getMapper() ->getLocale() ) ); if ( ! empty( $this->_seoUriStructure ) ) { $this->_seoUri = $this->_seoUriStructure->uri; } } return $this->_seoUri; }
[ "public", "function", "getSeoUri", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_seoUri", ")", ")", "{", "return", "$", "this", "->", "_seoUri", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "id", ")", ")", "{", "ret...
Get seo-friendly uri @return string
[ "Get", "seo", "-", "friendly", "uri" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Content.php#L663-L689
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Structure/Container.php
Container.getUri
public function getUri() { if ( $this->hasChildren() ) { foreach( $this->getChildren() as $child ) { $uri = $child->getUri(); if ( '#' != $uri[0] ) { return $uri; } } } else { return '#'; } }
php
public function getUri() { if ( $this->hasChildren() ) { foreach( $this->getChildren() as $child ) { $uri = $child->getUri(); if ( '#' != $uri[0] ) { return $uri; } } } else { return '#'; } }
[ "public", "function", "getUri", "(", ")", "{", "if", "(", "$", "this", "->", "hasChildren", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "uri", "=", "$", "child", "->", "getUri...
Get URI of this menu-item @return string
[ "Get", "URI", "of", "this", "menu", "-", "item" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Structure/Container.php#L25-L43
train
sadekbaroudi/operation-state
OperationState.php
OperationState.execute
public function execute() { $returnValues = array(); while ($execute = array_shift($this->executeParameters)) { $returnValues[] = $this->run($execute); } return $returnValues; }
php
public function execute() { $returnValues = array(); while ($execute = array_shift($this->executeParameters)) { $returnValues[] = $this->run($execute); } return $returnValues; }
[ "public", "function", "execute", "(", ")", "{", "$", "returnValues", "=", "array", "(", ")", ";", "while", "(", "$", "execute", "=", "array_shift", "(", "$", "this", "->", "executeParameters", ")", ")", "{", "$", "returnValues", "[", "]", "=", "$", "...
This will execute all the actions in the queue. It will not clear the queue! @return array returns the results of the executed actions, with OperationState->getKey() as the array keys
[ "This", "will", "execute", "all", "the", "actions", "in", "the", "queue", ".", "It", "will", "not", "clear", "the", "queue!" ]
75b34571ca8b77380eef4bc1be0cbea35bcb9c68
https://github.com/sadekbaroudi/operation-state/blob/75b34571ca8b77380eef4bc1be0cbea35bcb9c68/OperationState.php#L98-L107
train
sadekbaroudi/operation-state
OperationState.php
OperationState.undo
public function undo() { $returnValues = array(); while ($undo = array_shift($this->undoParameters)) { $returnValues[] = $this->run($undo); } return $returnValues; }
php
public function undo() { $returnValues = array(); while ($undo = array_shift($this->undoParameters)) { $returnValues[] = $this->run($undo); } return $returnValues; }
[ "public", "function", "undo", "(", ")", "{", "$", "returnValues", "=", "array", "(", ")", ";", "while", "(", "$", "undo", "=", "array_shift", "(", "$", "this", "->", "undoParameters", ")", ")", "{", "$", "returnValues", "[", "]", "=", "$", "this", ...
This will execute all the undo actions in the queue. It will not clear the queue! @return array returns the results of the undo actions, with OperationState->getKey() as the array keys
[ "This", "will", "execute", "all", "the", "undo", "actions", "in", "the", "queue", ".", "It", "will", "not", "clear", "the", "queue!" ]
75b34571ca8b77380eef4bc1be0cbea35bcb9c68
https://github.com/sadekbaroudi/operation-state/blob/75b34571ca8b77380eef4bc1be0cbea35bcb9c68/OperationState.php#L155-L163
train
sadekbaroudi/operation-state
OperationState.php
OperationState.run
protected function run($call) { if (!isset($call['callable'])) { throw new OperationStateException("\$call['callable'] was not set"); } if (!isset($call['arguments'])) { try { is_null($call['arguments']); } catch (\Exception $e) { throw new OperationStateException("\$call['arguments'] was not set"); } } if (is_callable($call['callable'])) { if ($call['arguments'] == self::NO_ARGUMENT) { return call_user_func($call['callable']); } else { return call_user_func_array($call['callable'], $call['arguments']); } } else { throw new OperationStateException("\$call and \$arguments passed did not pass is_callable() check"); } }
php
protected function run($call) { if (!isset($call['callable'])) { throw new OperationStateException("\$call['callable'] was not set"); } if (!isset($call['arguments'])) { try { is_null($call['arguments']); } catch (\Exception $e) { throw new OperationStateException("\$call['arguments'] was not set"); } } if (is_callable($call['callable'])) { if ($call['arguments'] == self::NO_ARGUMENT) { return call_user_func($call['callable']); } else { return call_user_func_array($call['callable'], $call['arguments']); } } else { throw new OperationStateException("\$call and \$arguments passed did not pass is_callable() check"); } }
[ "protected", "function", "run", "(", "$", "call", ")", "{", "if", "(", "!", "isset", "(", "$", "call", "[", "'callable'", "]", ")", ")", "{", "throw", "new", "OperationStateException", "(", "\"\\$call['callable'] was not set\"", ")", ";", "}", "if", "(", ...
This will run the action passed, whether execute or undo. @param array $call Contains 'callable' index supporting is_callable and 'arguments' (NULL or args). You can also pass OperationState::NO_ARGUMENT as an argument to call with no argument @throws \RuntimeException @return mixed returns the result of the method call
[ "This", "will", "run", "the", "action", "passed", "whether", "execute", "or", "undo", "." ]
75b34571ca8b77380eef4bc1be0cbea35bcb9c68
https://github.com/sadekbaroudi/operation-state/blob/75b34571ca8b77380eef4bc1be0cbea35bcb9c68/OperationState.php#L173-L196
train
sadekbaroudi/operation-state
OperationState.php
OperationState.getKey
public function getKey() { if (!isset($this->key)) { $this->key = md5(microtime().rand()); } return $this->key; }
php
public function getKey() { if (!isset($this->key)) { $this->key = md5(microtime().rand()); } return $this->key; }
[ "public", "function", "getKey", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "key", ")", ")", "{", "$", "this", "->", "key", "=", "md5", "(", "microtime", "(", ")", ".", "rand", "(", ")", ")", ";", "}", "return", "$", "this...
Get the a unique key for this object. It should return the same value regardless of when this function is called! @return string
[ "Get", "the", "a", "unique", "key", "for", "this", "object", ".", "It", "should", "return", "the", "same", "value", "regardless", "of", "when", "this", "function", "is", "called!" ]
75b34571ca8b77380eef4bc1be0cbea35bcb9c68
https://github.com/sadekbaroudi/operation-state/blob/75b34571ca8b77380eef4bc1be0cbea35bcb9c68/OperationState.php#L203-L209
train
pdenis/SnideTravinizerBundle
Loader/ComposerLoader.php
ComposerLoader.getFile
public function getFile(Repo $repo) { $file = tempnam(sys_get_temp_dir(), 'composer'); $content = file_get_contents($this->helper->getRawFileUrl($repo->getSlug(), 'master', 'composer.json')); file_put_contents($file, $content); return $file; }
php
public function getFile(Repo $repo) { $file = tempnam(sys_get_temp_dir(), 'composer'); $content = file_get_contents($this->helper->getRawFileUrl($repo->getSlug(), 'master', 'composer.json')); file_put_contents($file, $content); return $file; }
[ "public", "function", "getFile", "(", "Repo", "$", "repo", ")", "{", "$", "file", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'composer'", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "this", "->", "helper", "->", "getRawFil...
Get composer file @param \Snide\Bundle\TravinizerBundle\Model\Repo $repo @return string
[ "Get", "composer", "file" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Loader/ComposerLoader.php#L40-L47
train
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.calculateTotalAmountForDeliveryExpenses
private function calculateTotalAmountForDeliveryExpenses(Transaction $transaction) { $total = 0; foreach ($transaction->getItems() as $productPurchase) { if($productPurchase->getProduct() instanceof Product){ if(!$productPurchase->getProduct()->isFreeTransport()){ $addPercent = 0; if($this->deliveryExpensesPercentage > 0) $addPercent = $productPurchase->getTotalPrice() * $this->deliveryExpensesPercentage; $total += $productPurchase->getTotalPrice() + $addPercent; } }else{ $total += $productPurchase->getTotalPrice(); } } return $total; }
php
private function calculateTotalAmountForDeliveryExpenses(Transaction $transaction) { $total = 0; foreach ($transaction->getItems() as $productPurchase) { if($productPurchase->getProduct() instanceof Product){ if(!$productPurchase->getProduct()->isFreeTransport()){ $addPercent = 0; if($this->deliveryExpensesPercentage > 0) $addPercent = $productPurchase->getTotalPrice() * $this->deliveryExpensesPercentage; $total += $productPurchase->getTotalPrice() + $addPercent; } }else{ $total += $productPurchase->getTotalPrice(); } } return $total; }
[ "private", "function", "calculateTotalAmountForDeliveryExpenses", "(", "Transaction", "$", "transaction", ")", "{", "$", "total", "=", "0", ";", "foreach", "(", "$", "transaction", "->", "getItems", "(", ")", "as", "$", "productPurchase", ")", "{", "if", "(", ...
Calculate total amount for delivery expenses @param Transaction $transaction @return float $total
[ "Calculate", "total", "amount", "for", "delivery", "expenses" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L169-L186
train
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.getCurrentTransaction
public function getCurrentTransaction() { if (false === $this->session->has('transaction-id')) { throw new AccessDeniedHttpException(); } return $this->manager->getRepository('EcommerceBundle:Transaction')->find($this->session->get('transaction-id')); }
php
public function getCurrentTransaction() { if (false === $this->session->has('transaction-id')) { throw new AccessDeniedHttpException(); } return $this->manager->getRepository('EcommerceBundle:Transaction')->find($this->session->get('transaction-id')); }
[ "public", "function", "getCurrentTransaction", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "session", "->", "has", "(", "'transaction-id'", ")", ")", "{", "throw", "new", "AccessDeniedHttpException", "(", ")", ";", "}", "return", "$", "thi...
Get current transaction @throws AccessDeniedHttpException @return Transaction
[ "Get", "current", "transaction" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L194-L201
train
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.updateTransaction
public function updateTransaction() { $cart = $this->cartProvider->getCart(); if (0 === $cart->countItems() || $this->isTransactionUpdated($cart)) { return; } /** @var TransactionRepository $transactionRepository */ $transactionRepository = $this->manager->getRepository('EcommerceBundle:Transaction'); if ($this->session->has('transaction-id')) { /** @var Transaction $transaction */ $transaction = $transactionRepository->find($this->session->get('transaction-id')); $transactionRepository->removeItems($transaction); } else { $transactionKey = $transactionRepository->getNextNumber(); // create a new transaction $transaction = new Transaction(); $transaction->setTransactionKey($transactionKey); $transaction->setStatus(Transaction::STATUS_CREATED); $transaction->setActor($this->securityContext->getToken()->getUser()); $cartItem = $cart->getItems()->first(); $product = $cartItem->getProduct(); } $orderTotalPrice = 0; foreach ($cart->getItems() as $cartItem) { /** @var Product $product */ $product = $cartItem->getProduct(); $productPurchase = new ProductPurchase(); $productPurchase->setProduct($product); $productPurchase->setBasePrice($cartItem->getUnitPrice()); $productPurchase->setQuantity($cartItem->getQuantity()); $productPurchase->setDiscount($product->getDiscount()); $productPurchase->setTotalPrice($cartItem->getTotal()); $productPurchase->setTransaction($transaction); $productPurchase->setReturned(false); //free transport if($cartItem->isFreeTransport()){ $productPurchase->setDeliveryExpenses(0); }else{ $productPurchase->setDeliveryExpenses($cartItem->getShippingCost()); } $orderTotalPrice += $cartItem->getProduct()->getPrice() * $cartItem->getQuantity(); $this->manager->persist($productPurchase); } $transaction->setTotalPrice($orderTotalPrice); $this->manager->persist($transaction); $this->manager->flush(); $this->session->set('transaction-id', $transaction->getId()); $this->session->save(); }
php
public function updateTransaction() { $cart = $this->cartProvider->getCart(); if (0 === $cart->countItems() || $this->isTransactionUpdated($cart)) { return; } /** @var TransactionRepository $transactionRepository */ $transactionRepository = $this->manager->getRepository('EcommerceBundle:Transaction'); if ($this->session->has('transaction-id')) { /** @var Transaction $transaction */ $transaction = $transactionRepository->find($this->session->get('transaction-id')); $transactionRepository->removeItems($transaction); } else { $transactionKey = $transactionRepository->getNextNumber(); // create a new transaction $transaction = new Transaction(); $transaction->setTransactionKey($transactionKey); $transaction->setStatus(Transaction::STATUS_CREATED); $transaction->setActor($this->securityContext->getToken()->getUser()); $cartItem = $cart->getItems()->first(); $product = $cartItem->getProduct(); } $orderTotalPrice = 0; foreach ($cart->getItems() as $cartItem) { /** @var Product $product */ $product = $cartItem->getProduct(); $productPurchase = new ProductPurchase(); $productPurchase->setProduct($product); $productPurchase->setBasePrice($cartItem->getUnitPrice()); $productPurchase->setQuantity($cartItem->getQuantity()); $productPurchase->setDiscount($product->getDiscount()); $productPurchase->setTotalPrice($cartItem->getTotal()); $productPurchase->setTransaction($transaction); $productPurchase->setReturned(false); //free transport if($cartItem->isFreeTransport()){ $productPurchase->setDeliveryExpenses(0); }else{ $productPurchase->setDeliveryExpenses($cartItem->getShippingCost()); } $orderTotalPrice += $cartItem->getProduct()->getPrice() * $cartItem->getQuantity(); $this->manager->persist($productPurchase); } $transaction->setTotalPrice($orderTotalPrice); $this->manager->persist($transaction); $this->manager->flush(); $this->session->set('transaction-id', $transaction->getId()); $this->session->save(); }
[ "public", "function", "updateTransaction", "(", ")", "{", "$", "cart", "=", "$", "this", "->", "cartProvider", "->", "getCart", "(", ")", ";", "if", "(", "0", "===", "$", "cart", "->", "countItems", "(", ")", "||", "$", "this", "->", "isTransactionUpda...
Update transaction with cart's contents
[ "Update", "transaction", "with", "cart", "s", "contents" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L206-L267
train
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.isTransactionUpdated
private function isTransactionUpdated(Cart $cart) { if (false === $this->session->has('transaction-id')) { return false; } /** @var TransactionRepository $transactionRepository */ $transactionRepository = $this->manager->getRepository('EcommerceBundle:Transaction'); /** @var Order $order */ $transaction = $transactionRepository->find($this->session->get('transaction-id')); /** @var ArrayCollection $cartItems */ $cartItems = $cart->getItems(); /** @var ArrayCollection $orderItems */ $productPurchases = $transaction->getItems(); if ($cartItems->count() !== $productPurchases->count()) { return false; } for ($i=0; $i<$cartItems->count(); $i++) { /** @var CartItem $cartItem */ $cartItem = $cartItems[$i]; /** @var OrderItem $orderItem */ $productPurchase = $productPurchases[$i]; if ($cartItem->getProduct()->getId() !== $productPurchase->getProduct()->getId() || $cartItem->getQuantity() !== $productPurchase->getQuantity()) { return false; } } return true; }
php
private function isTransactionUpdated(Cart $cart) { if (false === $this->session->has('transaction-id')) { return false; } /** @var TransactionRepository $transactionRepository */ $transactionRepository = $this->manager->getRepository('EcommerceBundle:Transaction'); /** @var Order $order */ $transaction = $transactionRepository->find($this->session->get('transaction-id')); /** @var ArrayCollection $cartItems */ $cartItems = $cart->getItems(); /** @var ArrayCollection $orderItems */ $productPurchases = $transaction->getItems(); if ($cartItems->count() !== $productPurchases->count()) { return false; } for ($i=0; $i<$cartItems->count(); $i++) { /** @var CartItem $cartItem */ $cartItem = $cartItems[$i]; /** @var OrderItem $orderItem */ $productPurchase = $productPurchases[$i]; if ($cartItem->getProduct()->getId() !== $productPurchase->getProduct()->getId() || $cartItem->getQuantity() !== $productPurchase->getQuantity()) { return false; } } return true; }
[ "private", "function", "isTransactionUpdated", "(", "Cart", "$", "cart", ")", "{", "if", "(", "false", "===", "$", "this", "->", "session", "->", "has", "(", "'transaction-id'", ")", ")", "{", "return", "false", ";", "}", "/** @var TransactionRepository $trans...
Compare current cart with current transaction @param CartInterface $cart @return boolean
[ "Compare", "current", "cart", "with", "current", "transaction" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L346-L380
train