id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,500
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", "(", ")", "->", "DeAuthenticate", "(", ")", ";", "$", "this", "->", "SetCookie", "(", "'-Vv'", ",", "NULL", ",", "-", "3600", ")", ";", "$", "this", "->", "UserID", "=", "0", ";", "$", "this", "->", "User", "=", "FALSE", ";", "$", "this", "->", "_Attributes", "=", "array", "(", ")", ";", "$", "this", "->", "_Permissions", "=", "array", "(", ")", ";", "$", "this", "->", "_Preferences", "=", "array", "(", ")", ";", "$", "this", "->", "_TransientKey", "=", "FALSE", ";", "}" ]
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
240,501
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", "(", "!", "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", ";", "}", "}" ]
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
240,502
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 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", ")", ")", ";", "}" ]
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
240,503
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", "(", ")", "->", "SetTransientKey", "(", "$", "this", "->", "UserID", ",", "$", "NewKey", ")", ";", "}", "// if ($this->_TransientKey)", "return", "$", "this", "->", "_TransientKey", ";", "// else", "// return RandomString(12); // Postbacks will never be authenticated if transientkey is not defined.", "}" ]
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
240,504
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", ")", ";", "$", "this", "->", "guessIsIntrospectedStateLeaf", "(", "$", "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
240,505
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-'", ".", "$", "categoryKey", ")", ";", "}", "return", "false", ";", "}" ]
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
240,506
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", "(", "$", "pipeline", ",", "$", "this", "->", "resolver", ")", ";", "return", "$", "middleman", "->", "dispatch", "(", "$", "request", ")", ";", "}" ]
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
240,507
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'", "]", ")", ")", "{", "// --------------------", "// 対象のテーブルが選択されていない", "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", ";", "}" ]
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
240,508
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", "->", "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", ";", "}" ]
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
240,509
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", "(", "@", "$", "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", ";", "}" ]
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
240,510
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", "=", "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", ";", "}" ]
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
240,511
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", "(", "$", "this", "->", "getString", "(", "$", "string", ")", ",", "$", "vars", ")", ";", "}", "return", "$", "this", "->", "compileString", "(", "$", "this", "->", "getString", "(", "$", "string", ")", ",", "$", "vars", ")", ";", "}" ]
Translates the specified string. @return string
[ "Translates", "the", "specified", "string", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Language/Translation.php#L55-L63
240,512
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", "]", ";", "}", "else", "{", "return", "$", "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
240,513
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", "(", "$", "numeral", ">", "1", "or", "$", "numeral", "<", "-", "1", "or", "$", "numeral", "==", "0", ")", "?", "1", ":", "0", ";", "}" ]
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
240,514
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", "(", "$", "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", ";", "}" ]
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
240,515
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", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collObjects", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Object'", ")", ";", "}" ]
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
240,516
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", "(", ")", ";", "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", ";", "}" ]
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
240,517
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", "&&", "!", "$", "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", ")", ";", "}" ]
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
240,518
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", ";", "}", "if", "(", "!", "$", "this", "->", "collObjects", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddObject", "(", "$", "l", ")", ";", "}", "return", "$", "this", ";", "}" ]
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
240,519
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", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collPositions", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Position'", ")", ";", "}" ]
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
240,520
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", "(", ")", ";", "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", ";", "}" ]
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
240,521
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", "&&", "!", "$", "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", ")", ";", "}" ]
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
240,522
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", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "collPositions", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddPosition", "(", "$", "l", ")", ";", "}", "return", "$", "this", ";", "}" ]
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
240,523
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", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Object'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getSkills", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
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", ";", "or", "if", "this", "Sport", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "Skills", "from", "storage", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Sport.php#L3205-L3211
240,524
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", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collGroups", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Group'", ")", ";", "}" ]
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
240,525
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", "(", ")", ";", "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", ";", "}" ]
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
240,526
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", ";", "}", "if", "(", "!", "$", "this", "->", "collGroups", "->", "contains", "(", "$", "l", ")", ")", "{", "$", "this", "->", "doAddGroup", "(", "$", "l", ")", ";", "}", "return", "$", "this", ";", "}" ]
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
240,527
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", "(", "\"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", ")", ";", "}" ]
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
240,528
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", "$", "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", ";", "}" ]
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
240,529
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", "(", "$", "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", ";", "}" ]
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
240,530
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'", "]", "=", "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", ";", "}", ";", "}" ]
Load languages.
[ "Load", "languages", "." ]
e32a2d2cb16a2bb7939250372bd74ca3ca7eba58
https://github.com/khanhicetea/sifoni/blob/e32a2d2cb16a2bb7939250372bd74ca3ca7eba58/src/Sifoni/Engine.php#L250-L279
240,531
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", ".", "'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", ")", ";", "}", "}", "}" ]
Load routing.
[ "Load", "routing", "." ]
e32a2d2cb16a2bb7939250372bd74ca3ca7eba58
https://github.com/khanhicetea/sifoni/blob/e32a2d2cb16a2bb7939250372bd74ca3ca7eba58/src/Sifoni/Engine.php#L284-L339
240,532
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
240,533
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", "(", ")", ",", "$", "ext", "->", "getUniqueExtensionId", "(", ")", ")", ";", "}" ]
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
240,534
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", "$", "this", "->", "titles", "[", "$", "code", "]", ";", "}" ]
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
240,535
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", "=", "$", "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", ";", "}" ]
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
240,536
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", "(", "$", "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", ";", "}" ]
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
240,537
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", "::", "$", "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", ")", ";", "}" ]
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", "matter", "what", "the", "actual", "attribute", "name", "is", "for", "the", "primary", "key", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L501-L544
240,538
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", "(", "method_exists", "(", "$", "this", ",", "\"__get_$attrName\"", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
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
240,539
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", ")", "{", "$", "this", "->", "_dirty", "[", "$", "name", "]", "=", "true", ";", "}", "else", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_dirty", ")", ")", "{", "unset", "(", "$", "this", "->", "_dirty", "[", "$", "name", "]", ")", ";", "}", "}", "}" ]
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
240,540
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", ")", ";", "return", "!", "empty", "(", "$", "dirty", ")", "?", "$", "dirty", ":", "null", ";", "}" ]
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
240,541
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", ",", "$", "this", "->", "_attributes", ")", ";", "}" ]
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
240,542
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", "=", "new", "$", "className", "(", "$", "attributes", ",", "$", "guardAttributes", ")", ";", "$", "model", "->", "save", "(", "$", "validate", ")", ";", "return", "$", "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
240,543
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", "->", "_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", ";", "}" ]
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
240,544
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", "(", ")", ")", "{", "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", ";", "}" ]
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
240,545
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", "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", ";", "}" ]
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
240,546
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", "->", "$", "name", ";", "return", "$", "filter", ";", "}" ]
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
240,547
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", ")", ")", "{", "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", ";", "}" ]
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
240,548
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", "(", "isset", "(", "$", "this", "->", "created_at", ")", "&&", "$", "this", "->", "isNewRecord", "(", ")", ")", "$", "this", "->", "created_at", "=", "$", "now", ";", "}" ]
Updates a model's timestamps.
[ "Updates", "a", "model", "s", "timestamps", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Model.php#L1189-L1198
240,549
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
240,550
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", "(", ")", ")", ")", ";", "$", "this", "->", "setAttributesViaMassAssignment", "(", "$", "this", "->", "find", "(", "$", "pk", ")", "->", "attributes", ",", "false", ")", ";", "$", "this", "->", "resetDirty", "(", ")", ";", "return", "$", "this", ";", "}" ]
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
240,551
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'", "]", "=", "'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", ")", ";", "}" ]
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
240,552
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 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", ";", "}" ]
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
240,553
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", "(", ")", "->", "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", ";", "}" ]
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
240,554
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", ")", ";", "$", "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", ";", "}" ]
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
240,555
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_exist", ")", ";", "}" ]
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
240,556
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", "(", ")", "===", "false", ")", "{", "$", "connection", "->", "rollback", "(", ")", ";", "return", "false", ";", "}", "else", "$", "connection", "->", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "connection", "->", "rollback", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "true", ";", "}" ]
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
240,557
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", "||", "!", "is_array", "(", "$", "session", "->", "source", ")", ")", "{", "return", "null", ";", "}", "/** @noinspection PhpUndefinedFieldInspection */", "return", "$", "session", "->", "source", "[", "'routeName'", "]", "===", "$", "routeName", ";", "}" ]
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
240,558
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", "(", "$", "session", "->", "data", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
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
240,559
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", ";", "$", "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", ")", ";", "}" ]
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
240,560
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", "(", ")", ".", "'\\\\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", ";", "}" ]
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
240,561
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", "$", "database", ".", "DS", ".", "$", "this", "->", "generateVersion", "(", ")", ".", "$", "name", ".", "'.php'", ";", "}" ]
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
240,562
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", "->", "lineWidth", ")", ";", "}" ]
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
240,563
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", "->", "get", "(", "$", "this", "->", "key", ",", "null", ")", ";", "return", "$", "this", "->", "convertToString", "(", "$", "value", ")", ";", "}" ]
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
240,564
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", ")", "{", "$", "raw", "=", "strip_tags", "(", "$", "line", ")", ";", "$", "width", "[", "]", "=", "strlen", "(", "trim", "(", "$", "raw", ")", ")", ";", "}", "return", "max", "(", "$", "width", ")", ";", "}" ]
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
240,565
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
240,566
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", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Di'", ")", "->", "get", "(", "'Grid\\User\\Model\\User\\Mapper'", ",", "array", "(", "'dbAdapter'", "=>", "$", "mapper", "->", "getDbAdapter", "(", ")", ",", "'dbSchema'", "=>", "$", "mapper", "->", "getDbSchema", "(", ")", ",", ")", ")", ";", "}", "return", "$", "this", "->", "_userMapper", ";", "}" ]
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
240,567
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", ",", "$", "format", ")", ";", "return", "$", "this", ";", "}" ]
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
240,568
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", ",", "$", "format", ")", ";", "return", "$", "this", ";", "}" ]
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
240,569
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", "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", ";", "}" ]
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
240,570
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", ")", ")", ";", "return", "$", "this", ";", "}" ]
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
240,571
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", ")", ")", ";", "return", "$", "this", ";", "}" ]
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
240,572
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", ")", ")", ";", "return", "$", "this", ";", "}" ]
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
240,573
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", ")", ")", ";", "return", "$", "this", ";", "}" ]
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
240,574
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", ")", ")", "{", "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", ";", "}" ]
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
240,575
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", "(", ")", ";", "if", "(", "'#'", "!=", "$", "uri", "[", "0", "]", ")", "{", "return", "$", "uri", ";", "}", "}", "}", "else", "{", "return", "'#'", ";", "}", "}" ]
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
240,576
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", "->", "run", "(", "$", "execute", ")", ";", "}", "return", "$", "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
240,577
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", "->", "run", "(", "$", "undo", ")", ";", "}", "return", "$", "returnValues", ";", "}" ]
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
240,578
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", "(", "!", "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\"", ")", ";", "}", "}" ]
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
240,579
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", "->", "key", ";", "}" ]
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
240,580
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", "->", "getRawFileUrl", "(", "$", "repo", "->", "getSlug", "(", ")", ",", "'master'", ",", "'composer.json'", ")", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "content", ")", ";", "return", "$", "file", ";", "}" ]
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
240,581
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", "(", "$", "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", ";", "}" ]
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
240,582
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", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Transaction'", ")", "->", "find", "(", "$", "this", "->", "session", "->", "get", "(", "'transaction-id'", ")", ")", ";", "}" ]
Get current transaction @throws AccessDeniedHttpException @return Transaction
[ "Get", "current", "transaction" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L194-L201
240,583
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", "->", "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", "(", ")", ";", "}" ]
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
240,584
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 $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", ";", "}" ]
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
240,585
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.getDelivery
public function getDelivery(Transaction $transaction = null) { if ($this->session->has('delivery-id')) { $delivery = $this->manager->getRepository('EcommerceBundle:Delivery')->find($this->session->get('delivery-id')); return $delivery; } $delivery = new Delivery(); /** @var Address $billingAddress */ $billingAddress = $this->manager->getRepository('EcommerceBundle:Address')->findOneBy(array( 'actor' => $this->securityContext->getToken()->getUser(), 'forBilling' => true )); if (false === is_null($billingAddress)) { $delivery->setFullName($this->securityContext->getToken()->getUser()->getFullName()); $delivery->setContactPerson($billingAddress->getContactPerson()); $delivery->setDni($billingAddress->getDni()); $delivery->setAddressInfo($billingAddress->getAddressInfo()); $delivery->setPhone($billingAddress->getPhone()); $delivery->setPhone2($billingAddress->getPhone2()); $delivery->setPreferredSchedule($billingAddress->getPreferredSchedule()); } $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $delivery->setCountry($country); if (false === is_null($transaction)) { $delivery->setTransaction($transaction); } return $delivery; }
php
public function getDelivery(Transaction $transaction = null) { if ($this->session->has('delivery-id')) { $delivery = $this->manager->getRepository('EcommerceBundle:Delivery')->find($this->session->get('delivery-id')); return $delivery; } $delivery = new Delivery(); /** @var Address $billingAddress */ $billingAddress = $this->manager->getRepository('EcommerceBundle:Address')->findOneBy(array( 'actor' => $this->securityContext->getToken()->getUser(), 'forBilling' => true )); if (false === is_null($billingAddress)) { $delivery->setFullName($this->securityContext->getToken()->getUser()->getFullName()); $delivery->setContactPerson($billingAddress->getContactPerson()); $delivery->setDni($billingAddress->getDni()); $delivery->setAddressInfo($billingAddress->getAddressInfo()); $delivery->setPhone($billingAddress->getPhone()); $delivery->setPhone2($billingAddress->getPhone2()); $delivery->setPreferredSchedule($billingAddress->getPreferredSchedule()); } $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $delivery->setCountry($country); if (false === is_null($transaction)) { $delivery->setTransaction($transaction); } return $delivery; }
[ "public", "function", "getDelivery", "(", "Transaction", "$", "transaction", "=", "null", ")", "{", "if", "(", "$", "this", "->", "session", "->", "has", "(", "'delivery-id'", ")", ")", "{", "$", "delivery", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Delivery'", ")", "->", "find", "(", "$", "this", "->", "session", "->", "get", "(", "'delivery-id'", ")", ")", ";", "return", "$", "delivery", ";", "}", "$", "delivery", "=", "new", "Delivery", "(", ")", ";", "/** @var Address $billingAddress */", "$", "billingAddress", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'actor'", "=>", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ",", "'forBilling'", "=>", "true", ")", ")", ";", "if", "(", "false", "===", "is_null", "(", "$", "billingAddress", ")", ")", "{", "$", "delivery", "->", "setFullName", "(", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", "->", "getFullName", "(", ")", ")", ";", "$", "delivery", "->", "setContactPerson", "(", "$", "billingAddress", "->", "getContactPerson", "(", ")", ")", ";", "$", "delivery", "->", "setDni", "(", "$", "billingAddress", "->", "getDni", "(", ")", ")", ";", "$", "delivery", "->", "setAddressInfo", "(", "$", "billingAddress", "->", "getAddressInfo", "(", ")", ")", ";", "$", "delivery", "->", "setPhone", "(", "$", "billingAddress", "->", "getPhone", "(", ")", ")", ";", "$", "delivery", "->", "setPhone2", "(", "$", "billingAddress", "->", "getPhone2", "(", ")", ")", ";", "$", "delivery", "->", "setPreferredSchedule", "(", "$", "billingAddress", "->", "getPreferredSchedule", "(", ")", ")", ";", "}", "$", "country", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'CoreBundle:Country'", ")", "->", "find", "(", "'es'", ")", ";", "$", "delivery", "->", "setCountry", "(", "$", "country", ")", ";", "if", "(", "false", "===", "is_null", "(", "$", "transaction", ")", ")", "{", "$", "delivery", "->", "setTransaction", "(", "$", "transaction", ")", ";", "}", "return", "$", "delivery", ";", "}" ]
Build a delivery object for the current actor @param Transaction $transaction @return Delivery
[ "Build", "a", "delivery", "object", "for", "the", "current", "actor" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L389-L423
240,586
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.saveDelivery
public function saveDelivery(Delivery $delivery, array $params, $cart) { /** @var Carrier $carrier */ // $carrier = $this->manager->getRepository('ModelBundle:Carrier')->find($delivery->getCarrier()); if ('same' === $params['selectDelivery']) { $delivery->setDeliveryContactPerson($delivery->getContactPerson()); $delivery->setDeliveryDni($delivery->getDni()); $delivery->setDeliveryAddressInfo($delivery->getAddressInfo()); $delivery->setDeliveryPhone($delivery->getPhone()); $delivery->setDeliveryPhone2($delivery->getPhone2()); $delivery->setDeliveryPreferredSchedule($delivery->getPreferredSchedule()); } else if ('existing' === $params['selectDelivery']) { /** @var Address $address */ $address = $this->manager->getRepository('EcommerceBundle:Address')->find($params['existingDeliveryAddress']); $delivery->setDeliveryContactPerson($address->getContactPerson()); $delivery->setDeliveryDni($address->getDni()); $delivery->setDeliveryAddressInfo($address->getAddressInfo()); $delivery->setDeliveryPhone($address->getPhone()); $delivery->setDeliveryPhone2($address->getPhone2()); $delivery->setDeliveryPreferredSchedule($address->getPreferredSchedule()); } else if ('new' === $params['selectDelivery']) { $this->addUserDeliveryAddress($delivery); } $deliveryCountry = $this->manager->getRepository('CoreBundle:Country')->find('es'); $delivery->setDeliveryCountry($deliveryCountry); $total = 0; $productPurchases = $this->manager->getRepository('EcommerceBundle:ProductPurchase')->findByTransaction($delivery->getTransaction()); foreach ($productPurchases as $item) { if($item->getDeliveryExpenses()>0) $total = $total + $item->getDeliveryExpenses(); } $delivery->setExpenses($total); if($total>0) $delivery->setExpensesType('store_pickup'); else $delivery->setExpensesType('send'); $this->saveUserBillingAddress($delivery); $this->manager->persist($delivery); $this->manager->flush(); $this->session->set('delivery-id', $delivery->getId()); $this->session->set('select-delivery', $params['selectDelivery']); if ('existing' === $params['selectDelivery']) { $this->session->set('existing-delivery-address', intval($params['existingDeliveryAddress'])); } else { $this->session->remove('existing-delivery-address'); } $this->session->save(); }
php
public function saveDelivery(Delivery $delivery, array $params, $cart) { /** @var Carrier $carrier */ // $carrier = $this->manager->getRepository('ModelBundle:Carrier')->find($delivery->getCarrier()); if ('same' === $params['selectDelivery']) { $delivery->setDeliveryContactPerson($delivery->getContactPerson()); $delivery->setDeliveryDni($delivery->getDni()); $delivery->setDeliveryAddressInfo($delivery->getAddressInfo()); $delivery->setDeliveryPhone($delivery->getPhone()); $delivery->setDeliveryPhone2($delivery->getPhone2()); $delivery->setDeliveryPreferredSchedule($delivery->getPreferredSchedule()); } else if ('existing' === $params['selectDelivery']) { /** @var Address $address */ $address = $this->manager->getRepository('EcommerceBundle:Address')->find($params['existingDeliveryAddress']); $delivery->setDeliveryContactPerson($address->getContactPerson()); $delivery->setDeliveryDni($address->getDni()); $delivery->setDeliveryAddressInfo($address->getAddressInfo()); $delivery->setDeliveryPhone($address->getPhone()); $delivery->setDeliveryPhone2($address->getPhone2()); $delivery->setDeliveryPreferredSchedule($address->getPreferredSchedule()); } else if ('new' === $params['selectDelivery']) { $this->addUserDeliveryAddress($delivery); } $deliveryCountry = $this->manager->getRepository('CoreBundle:Country')->find('es'); $delivery->setDeliveryCountry($deliveryCountry); $total = 0; $productPurchases = $this->manager->getRepository('EcommerceBundle:ProductPurchase')->findByTransaction($delivery->getTransaction()); foreach ($productPurchases as $item) { if($item->getDeliveryExpenses()>0) $total = $total + $item->getDeliveryExpenses(); } $delivery->setExpenses($total); if($total>0) $delivery->setExpensesType('store_pickup'); else $delivery->setExpensesType('send'); $this->saveUserBillingAddress($delivery); $this->manager->persist($delivery); $this->manager->flush(); $this->session->set('delivery-id', $delivery->getId()); $this->session->set('select-delivery', $params['selectDelivery']); if ('existing' === $params['selectDelivery']) { $this->session->set('existing-delivery-address', intval($params['existingDeliveryAddress'])); } else { $this->session->remove('existing-delivery-address'); } $this->session->save(); }
[ "public", "function", "saveDelivery", "(", "Delivery", "$", "delivery", ",", "array", "$", "params", ",", "$", "cart", ")", "{", "/** @var Carrier $carrier */", "// $carrier = $this->manager->getRepository('ModelBundle:Carrier')->find($delivery->getCarrier());", "if", "(", "'same'", "===", "$", "params", "[", "'selectDelivery'", "]", ")", "{", "$", "delivery", "->", "setDeliveryContactPerson", "(", "$", "delivery", "->", "getContactPerson", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryDni", "(", "$", "delivery", "->", "getDni", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryAddressInfo", "(", "$", "delivery", "->", "getAddressInfo", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPhone", "(", "$", "delivery", "->", "getPhone", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPhone2", "(", "$", "delivery", "->", "getPhone2", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPreferredSchedule", "(", "$", "delivery", "->", "getPreferredSchedule", "(", ")", ")", ";", "}", "else", "if", "(", "'existing'", "===", "$", "params", "[", "'selectDelivery'", "]", ")", "{", "/** @var Address $address */", "$", "address", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "find", "(", "$", "params", "[", "'existingDeliveryAddress'", "]", ")", ";", "$", "delivery", "->", "setDeliveryContactPerson", "(", "$", "address", "->", "getContactPerson", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryDni", "(", "$", "address", "->", "getDni", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryAddressInfo", "(", "$", "address", "->", "getAddressInfo", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPhone", "(", "$", "address", "->", "getPhone", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPhone2", "(", "$", "address", "->", "getPhone2", "(", ")", ")", ";", "$", "delivery", "->", "setDeliveryPreferredSchedule", "(", "$", "address", "->", "getPreferredSchedule", "(", ")", ")", ";", "}", "else", "if", "(", "'new'", "===", "$", "params", "[", "'selectDelivery'", "]", ")", "{", "$", "this", "->", "addUserDeliveryAddress", "(", "$", "delivery", ")", ";", "}", "$", "deliveryCountry", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'CoreBundle:Country'", ")", "->", "find", "(", "'es'", ")", ";", "$", "delivery", "->", "setDeliveryCountry", "(", "$", "deliveryCountry", ")", ";", "$", "total", "=", "0", ";", "$", "productPurchases", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:ProductPurchase'", ")", "->", "findByTransaction", "(", "$", "delivery", "->", "getTransaction", "(", ")", ")", ";", "foreach", "(", "$", "productPurchases", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getDeliveryExpenses", "(", ")", ">", "0", ")", "$", "total", "=", "$", "total", "+", "$", "item", "->", "getDeliveryExpenses", "(", ")", ";", "}", "$", "delivery", "->", "setExpenses", "(", "$", "total", ")", ";", "if", "(", "$", "total", ">", "0", ")", "$", "delivery", "->", "setExpensesType", "(", "'store_pickup'", ")", ";", "else", "$", "delivery", "->", "setExpensesType", "(", "'send'", ")", ";", "$", "this", "->", "saveUserBillingAddress", "(", "$", "delivery", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "delivery", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "$", "this", "->", "session", "->", "set", "(", "'delivery-id'", ",", "$", "delivery", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "session", "->", "set", "(", "'select-delivery'", ",", "$", "params", "[", "'selectDelivery'", "]", ")", ";", "if", "(", "'existing'", "===", "$", "params", "[", "'selectDelivery'", "]", ")", "{", "$", "this", "->", "session", "->", "set", "(", "'existing-delivery-address'", ",", "intval", "(", "$", "params", "[", "'existingDeliveryAddress'", "]", ")", ")", ";", "}", "else", "{", "$", "this", "->", "session", "->", "remove", "(", "'existing-delivery-address'", ")", ";", "}", "$", "this", "->", "session", "->", "save", "(", ")", ";", "}" ]
Save delivery fields from billing fields @param Delivery $delivery @param array $params
[ "Save", "delivery", "fields", "from", "billing", "fields" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L431-L489
240,587
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.saveUserBillingAddress
private function saveUserBillingAddress($delivery) { // get billing address /** @var Address $billingAddress */ $billingAddress = $this->manager->getRepository('EcommerceBundle:Address')->findOneBy(array( 'actor' => $this->securityContext->getToken()->getUser(), 'forBilling' => true )); // build new billing address when it does not exist if (is_null($billingAddress)) { $billingAddress = new Address(); $billingAddress->setForBilling(true); $billingAddress->setActor($this->securityContext->getToken()->getUser()); } $billingAddress->setContactPerson($delivery->getContactPerson()); $billingAddress->setDni($delivery->getDni()); $billingAddress->setAddressInfo($delivery->getAddressInfo()); $billingAddress->setPhone($delivery->getPhone()); $billingAddress->setPhone2($delivery->getPhone2()); $billingAddress->setPreferredSchedule($delivery->getPreferredSchedule()); $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $billingAddress->setCountry($country); $this->manager->persist($billingAddress); $this->manager->flush(); }
php
private function saveUserBillingAddress($delivery) { // get billing address /** @var Address $billingAddress */ $billingAddress = $this->manager->getRepository('EcommerceBundle:Address')->findOneBy(array( 'actor' => $this->securityContext->getToken()->getUser(), 'forBilling' => true )); // build new billing address when it does not exist if (is_null($billingAddress)) { $billingAddress = new Address(); $billingAddress->setForBilling(true); $billingAddress->setActor($this->securityContext->getToken()->getUser()); } $billingAddress->setContactPerson($delivery->getContactPerson()); $billingAddress->setDni($delivery->getDni()); $billingAddress->setAddressInfo($delivery->getAddressInfo()); $billingAddress->setPhone($delivery->getPhone()); $billingAddress->setPhone2($delivery->getPhone2()); $billingAddress->setPreferredSchedule($delivery->getPreferredSchedule()); $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $billingAddress->setCountry($country); $this->manager->persist($billingAddress); $this->manager->flush(); }
[ "private", "function", "saveUserBillingAddress", "(", "$", "delivery", ")", "{", "// get billing address", "/** @var Address $billingAddress */", "$", "billingAddress", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'actor'", "=>", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ",", "'forBilling'", "=>", "true", ")", ")", ";", "// build new billing address when it does not exist", "if", "(", "is_null", "(", "$", "billingAddress", ")", ")", "{", "$", "billingAddress", "=", "new", "Address", "(", ")", ";", "$", "billingAddress", "->", "setForBilling", "(", "true", ")", ";", "$", "billingAddress", "->", "setActor", "(", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ")", ";", "}", "$", "billingAddress", "->", "setContactPerson", "(", "$", "delivery", "->", "getContactPerson", "(", ")", ")", ";", "$", "billingAddress", "->", "setDni", "(", "$", "delivery", "->", "getDni", "(", ")", ")", ";", "$", "billingAddress", "->", "setAddressInfo", "(", "$", "delivery", "->", "getAddressInfo", "(", ")", ")", ";", "$", "billingAddress", "->", "setPhone", "(", "$", "delivery", "->", "getPhone", "(", ")", ")", ";", "$", "billingAddress", "->", "setPhone2", "(", "$", "delivery", "->", "getPhone2", "(", ")", ")", ";", "$", "billingAddress", "->", "setPreferredSchedule", "(", "$", "delivery", "->", "getPreferredSchedule", "(", ")", ")", ";", "$", "country", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'CoreBundle:Country'", ")", "->", "find", "(", "'es'", ")", ";", "$", "billingAddress", "->", "setCountry", "(", "$", "country", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "billingAddress", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "}" ]
Save user billing address @param Delivery $delivery
[ "Save", "user", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L496-L530
240,588
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.cleanSession
public function cleanSession() { // remove checkout session parameters $this->session->remove('select-delivery'); $this->session->remove('delivery-id'); $this->session->remove('existing-delivery-address'); $this->session->remove('transaction-id'); // abandon cart $this->cartProvider->abandonCart(); }
php
public function cleanSession() { // remove checkout session parameters $this->session->remove('select-delivery'); $this->session->remove('delivery-id'); $this->session->remove('existing-delivery-address'); $this->session->remove('transaction-id'); // abandon cart $this->cartProvider->abandonCart(); }
[ "public", "function", "cleanSession", "(", ")", "{", "// remove checkout session parameters", "$", "this", "->", "session", "->", "remove", "(", "'select-delivery'", ")", ";", "$", "this", "->", "session", "->", "remove", "(", "'delivery-id'", ")", ";", "$", "this", "->", "session", "->", "remove", "(", "'existing-delivery-address'", ")", ";", "$", "this", "->", "session", "->", "remove", "(", "'transaction-id'", ")", ";", "// abandon cart", "$", "this", "->", "cartProvider", "->", "abandonCart", "(", ")", ";", "}" ]
Clean checkout parameters from session and void the shopping cart
[ "Clean", "checkout", "parameters", "from", "session", "and", "void", "the", "shopping", "cart" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L630-L640
240,589
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.getBillingAddress
public function getBillingAddress($actor=null) { if(is_null($actor)){ $actor = $this->securityContext->getToken()->getUser(); if (!$actor || !is_object($actor)) { throw new \LogicException( 'The getBillingAddress cannot be used without an authenticated user!' ); } } /** @var Address $address */ $address = $this->manager->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'actor' => $actor, 'forBilling' => true )); // if it does not exist, create a new one if (is_null($address)) { $address = new Address(); $address->setForBilling(true); $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $address->setCountry($country); $address->setActor($actor); } return $address; }
php
public function getBillingAddress($actor=null) { if(is_null($actor)){ $actor = $this->securityContext->getToken()->getUser(); if (!$actor || !is_object($actor)) { throw new \LogicException( 'The getBillingAddress cannot be used without an authenticated user!' ); } } /** @var Address $address */ $address = $this->manager->getRepository('EcommerceBundle:Address') ->findOneBy(array( 'actor' => $actor, 'forBilling' => true )); // if it does not exist, create a new one if (is_null($address)) { $address = new Address(); $address->setForBilling(true); $country = $this->manager->getRepository('CoreBundle:Country')->find('es'); $address->setCountry($country); $address->setActor($actor); } return $address; }
[ "public", "function", "getBillingAddress", "(", "$", "actor", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "actor", ")", ")", "{", "$", "actor", "=", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "!", "$", "actor", "||", "!", "is_object", "(", "$", "actor", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'The getBillingAddress cannot be used without an authenticated user!'", ")", ";", "}", "}", "/** @var Address $address */", "$", "address", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:Address'", ")", "->", "findOneBy", "(", "array", "(", "'actor'", "=>", "$", "actor", ",", "'forBilling'", "=>", "true", ")", ")", ";", "// if it does not exist, create a new one", "if", "(", "is_null", "(", "$", "address", ")", ")", "{", "$", "address", "=", "new", "Address", "(", ")", ";", "$", "address", "->", "setForBilling", "(", "true", ")", ";", "$", "country", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'CoreBundle:Country'", ")", "->", "find", "(", "'es'", ")", ";", "$", "address", "->", "setCountry", "(", "$", "country", ")", ";", "$", "address", "->", "setActor", "(", "$", "actor", ")", ";", "}", "return", "$", "address", ";", "}" ]
Get billing address @return Address
[ "Get", "billing", "address" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L647-L674
240,590
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.isCurrentUserOwner
public function isCurrentUserOwner(Transaction $transaction) { if($this->securityContext->getToken()->getUser()->isGranted('ROLE_ADMIN')){ return true; } $currentUserId = $this->securityContext->getToken()->getUser()->getId(); //actor owner if($transaction->getActor() instanceof Actor){ if($currentUserId == $transaction->getActor()->getId()){ return true; }elseif($currentUserId == $transaction->getItems()->first()->getProduct()->getActor()->getId()){ return true; } } return false; }
php
public function isCurrentUserOwner(Transaction $transaction) { if($this->securityContext->getToken()->getUser()->isGranted('ROLE_ADMIN')){ return true; } $currentUserId = $this->securityContext->getToken()->getUser()->getId(); //actor owner if($transaction->getActor() instanceof Actor){ if($currentUserId == $transaction->getActor()->getId()){ return true; }elseif($currentUserId == $transaction->getItems()->first()->getProduct()->getActor()->getId()){ return true; } } return false; }
[ "public", "function", "isCurrentUserOwner", "(", "Transaction", "$", "transaction", ")", "{", "if", "(", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "{", "return", "true", ";", "}", "$", "currentUserId", "=", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", "->", "getId", "(", ")", ";", "//actor owner", "if", "(", "$", "transaction", "->", "getActor", "(", ")", "instanceof", "Actor", ")", "{", "if", "(", "$", "currentUserId", "==", "$", "transaction", "->", "getActor", "(", ")", "->", "getId", "(", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "currentUserId", "==", "$", "transaction", "->", "getItems", "(", ")", "->", "first", "(", ")", "->", "getProduct", "(", ")", "->", "getActor", "(", ")", "->", "getId", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if current user is the transaction owner @param Transaction $transaction @return boolean
[ "Check", "if", "current", "user", "is", "the", "transaction", "owner" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L683-L700
240,591
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.processBankTransfer
public function processBankTransfer(Transaction $transaction) { $transaction->setStatus(Transaction::STATUS_PENDING_TRANSFER); $pm = $this->manager->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('bank-transfer-test'); $transaction->setPaymentMethod($pm); $this->manager->persist($transaction); $this->manager->flush(); return true; }
php
public function processBankTransfer(Transaction $transaction) { $transaction->setStatus(Transaction::STATUS_PENDING_TRANSFER); $pm = $this->manager->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('bank-transfer-test'); $transaction->setPaymentMethod($pm); $this->manager->persist($transaction); $this->manager->flush(); return true; }
[ "public", "function", "processBankTransfer", "(", "Transaction", "$", "transaction", ")", "{", "$", "transaction", "->", "setStatus", "(", "Transaction", "::", "STATUS_PENDING_TRANSFER", ")", ";", "$", "pm", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:PaymentMethod'", ")", "->", "findOneBySlug", "(", "'bank-transfer-test'", ")", ";", "$", "transaction", "->", "setPaymentMethod", "(", "$", "pm", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "transaction", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Process a bank transfer request @param Transaction $transaction
[ "Process", "a", "bank", "transfer", "request" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L1549-L1559
240,592
sebardo/ecommerce
EcommerceBundle/Service/CheckoutManager.php
CheckoutManager.processRedsysTransaction
public function processRedsysTransaction($ds_response, Transaction $transaction) { if ($ds_response > 99) { return false; } $transaction->setStatus(Transaction::STATUS_PAID); $pm = $this->manager->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('redsys'); $transaction->setPaymentMethod($pm); $this->manager->persist($transaction); $this->manager->flush(); return true; }
php
public function processRedsysTransaction($ds_response, Transaction $transaction) { if ($ds_response > 99) { return false; } $transaction->setStatus(Transaction::STATUS_PAID); $pm = $this->manager->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('redsys'); $transaction->setPaymentMethod($pm); $this->manager->persist($transaction); $this->manager->flush(); return true; }
[ "public", "function", "processRedsysTransaction", "(", "$", "ds_response", ",", "Transaction", "$", "transaction", ")", "{", "if", "(", "$", "ds_response", ">", "99", ")", "{", "return", "false", ";", "}", "$", "transaction", "->", "setStatus", "(", "Transaction", "::", "STATUS_PAID", ")", ";", "$", "pm", "=", "$", "this", "->", "manager", "->", "getRepository", "(", "'EcommerceBundle:PaymentMethod'", ")", "->", "findOneBySlug", "(", "'redsys'", ")", ";", "$", "transaction", "->", "setPaymentMethod", "(", "$", "pm", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "transaction", ")", ";", "$", "this", "->", "manager", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Process a redsys transaction @param int $ds_response @param Transaction $transaction @return boolean
[ "Process", "a", "redsys", "transaction" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/CheckoutManager.php#L1569-L1583
240,593
themichaelhall/bluemvc-core
src/Collections/ResponseCookieCollection.php
ResponseCookieCollection.get
public function get(string $name): ?ResponseCookieInterface { if (!isset($this->responseCookies[$name])) { return null; } return $this->responseCookies[$name]; }
php
public function get(string $name): ?ResponseCookieInterface { if (!isset($this->responseCookies[$name])) { return null; } return $this->responseCookies[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "?", "ResponseCookieInterface", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "responseCookies", "[", "$", "name", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "responseCookies", "[", "$", "name", "]", ";", "}" ]
Returns the response cookie by name if it exists, null otherwise. @since 1.0.0 @param string $name The name. @return ResponseCookieInterface|null The response cookie by name if it exists, null otherwise.
[ "Returns", "the", "response", "cookie", "by", "name", "if", "it", "exists", "null", "otherwise", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/ResponseCookieCollection.php#L64-L71
240,594
themichaelhall/bluemvc-core
src/Collections/ResponseCookieCollection.php
ResponseCookieCollection.set
public function set(string $name, ResponseCookieInterface $responseCookie): void { $this->responseCookies[$name] = $responseCookie; }
php
public function set(string $name, ResponseCookieInterface $responseCookie): void { $this->responseCookies[$name] = $responseCookie; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "ResponseCookieInterface", "$", "responseCookie", ")", ":", "void", "{", "$", "this", "->", "responseCookies", "[", "$", "name", "]", "=", "$", "responseCookie", ";", "}" ]
Sets a response cookie by name. @since 1.0.0 @param string $name The name. @param ResponseCookieInterface $responseCookie The response cookie.
[ "Sets", "a", "response", "cookie", "by", "name", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/ResponseCookieCollection.php#L113-L116
240,595
Becklyn/BecklynSymfonyBase
src/LocalAccess.php
LocalAccess.isLocalIp
private function isLocalIp () { $ip = $this->serverData["REMOTE_ADDR"]; if (!is_string($ip)) { return false; } if (in_array($ip, ['127.0.0.1', 'fe80::1', '::1'], true)) { return true; } // allowed (= local) IPs include // 10.0.0.0 – 10.255.255.255 // 172.16.0.0 – 172.31.255.255 // 192.168.0.0 – 192.168.255.255 return 1 === preg_match("/^(10\\.|192\\.168\\.|172\\.(1[6-9]|2[0-9]|3[0-1])\\.)/", $ip); }
php
private function isLocalIp () { $ip = $this->serverData["REMOTE_ADDR"]; if (!is_string($ip)) { return false; } if (in_array($ip, ['127.0.0.1', 'fe80::1', '::1'], true)) { return true; } // allowed (= local) IPs include // 10.0.0.0 – 10.255.255.255 // 172.16.0.0 – 172.31.255.255 // 192.168.0.0 – 192.168.255.255 return 1 === preg_match("/^(10\\.|192\\.168\\.|172\\.(1[6-9]|2[0-9]|3[0-1])\\.)/", $ip); }
[ "private", "function", "isLocalIp", "(", ")", "{", "$", "ip", "=", "$", "this", "->", "serverData", "[", "\"REMOTE_ADDR\"", "]", ";", "if", "(", "!", "is_string", "(", "$", "ip", ")", ")", "{", "return", "false", ";", "}", "if", "(", "in_array", "(", "$", "ip", ",", "[", "'127.0.0.1'", ",", "'fe80::1'", ",", "'::1'", "]", ",", "true", ")", ")", "{", "return", "true", ";", "}", "// allowed (= local) IPs include", "// 10.0.0.0 – 10.255.255.255", "// 172.16.0.0 – 172.31.255.255", "// 192.168.0.0 – 192.168.255.255", "return", "1", "===", "preg_match", "(", "\"/^(10\\\\.|192\\\\.168\\\\.|172\\\\.(1[6-9]|2[0-9]|3[0-1])\\\\.)/\"", ",", "$", "ip", ")", ";", "}" ]
Returns whether remote IP is a local one @return bool
[ "Returns", "whether", "remote", "IP", "is", "a", "local", "one" ]
f912694c3e3ed46af37fe7ecf08bc503c77a5b41
https://github.com/Becklyn/BecklynSymfonyBase/blob/f912694c3e3ed46af37fe7ecf08bc503c77a5b41/src/LocalAccess.php#L69-L88
240,596
franzip/serp-page-serializer
src/SerpPageSerializer.php
SerpPageSerializer.serialize
public function serialize($serializablePage, $format) { // check if supported serialization format if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatSerialization)) throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedSerializationFormatException('Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.'); // typecheck the object to serialize if (!SerpPageSerializerHelper::serializablePage($serializablePage)) throw new \Franzip\SerpPageSerializer\Exceptions\NonSerializableObjectException('Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.'); $format = strtolower($format); $entries = $this->createEntries($serializablePage, $format); $serializablePage = $this->prepareForSerialization($serializablePage, $format, $entries); $serializedPage = $this->getSerializer()->serialize($serializablePage, $format); // beautify output if JSON $content = ($format == 'json') ? SerpPageSerializerHelper::prettyJSON($serializedPage) : $serializedPage; return new SerializedSerpPage($content); }
php
public function serialize($serializablePage, $format) { // check if supported serialization format if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatSerialization)) throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedSerializationFormatException('Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.'); // typecheck the object to serialize if (!SerpPageSerializerHelper::serializablePage($serializablePage)) throw new \Franzip\SerpPageSerializer\Exceptions\NonSerializableObjectException('Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.'); $format = strtolower($format); $entries = $this->createEntries($serializablePage, $format); $serializablePage = $this->prepareForSerialization($serializablePage, $format, $entries); $serializedPage = $this->getSerializer()->serialize($serializablePage, $format); // beautify output if JSON $content = ($format == 'json') ? SerpPageSerializerHelper::prettyJSON($serializedPage) : $serializedPage; return new SerializedSerpPage($content); }
[ "public", "function", "serialize", "(", "$", "serializablePage", ",", "$", "format", ")", "{", "// check if supported serialization format", "if", "(", "!", "SerpPageSerializerHelper", "::", "validFormat", "(", "$", "format", ",", "self", "::", "$", "supportedFormatSerialization", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpPageSerializer", "\\", "Exceptions", "\\", "UnsupportedSerializationFormatException", "(", "'Invalid SerpPageSerializer $format: supported serialization formats are JSON, XML and YAML.'", ")", ";", "// typecheck the object to serialize", "if", "(", "!", "SerpPageSerializerHelper", "::", "serializablePage", "(", "$", "serializablePage", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpPageSerializer", "\\", "Exceptions", "\\", "NonSerializableObjectException", "(", "'Invalid SerpPageSerializer $serializablePage: you must supply a SerializableSerpPage object to serialize.'", ")", ";", "$", "format", "=", "strtolower", "(", "$", "format", ")", ";", "$", "entries", "=", "$", "this", "->", "createEntries", "(", "$", "serializablePage", ",", "$", "format", ")", ";", "$", "serializablePage", "=", "$", "this", "->", "prepareForSerialization", "(", "$", "serializablePage", ",", "$", "format", ",", "$", "entries", ")", ";", "$", "serializedPage", "=", "$", "this", "->", "getSerializer", "(", ")", "->", "serialize", "(", "$", "serializablePage", ",", "$", "format", ")", ";", "// beautify output if JSON", "$", "content", "=", "(", "$", "format", "==", "'json'", ")", "?", "SerpPageSerializerHelper", "::", "prettyJSON", "(", "$", "serializedPage", ")", ":", "$", "serializedPage", ";", "return", "new", "SerializedSerpPage", "(", "$", "content", ")", ";", "}" ]
Serialize a SerializableSerpPage object in the target format @param SerializableSerpPage $serializablePage @param string $format @return string
[ "Serialize", "a", "SerializableSerpPage", "object", "in", "the", "target", "format" ]
d3b67682e9a5ef87dcd56fb4191a23c4eeebc716
https://github.com/franzip/serp-page-serializer/blob/d3b67682e9a5ef87dcd56fb4191a23c4eeebc716/src/SerpPageSerializer.php#L58-L74
240,597
franzip/serp-page-serializer
src/SerpPageSerializer.php
SerpPageSerializer.deserialize
public function deserialize($serializedPage, $format) { // check if supported deserialization format if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatDeserialization)) throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedDeserializationFormatException('Invalid SerpPageSerializer $format: supported deserialization formats are JSON and XML.'); // TODO: typecheck object if (!SerpPageSerializerHelper::deserializablePage($serializedPage)) throw new \Franzip\SerpPageSerializer\Exceptions\RuntimeException('Invalid SerpPageSerializer $serializedPage: you must supply a SerializedSerpPage object to deserialize.'); $format = strtolower($format); $targetClass = self::SERIALIZABLE_OBJECT_PREFIX . strtoupper($format); return $this->getSerializer()->deserialize($serializedPage->getContent(), $targetClass, $format); }
php
public function deserialize($serializedPage, $format) { // check if supported deserialization format if (!SerpPageSerializerHelper::validFormat($format, self::$supportedFormatDeserialization)) throw new \Franzip\SerpPageSerializer\Exceptions\UnsupportedDeserializationFormatException('Invalid SerpPageSerializer $format: supported deserialization formats are JSON and XML.'); // TODO: typecheck object if (!SerpPageSerializerHelper::deserializablePage($serializedPage)) throw new \Franzip\SerpPageSerializer\Exceptions\RuntimeException('Invalid SerpPageSerializer $serializedPage: you must supply a SerializedSerpPage object to deserialize.'); $format = strtolower($format); $targetClass = self::SERIALIZABLE_OBJECT_PREFIX . strtoupper($format); return $this->getSerializer()->deserialize($serializedPage->getContent(), $targetClass, $format); }
[ "public", "function", "deserialize", "(", "$", "serializedPage", ",", "$", "format", ")", "{", "// check if supported deserialization format", "if", "(", "!", "SerpPageSerializerHelper", "::", "validFormat", "(", "$", "format", ",", "self", "::", "$", "supportedFormatDeserialization", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpPageSerializer", "\\", "Exceptions", "\\", "UnsupportedDeserializationFormatException", "(", "'Invalid SerpPageSerializer $format: supported deserialization formats are JSON and XML.'", ")", ";", "// TODO: typecheck object", "if", "(", "!", "SerpPageSerializerHelper", "::", "deserializablePage", "(", "$", "serializedPage", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpPageSerializer", "\\", "Exceptions", "\\", "RuntimeException", "(", "'Invalid SerpPageSerializer $serializedPage: you must supply a SerializedSerpPage object to deserialize.'", ")", ";", "$", "format", "=", "strtolower", "(", "$", "format", ")", ";", "$", "targetClass", "=", "self", "::", "SERIALIZABLE_OBJECT_PREFIX", ".", "strtoupper", "(", "$", "format", ")", ";", "return", "$", "this", "->", "getSerializer", "(", ")", "->", "deserialize", "(", "$", "serializedPage", "->", "getContent", "(", ")", ",", "$", "targetClass", ",", "$", "format", ")", ";", "}" ]
Deserialize a serialized page. YAML deserialization is not currently supported. @param SerializedSerpPage $serializedPage @param string $format @return SerializableSerpPage
[ "Deserialize", "a", "serialized", "page", ".", "YAML", "deserialization", "is", "not", "currently", "supported", "." ]
d3b67682e9a5ef87dcd56fb4191a23c4eeebc716
https://github.com/franzip/serp-page-serializer/blob/d3b67682e9a5ef87dcd56fb4191a23c4eeebc716/src/SerpPageSerializer.php#L83-L95
240,598
franzip/serp-page-serializer
src/SerpPageSerializer.php
SerpPageSerializer.prepareForSerialization
private function prepareForSerialization($serializablePage, $format, $entries) { $engine = $serializablePage->getEngine(); $keyword = $serializablePage->getKeyword(); $pageUrl = $serializablePage->getPageUrl(); $pageNumber = $serializablePage->getPageNumber(); $age = $serializablePage->getAge(); return self::getFormatClassName($format, array($engine, $pageNumber, $pageUrl, $keyword, $age, $entries)); }
php
private function prepareForSerialization($serializablePage, $format, $entries) { $engine = $serializablePage->getEngine(); $keyword = $serializablePage->getKeyword(); $pageUrl = $serializablePage->getPageUrl(); $pageNumber = $serializablePage->getPageNumber(); $age = $serializablePage->getAge(); return self::getFormatClassName($format, array($engine, $pageNumber, $pageUrl, $keyword, $age, $entries)); }
[ "private", "function", "prepareForSerialization", "(", "$", "serializablePage", ",", "$", "format", ",", "$", "entries", ")", "{", "$", "engine", "=", "$", "serializablePage", "->", "getEngine", "(", ")", ";", "$", "keyword", "=", "$", "serializablePage", "->", "getKeyword", "(", ")", ";", "$", "pageUrl", "=", "$", "serializablePage", "->", "getPageUrl", "(", ")", ";", "$", "pageNumber", "=", "$", "serializablePage", "->", "getPageNumber", "(", ")", ";", "$", "age", "=", "$", "serializablePage", "->", "getAge", "(", ")", ";", "return", "self", "::", "getFormatClassName", "(", "$", "format", ",", "array", "(", "$", "engine", ",", "$", "pageNumber", ",", "$", "pageUrl", ",", "$", "keyword", ",", "$", "age", ",", "$", "entries", ")", ")", ";", "}" ]
Map SerializableSerpPage to an easy serializable SerpPage. The serialization format is resolved at runtime. @param SerializableSerpPage $serializablePage @param string $format @param array $entries @return SerpPageJSON|SerpPageXML|SerpPageYML
[ "Map", "SerializableSerpPage", "to", "an", "easy", "serializable", "SerpPage", ".", "The", "serialization", "format", "is", "resolved", "at", "runtime", "." ]
d3b67682e9a5ef87dcd56fb4191a23c4eeebc716
https://github.com/franzip/serp-page-serializer/blob/d3b67682e9a5ef87dcd56fb4191a23c4eeebc716/src/SerpPageSerializer.php#L114-L123
240,599
franzip/serp-page-serializer
src/SerpPageSerializer.php
SerpPageSerializer.createEntries
private function createEntries($serializablePage, $format) { $result = array(); $entries = $serializablePage->getEntries(); for ($i = 0; $i < count($entries); $i++) { $args = array(($i + 1), $entries[$i]['url'], $entries[$i]['title'], $entries[$i]['snippet']); array_push($result, self::getFormatClassName($format, $args, true)); } return $result; }
php
private function createEntries($serializablePage, $format) { $result = array(); $entries = $serializablePage->getEntries(); for ($i = 0; $i < count($entries); $i++) { $args = array(($i + 1), $entries[$i]['url'], $entries[$i]['title'], $entries[$i]['snippet']); array_push($result, self::getFormatClassName($format, $args, true)); } return $result; }
[ "private", "function", "createEntries", "(", "$", "serializablePage", ",", "$", "format", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "entries", "=", "$", "serializablePage", "->", "getEntries", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "entries", ")", ";", "$", "i", "++", ")", "{", "$", "args", "=", "array", "(", "(", "$", "i", "+", "1", ")", ",", "$", "entries", "[", "$", "i", "]", "[", "'url'", "]", ",", "$", "entries", "[", "$", "i", "]", "[", "'title'", "]", ",", "$", "entries", "[", "$", "i", "]", "[", "'snippet'", "]", ")", ";", "array_push", "(", "$", "result", ",", "self", "::", "getFormatClassName", "(", "$", "format", ",", "$", "args", ",", "true", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Map SerializableSerpPage entries to SerpPageEntries. The serialization format is resolved at runtime. @param SerializableSerpPage $serializablePage @param string $format @return SerpPageEntryJSON|SerpPageEntryXML|SerpPageEntryYAML
[ "Map", "SerializableSerpPage", "entries", "to", "SerpPageEntries", ".", "The", "serialization", "format", "is", "resolved", "at", "runtime", "." ]
d3b67682e9a5ef87dcd56fb4191a23c4eeebc716
https://github.com/franzip/serp-page-serializer/blob/d3b67682e9a5ef87dcd56fb4191a23c4eeebc716/src/SerpPageSerializer.php#L132-L141