idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
235,400
public function removeTransactionMethod ( $ method ) { if ( ! is_array ( $ this -> transactionMethods ) ) { return $ this ; } $ index = array_search ( $ method , $ this -> transactionMethods ) ; if ( $ index !== false ) { array_splice ( $ this -> transactionMethods , $ index , 1 ) ; } if ( empty ( $ this -> transaction...
Remove transaction method .
235,401
protected function proxy ( $ method , $ args ) { $ this -> beforeProxy ( $ method , $ args ) ; $ result = call_user_func_array ( array ( $ this , $ method ) , $ args ) ; $ this -> afterProxy ( $ method , $ args , $ result ) ; return $ result ; }
Proxy function through which domain methods will be called This method should be overridden in extending classes
235,402
protected function beforeProxy ( $ method , $ args ) { if ( is_array ( $ this -> transactionMethods ) && in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> db -> beginTransaction ( ) ; } }
Logic before proxy call to domain method
235,403
protected function afterProxy ( $ method , $ args , $ result ) { if ( is_array ( $ this -> transactionMethods ) && in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> db -> commit ( ) ; } }
Logic after proxy call to domain method
235,404
public function update ( $ id , $ model ) { $ args = func_get_args ( ) ; $ result = $ this -> proxy ( '_update' , $ args ) ; return $ result ; }
DB UPDATE of object
235,405
public function post2FALogin ( Request $ request ) { $ userId = $ request -> session ( ) -> get ( 'user_id' ) ; if ( $ this -> twoFactorAuthHelper -> isTwoFactorAuthFormTimeout ( $ userId ) ) { return view ( 'usermanagement::frontend.' . $ this -> frontend_template_name . '.login.login' , [ 'title' => 'Login' , ] ) -> ...
Handle the front - end Two Factor Authorization login
235,406
public function request ( $ endpoint , $ isPost = false , $ params = array ( ) ) { $ accessToken = $ this -> getAccessToken ( ) ; if ( $ accessToken === null ) { return null ; } $ params [ 'accessToken' ] = $ accessToken -> getAccessToken ( ) ; $ url = $ this -> getConfig ( ) -> getApiUrl ( ) . $ endpoint ; if ( ! $ is...
Request an API endpoint with post or get method and given parameters . Returns null if no AccessToken is provided
235,407
private function evaluateDirectory ( $ directory = null ) { $ directory = $ this -> setDirectoryFallback ( $ directory ) ; $ this -> run ( $ directory ) ; }
Walk through directory
235,408
public function remove ( $ key ) { if ( $ key instanceof UniqueId ) { $ key = $ key -> id ( ) ; } return $ this -> elements -> remove ( $ key ) ; }
Removes the element at the specified index from the collection .
235,409
public function map ( Closure $ func ) { return new static ( $ this -> type , $ this -> elements -> map ( $ func ) -> toArray ( ) ) ; }
Applies the given public function to each element in the collection and returns a new collection with the elements returned by the public function .
235,410
public static function validate ( $ data , $ type , callable $ filter = null ) { $ type = strtoupper ( $ type ) ; if ( ! array_key_exists ( $ type , self :: $ supported_types ) ) { throw new UnexpectedValueException ( "Bad validation type" ) ; } return call_user_func ( self :: $ supported_types [ $ type ] , $ data , $ ...
Generic validator .
235,411
public static function validateString ( $ data , callable $ filter = null ) { if ( is_string ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
String validator .
235,412
public static function validateBoolean ( $ data , callable $ filter = null ) { if ( is_bool ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Bool validator .
235,413
public static function validateInteger ( $ data , callable $ filter = null ) { if ( is_int ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Int validator .
235,414
public static function validateNumeric ( $ data , callable $ filter = null ) { if ( is_numeric ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Numeric validator .
235,415
public static function validateFloat ( $ data , callable $ filter = null ) { if ( is_float ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Float validator .
235,416
public static function validateJson ( $ data , callable $ filter = null ) { $ decoded = json_decode ( $ data ) ; if ( is_null ( $ decoded ) ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Json validator .
235,417
public static function validateSerialized ( $ data , callable $ filter = null ) { $ decoded = @ unserialize ( $ data ) ; if ( $ decoded === false && $ data != @ serialize ( false ) ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Serialized values validator .
235,418
public static function validateDatetimeIso8601 ( $ data , callable $ filter = null ) { if ( DateTime :: createFromFormat ( DateTime :: ATOM , $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; }
Iso8601 - datetime validator .
235,419
public static function validateBase64 ( $ data , callable $ filter = null ) { return base64_encode ( base64_decode ( $ data , true ) ) === $ data ? self :: applyFilter ( $ data , $ filter ) : false ; }
Base64 validator .
235,420
public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'toolba...
Loads the terrific composer configuration .
235,421
protected function parseFragment ( $ name ) { $ fileName = $ this -> loader -> findFilename ( $ name ) ; $ html5 = new HTML5 ( ) ; $ dom = $ html5 -> loadHTMLFragment ( file_get_contents ( $ fileName ) ) ; if ( $ html5 -> getErrors ( ) ) { $ errors = "" ; foreach ( $ html5 -> getErrors ( ) as $ error ) { $ errors .= "\...
Parses an HTML Togu component
235,422
public static function underscoreToCamelCase ( $ string ) { static $ cache = array ( ) ; if ( array_key_exists ( $ string , $ cache ) == true ) { return $ cache [ $ string ] ; } $ replacer = function ( array $ matches ) { return strtoupper ( $ matches [ 1 ] ) ; } ; return $ cache [ $ string ] = preg_replace_callback ( ...
Convert a underscore defined string to his camelCase format
235,423
public static function camelCaseToUnderscore ( $ string ) { static $ cache = array ( ) ; if ( array_key_exists ( $ string , $ cache ) === true ) { return $ cache [ $ string ] ; } $ replacer = function ( array $ matches ) { return '_' . strtolower ( $ matches [ 0 ] ) ; } ; return $ cache [ $ string ] = preg_replace_call...
Convert a camelCased defined string to his underscore format
235,424
public function setStream ( PsrStreamInterface $ stream ) { $ this -> stream = $ stream ; $ this -> error = UPLOAD_ERR_OK ; return true ; }
Set the stream which this uploaded file refers to .
235,425
public function addImageSizeDefinition ( ImageResizeDefinition $ ird ) { $ this -> image_resize_definitions [ $ ird -> getWidth ( ) ] = $ ird ; ksort ( $ this -> image_resize_definitions ) ; }
Add another allowed image size
235,426
public function getImageResizeDefinitionForWidth ( $ width , $ fit_in_width = false ) { if ( empty ( $ this -> image_resize_definitions ) ) { return null ; } if ( $ fit_in_width ) { foreach ( $ this -> image_resize_definitions as $ w => $ ird ) { if ( $ w > $ width && isset ( $ prev_ird ) ) { return $ prev_ird ; } else...
Get nearest available ImageSizeDefinition for given screen width
235,427
protected function isCachedById ( int $ id , int $ siteId = null ) { $ siteId = SiteHelper :: resolveSiteId ( $ siteId ) ; if ( ! isset ( $ this -> cacheById [ $ siteId ] ) ) { $ this -> cacheById [ $ siteId ] = [ ] ; } return array_key_exists ( $ id , $ this -> cacheById [ $ siteId ] ) ; }
Identify whether in cached by ID
235,428
public static function getEnv ( ) { if ( null !== ( getenv ( 'P_DRIVER' ) ) ) { $ dotEnv = new Dotenv ( $ _SERVER [ 'DOCUMENT_ROOT' ] ) ; $ dotEnv -> load ( ) ; } self :: $ driver = getenv ( 'P_DRIVER' ) ; self :: $ host = getenv ( 'P_HOST' ) ; self :: $ dbname = getenv ( 'P_DBNAME' ) ; self :: $ user = getenv ( 'P_USE...
Get environment values from . env file
235,429
public static function connect ( ) { self :: getEnv ( ) ; return new PDO ( self :: $ driver . ':host=' . self :: $ host . ';dbname=' . self :: $ dbname , self :: $ user , self :: $ pass ) ; }
Create PDO connections
235,430
private function propertyNeedsMapping ( ClassMetadata $ class , \ ReflectionProperty $ property ) { if ( $ class -> isMappedSuperclass && ! $ property -> isPrivate ( ) ) { return false ; } $ inherited = $ class -> hasAttribute ( $ property -> name ) && $ class -> getPropertyMetadata ( $ property -> name ) -> isInherite...
Check if the specified property needs to be mapped .
235,431
public function removeGroup ( GroupInterface $ group ) : void { if ( ! $ group instanceof Production ) { throw new Exception ( 'Group type not supported.' ) ; } $ this -> groups -> removeElement ( $ group ) ; }
Remove group .
235,432
public function addEvent ( Event $ event ) : self { $ event -> setSchedule ( $ this ) ; $ this -> events [ ] = $ event ; return $ this ; }
Add event .
235,433
public function getStart ( ) : ? \ DateTimeInterface { $ lowest_date = null ; foreach ( $ this -> events as $ event ) { if ( null === $ lowest_date || $ event -> getStart ( ) < $ lowest_date ) { $ lowest_date = $ event -> getStart ( ) ; } } return $ lowest_date ; }
Get the start date of the schedule .
235,434
public function getEnd ( ) : ? \ DateTimeInterface { $ highest_date = null ; foreach ( $ this -> events as $ event ) { if ( null === $ highest_date || $ event -> getEnd ( ) > $ highest_date ) { $ highest_date = $ event -> getEnd ( ) ; } } return $ highest_date ; }
Get the end date of the schedule .
235,435
public static function parse ( $ content ) { $ matter = array ( ) ; $ text = str_replace ( PHP_EOL , $ id = uniqid ( ) , $ content ) ; $ regex = '/^---' . $ id . '(.*?)' . $ id . '---/' ; if ( preg_match ( $ regex , $ text , $ matches ) === 1 ) { $ yaml = str_replace ( $ id , PHP_EOL , $ matches [ 1 ] ) ; $ matter = ( ...
Retrieves the contents from a YAML format .
235,436
public function setValue ( $ value ) { if ( is_string ( $ value ) && strlen ( $ value ) > 100 ) { $ value = substr ( $ value , 0 , 96 ) . '...' ; } $ this -> value = $ value ; }
Set the value in the field that failed to validate
235,437
public function setApplication ( ApplicationInterface $ application ) { $ this -> setParam ( 'application' , $ application ) ; $ this -> application = $ application ; return $ this ; }
Set application instance
235,438
protected function Wordings ( ) { $ result = array ( ) ; $ result [ ] = 'Success' ; $ result [ ] = 'Error' ; $ result [ ] = 'Password' ; $ result [ ] = 'Password.Validation.Required.Missing' ; $ result [ ] = 'PasswordRepeat' ; $ result [ ] = 'PasswordRepeat.Validation.Required.Missing' ; $ result [ ] = 'PasswordRepeat....
Returns the wording labels for success and error
235,439
public static function create ( $ template = null , $ action = null , $ method = 'POST' , $ encType = null ) { return new static ( $ template , $ action , $ method , $ encType ) ; }
Create instance allows chaining
235,440
public function bindRequestParameters ( ParameterBag $ bag = null ) { if ( $ bag ) { $ this -> requestValues = $ bag ; } else { if ( $ this -> request -> getMethod ( ) == 'GET' ) { $ this -> requestValues = $ this -> request -> query ; } else { $ this -> requestValues = $ this -> request -> request ; } } foreach ( $ th...
initialize parameter bag parameterbag is either supplied or depending on request method retrieved from request object
235,441
public function setMethod ( $ method ) { $ method = strtoupper ( $ method ) ; if ( $ method != 'GET' && $ method != 'POST' ) { throw new HtmlFormException ( sprintf ( "Invalid form method: '%s'." , $ method ) , HtmlFormException :: INVALID_METHOD ) ; } $ this -> method = $ method ; return $ this ; }
set submission method GET and POST are the only allowed values
235,442
public function setAttribute ( $ attr , $ value ) { $ attr = strtolower ( $ attr ) ; switch ( $ attr ) { case 'action' : $ this -> setAction ( $ value ) ; return $ this ; case 'enctype' : $ this -> setEncType ( $ value ) ; return $ this ; case 'method' : $ this -> setMethod ( $ value ) ; return $ this ; default : $ thi...
set miscellaneous attribute of form
235,443
public function getAttribute ( $ attr , $ default = null ) { return ( $ attr && array_key_exists ( $ attr , $ this -> attributes ) ) ? $ this -> attributes [ $ attr ] : $ default ; }
get an attribute if the attribute was not set previously a default value can be supplied
235,444
public function setAttributes ( array $ attrs ) { foreach ( $ attrs as $ k => $ v ) { $ this -> setAttribute ( $ k , $ v ) ; } return $ this ; }
sets sevaral form attributes stored in associative array
235,445
public function getSubmittingElement ( ) { if ( ! empty ( $ this -> clickedSubmit ) ) { return $ this -> clickedSubmit ; } if ( is_null ( $ this -> requestValues ) ) { return null ; } foreach ( $ this -> elements as $ name => $ e ) { if ( is_array ( $ e ) ) { foreach ( $ this -> requestValues -> keys ( ) as $ k ) { if ...
Returns FormElement which submitted form result is cached
235,446
public function render ( ) { if ( $ this -> loadTemplate ( ) ) { $ this -> primeTemplate ( ) -> insertFormFields ( ) -> insertErrorMessages ( ) -> insertFormStart ( ) -> insertFormEnd ( ) -> cleanupHtml ( ) ; return $ this -> html ; } }
renders complete form markup
235,447
public function getValidFormValues ( $ getSubmits = false ) { if ( is_null ( $ this -> requestValues ) ) { throw new HtmlFormException ( 'Values can not be evaluated. No request bound.' , HtmlFormException :: NO_REQUEST_BOUND ) ; } $ tmp = new ValuesBag ( ) ; foreach ( $ this -> elements as $ name => $ e ) { if ( is_ar...
deliver all valid form values
235,448
public function setInitFormValues ( array $ values ) { $ this -> initFormValues = $ values ; foreach ( $ values as $ name => $ value ) { if ( isset ( $ this -> elements [ $ name ] ) && is_object ( $ this -> elements [ $ name ] ) ) { if ( $ this -> elements [ $ name ] instanceof CheckboxElement ) { if ( empty ( $ this -...
sets initial form values stored in associative array values will only be applied to elements with previously declared value NULL checkbox elements will be checked when their value equals form value
235,449
public function setError ( $ errorName , $ errorNameIndex = null , $ message = null ) { if ( is_null ( $ errorNameIndex ) ) { $ this -> formErrors [ $ errorName ] = new FormError ( $ message ) ; } else { $ this -> formErrors [ $ errorName ] [ $ errorNameIndex ] = new FormError ( $ message ) ; } return $ this ; }
add custom error and force error message in template
235,450
public function getElementsByName ( $ name ) { if ( isset ( $ this -> elements [ $ name ] ) ) { return $ this -> elements [ $ name ] ; } throw new \ InvalidArgumentException ( sprintf ( "Unknown form element '%s'" , $ name ) ) ; }
get one or more elements by name
235,451
public function addElement ( FormElement $ element ) { if ( ! empty ( $ this -> elements [ $ element -> getName ( ) ] ) ) { throw new HtmlFormException ( sprintf ( "Element '%s' already assigned." , $ element -> getName ( ) ) ) ; } $ this -> elements [ $ element -> getName ( ) ] = $ element ; $ element -> setForm ( $ t...
add form element to form
235,452
public function addElementArray ( array $ elements ) { if ( count ( $ elements ) ) { $ firstElement = array_shift ( $ elements ) ; $ name = $ firstElement -> getName ( ) ; $ name = preg_replace ( '~\[\w*\]$~i' , '' , $ name ) ; if ( ! empty ( $ this -> elements [ $ name ] ) ) { throw new HtmlFormException ( sprintf ( "...
add several form elements stored in array to form
235,453
private function renderCsrfToken ( ) { $ tokenManager = new CsrfTokenManager ( ) ; $ token = $ tokenManager -> refreshToken ( '_' . $ this -> action . '_' ) ; $ e = new InputElement ( self :: CSRF_TOKEN_NAME , $ token -> getValue ( ) ) ; $ e -> setAttribute ( 'type' , 'hidden' ) ; return $ e -> render ( ) ; }
render CSRF token element the token will use the form action as id
235,454
private function checkCsrfToken ( ) { $ tokenManager = new CsrfTokenManager ( ) ; $ token = new CsrfToken ( '_' . $ this -> action . '_' , $ this -> requestValues -> get ( self :: CSRF_TOKEN_NAME ) ) ; return $ tokenManager -> isTokenValid ( $ token ) ; }
check whether a CSRF token remained untainted compares the stored token with the request value
235,455
private function renderAntiSpam ( ) { $ secret = md5 ( uniqid ( null , true ) ) ; $ label = md5 ( $ secret ) ; Session :: getSessionDataBag ( ) -> set ( 'antiSpamTimer' , [ $ secret => microtime ( true ) ] ) ; $ e = new InputElement ( 'verify' , null ) ; $ e -> setAttribute ( 'type' , 'hidden' ) ; $ this -> addElement ...
render spam countermeasures
235,456
public function detectSpam ( array $ fields = [ ] , $ threshold = 3 ) { $ verify = $ this -> requestValues -> get ( 'verify' ) ; $ timer = Session :: getSessionDataBag ( ) -> get ( 'antiSpamTimer' ) ; if ( ! $ verify || ! isset ( $ timer [ $ verify ] ) || ( microtime ( true ) - $ timer [ $ verify ] < 1 ) ) { return tru...
check for spam
235,457
private function insertFormFields ( ) { $ this -> html = preg_replace_callback ( '/\{\s*(dropdown|input|image|button|textarea|options|checkbox|selectbox|label|element):(\w+)(?:\s+(\{.*?\}))?\s*\}/i' , function ( $ matches ) { if ( empty ( $ this -> elements [ $ matches [ 2 ] ] ) ) { if ( $ this -> onlyAssignedElements ...
insert form fields into template
235,458
private function insertErrorMessages ( ) { $ rex = '/\{(?:\w+\|)*error_%s(?:\|\w+)*:([^\}]+)\}/i' ; foreach ( $ this -> formErrors as $ name => $ v ) { if ( ! is_array ( $ v ) ) { $ this -> html = preg_replace ( sprintf ( $ rex , $ name ) , '$1' , $ this -> html ) ; } else { foreach ( array_keys ( $ this -> formErrors ...
insert error messages into template placeholder for error messages are replaced
235,459
public function match ( ) { $ requestUrl = isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '/' ; $ method = $ this -> getRequestMethod ( ) ; $ uri = $ this -> getCurrentUri ( ) ; foreach ( $ this -> routes [ $ method ] as $ route ) { if ( preg_match_all ( '#^' . $ route [ 'pattern' ] . '$#' , $ ur...
match a current request
235,460
private static function determinePlaceholderPosition ( $ query , $ index , array $ placeholdersPositions = array ( ) ) { $ placeholderPosition = null ; $ previousIndex = $ index - 1 ; while ( ( $ previousIndex >= 0 ) && ( $ placeholderPosition === null ) ) { if ( isset ( $ placeholdersPositions [ $ previousIndex ] ) ) ...
Determines the placeholder position in the query .
235,461
private static function rewriteQuery ( $ query , $ placeholderPosition , array $ newPlaceholders ) { return substr ( $ query , 0 , $ placeholderPosition ) . implode ( ', ' , $ newPlaceholders ) . substr ( $ query , $ placeholderPosition + 1 ) ; }
Rewrites the query according to the placeholder position and new placeholders .
235,462
private static function rewriteParameterAndType ( array $ parameters , array $ types , $ index ) { $ parameterValue = $ parameters [ $ index ] ; $ parameterCount = count ( $ parameterValue ) ; $ type = static :: extractType ( $ types [ $ index ] ) ; $ minPosition = $ index ; $ maxPosition = max ( array_keys ( $ paramet...
Rewrites the parameter & type according to the parameter index .
235,463
public function activate ( Composer $ composer , IOInterface $ io ) { $ this -> assetsInstaller = new AssetsInstaller ( $ composer , $ io ) ; }
Initializes the plugin Reads the composer . json file and retrieves the assets - dir set if any . This assets - dir is the path where the other packages assets will be installed
235,464
public function addCriteria ( array $ criteria ) { foreach ( $ criteria as $ key => $ value ) { $ this -> attr ( $ key ) -> matches ( $ value ) ; } return $ this ; }
Add an array of criteria to the expression as AND clauses .
235,465
public function addOr ( Expr $ subexpression ) { $ or = new Condition \ Logical \ AddOr ; $ or -> add ( ... array_map ( function ( Expr $ expr ) { return $ expr -> condition ; } , func_get_args ( ) ) ) ; $ this -> addCondition ( $ or ) ; return $ this ; }
Add one or more OR clauses to the expression .
235,466
public function attr ( $ name , $ discriminatorValue = null ) { if ( empty ( $ name ) ) { throw new \ InvalidArgumentException ; } return new Operand \ Attribute ( $ this , $ name , $ discriminatorValue ) ; }
Return an attribute object used for building an expression .
235,467
public function not ( Expr $ subexpression ) { $ not = new Condition \ Logical \ Not ; $ not -> add ( $ subexpression -> condition ) ; return $ this ; }
Add a NOT clause to the expression .
235,468
public function value ( $ value ) { if ( ! $ value instanceof Operand \ OperandInterface && ! $ value instanceof Update \ Func ) { $ value = new Operand \ Value ( $ this , $ value ) ; } return $ value ; }
Return a value object used for building an expression .
235,469
private function getNextTag ( & $ s , $ i , & $ position ) { $ j = mb_strpos ( $ s , '[' , $ i ) ; $ k = mb_strpos ( $ s , ']' , $ j + 1 ) ; if ( $ j === false || $ k === false ) { $ position = false ; return null ; } $ t = mb_substr ( $ s , $ j + 1 , $ k - ( $ j + 1 ) ) ; $ l = mb_strrpos ( $ t , '[' ) ; if ( $ l !== ...
Gets the next tag
235,470
private function formatString ( $ s ) { static $ last_tag = null ; if ( $ this -> m_stack -> count ( ) > 0 && $ this -> m_stack -> top ( ) -> isOfType ( self :: TAG_PRE ) ) { return $ s ; } if ( $ last_tag !== null ) { } if ( $ last_tag !== null && $ last_tag -> isOfType ( self :: TAG_INLINE ) ) { $ s = preg_replace ( ...
Formats small pieces of CDATA
235,471
private function printCData ( & $ cdata , $ outline = false ) { $ cdata = trim ( $ cdata ) ; $ ret = '' ; if ( $ cdata === '' ) { return $ ret ; } if ( $ outline || ( mb_strpos ( $ cdata , "\n" ) ) || ( $ this -> m_stack -> count ( ) > 0 && $ this -> m_stack -> top ( ) -> isOfType ( self :: TAG_FORCE_PARAGRAPHS ) ) ) {...
Formats whole blocks of CDATA
235,472
public function nth ( $ position ) { if ( $ position < 0 ) { $ position = $ this -> count ( ) + $ position ; } if ( $ position < 0 || $ this -> count ( ) < $ position ) { throw new \ InvalidArgumentException ( 'Invalid Position' ) ; } $ slice = array_slice ( $ this -> items , $ position , 1 ) ; return empty ( $ slice )...
Get the nth item in the collection .
235,473
public function implode ( $ glue = '' , callable $ callback = null ) { return implode ( $ glue , $ callback ? array_map ( $ callback , $ this -> items ) : $ this -> items ) ; }
Implode the collection values .
235,474
public function display ( ) { $ msg = Str :: replace ( root , '$DOCUMENT_ROOT' , $ this -> getMessage ( ) ) ; $ msg = App :: $ Security -> strip_tags ( $ msg ) ; $ this -> text = App :: $ Translate -> get ( 'Default' , $ this -> text , [ 'e' => $ msg ] ) ; if ( env_type !== 'html' ) { if ( env_type === 'json' ) { retur...
Display exception template
235,475
protected function buildFakePage ( ) { try { $ rawResponse = App :: $ View -> render ( '_core/exceptions/' . $ this -> tpl , [ 'msg' => $ this -> text ] ) ; if ( Str :: likeEmpty ( $ rawResponse ) ) { $ rawResponse = $ this -> text ; } } catch ( \ Exception $ e ) { $ rawResponse = $ this -> text ; } App :: $ Response -...
Build fake page with error based on fake controller initiation
235,476
public static function emitter ( ) : EmitterInterface { if ( ! isset ( self :: $ emitter_map [ static :: class ] ) ) { $ class = array_reverse ( array_values ( class_parents ( static :: class ) ) ) [ 1 ] ?? static :: class ; self :: $ emitter_map [ static :: class ] = self :: $ emitter_map [ $ class ] ?? ( self :: $ em...
Get the event s emitter to manipulate callbacks for the event
235,477
public function build ( string $ bodyCssClass = self :: DEFAULT_BODY_CSS_CLASS ) : string { $ page = $ this -> pageService -> getCurrentPage ( ) ; $ backendLayout = $ this -> pageService -> getBackendLayoutForPage ( $ page [ 'uid' ] ) ; if ( ! empty ( $ backendLayout ) ) { $ bodyCssClass = "{$backendLayout} {$bodyCssCl...
Builds a body tag .
235,478
function addmeta ( $ name , $ values = null ) { if ( $ values != null ) { foreach ( $ values as $ value ) { $ this -> add ( $ name , $ value ) ; } } return $ this ; }
Convenient way to add multiple meta attributes in a single call .
235,479
public function add ( SplFileInfo $ splFileInfo ) { $ fileSystem = new Filesystem ( ) ; if ( ! $ fileSystem -> exists ( $ splFileInfo -> getRealPath ( ) ) ) { throw new Exception ( 'Trying to add ' . $ splFileInfo -> getRealPath ( ) . ' missing file to the index' ) ; } if ( $ this -> has ( $ splFileInfo -> getRealPath ...
Add an entry to the indexer . If a entry already exists it will also be added to the changes .
235,480
public static function getDiscountByCode ( $ request , $ code ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOr404 ( $ code ) ; $ discountEngine = $ discount -> get_engine ( ) ; $ validationCode = $ discountEngine -> validate ( $ discount , $ request ) ; $ discount -> __set ( 'validation_code' , $ validationCode ...
Returns tag with given name .
235,481
public function getBundleVendorDir ( ) { $ psr4Path = $ this -> getRootDir ( ) . '/../vendor/rch/capistrano-bundle' ; $ psr0Path = $ psr4Path . '/RCH/CapistranoBundle' ; if ( is_dir ( $ psr0Path ) ) { return $ psr0Path ; } return $ psr4Path ; }
Get bundle directory .
235,482
public function getContainer ( ) { if ( property_exists ( __CLASS__ , 'container' ) ) { return $ this -> container ; } else { return parent :: getContainer ( ) ; } throw new RuntimeException ( sprintf ( 'The service container must be accessible from class %s to use this trait' , __CLASS__ ) ) ; }
Get the Service Container .
235,483
public function setAgent ( AgentContract $ agent = null ) { if ( ! $ agent ) { $ agent = new Agents \ SystemAgent ( ) ; } $ this -> agent = $ agent ; return $ this ; }
set agent .
235,484
public function create ( $ parameters ) { return $ this -> update ( $ this -> repository -> newEntity ( ) , $ parameters , Tokens :: PERMISSION_CREATE ) ; }
Create a new EntityContract given parameters .
235,485
public function update ( EntityContract $ entity , $ parameters , $ permission = Tokens :: PERMISSION_UPDATE ) { $ parameters = $ this -> castParameters ( $ parameters ) ; $ result = new Result ( ) ; try { DB :: beginTransaction ( ) ; $ result -> addErrors ( $ this -> getAuthorizer ( ) -> authorize ( $ permission , $ e...
Update a EntityContract given parameters .
235,486
public function fill ( EntityContract $ entity , $ parameters ) { $ result = new Result ( ) ; foreach ( $ this -> getAttributes ( ) as $ attribute ) { $ result -> addErrors ( $ attribute -> update ( $ entity , $ parameters ) ) ; } return $ result ; }
Fill entity .
235,487
public function save ( EntityContract $ entity ) { $ result = new Result ( ) ; $ saving = $ entity -> save ( ) ; foreach ( $ this -> getAttributes ( ) as $ attribute ) { $ result -> addErrors ( $ attribute -> save ( $ entity ) ) ; } return $ result ; }
Save the entity .
235,488
public function delete ( EntityContract $ entity ) { $ result = new Result ( ) ; $ result -> addErrors ( $ this -> authorizer -> authorize ( Tokens :: PERMISSION_REMOVE , $ entity , Bag :: factory ( [ ] ) ) ) ; if ( ! $ result -> ok ( ) ) { return $ result ; } try { DB :: beginTransaction ( ) ; $ entity -> delete ( ) ;...
Delete a EntityContract .
235,489
public function findOrCreate ( $ criteria , $ parameters = null ) { if ( $ criteria instanceof Bag ) { $ criteria = $ criteria -> toArray ( ) ; } if ( $ parameters === null ) { $ parameters = $ criteria ; } $ parameters = $ this -> castParameters ( $ parameters ) ; $ entity = $ this -> getRepository ( ) -> findOneBy ( ...
First or create .
235,490
public function updateOrCreate ( $ criteria , $ parameters = null ) { if ( $ criteria instanceof Bag ) { $ criteria = $ criteria -> toArray ( ) ; } if ( $ parameters === null ) { $ parameters = $ criteria ; } $ parameters = $ this -> castParameters ( $ parameters ) ; $ entity = $ this -> getRepository ( ) -> findOneBy ...
Update or create .
235,491
public function setLocale ( $ locale = null ) { $ this -> _locale = Zend_Locale :: findLocale ( $ locale ) ; $ locale = new Zend_Locale ( $ this -> _locale ) ; $ region = $ locale -> getRegion ( ) ; if ( empty ( $ region ) ) { throw new Zend_Validate_Exception ( "Unable to detect a region for the locale '$locale'" ) ; ...
Sets the locale to use
235,492
public function setFormat ( $ format ) { if ( empty ( $ format ) || ! is_string ( $ format ) ) { throw new Zend_Validate_Exception ( "A postcode-format string has to be given for validation" ) ; } if ( $ format [ 0 ] !== '/' ) { $ format = '/^' . $ format ; } if ( $ format [ strlen ( $ format ) - 1 ] !== '/' ) { $ form...
Sets a self defined postal format as regex
235,493
public function paginate ( Paginator $ paginator , $ params = [ ] ) { $ query = $ this -> paramsToQuery ( $ params ) ; $ countQuery = $ this -> getDB ( ) -> newSelect ( ) ; $ countQuery -> count ( [ '*' , 'count' ] ) ; $ countQuery -> from ( [ $ query , 'tbl' ] ) ; $ results = $ countQuery -> execute ( ) -> fetchResult...
Returns paginated results
235,494
public function findOne ( $ primary ) { $ item = $ this -> getRegistry ( ) -> get ( $ primary ) ; if ( ! $ item ) { $ all = $ this -> getRegistry ( ) -> get ( "all" ) ; if ( $ all ) { $ item = $ all [ $ primary ] ; } if ( ! $ item ) { $ params [ 'where' ] [ ] = [ "`{$this->getTable()}`.`{$this->getPrimaryKey()}` = ?" ,...
Checks the registry before fetching from the database
235,495
public function findByPrimary ( $ pk_list = [ ] ) { $ pk = $ this -> getPrimaryKey ( ) ; $ return = $ this -> newCollection ( ) ; if ( $ pk_list ) { $ pk_list = array_unique ( $ pk_list ) ; foreach ( $ pk_list as $ key => $ value ) { $ item = $ this -> getRegistry ( ) -> get ( $ value ) ; if ( $ item ) { unset ( $ pk_l...
When searching by primary key look for items in current registry before fetching them from the database
235,496
public function findOneByParams ( array $ params = [ ] ) { $ params [ 'limit' ] = 1 ; $ records = $ this -> findByParams ( $ params ) ; if ( count ( $ records ) > 0 ) { return $ records -> rewind ( ) ; } return null ; }
Finds one Record using params array
235,497
public function findByParams ( $ params = [ ] ) { $ query = $ this -> paramsToQuery ( $ params ) ; return $ this -> findByQuery ( $ query , $ params ) ; }
Finds Records using params array
235,498
public function registerService ( $ object , $ name = NULL ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expecting an object, given %s' , gettype ( $ object ) ) ) ; } $ key = ( $ name === NULL ) ? get_class ( $ object ) : ( string ) $ name ; if ( isset ( $ this -> services [ $ ...
Register the given object instance under the given name defaults to the fully - qualified type name of the object instance when no name is given .
235,499
public function genereteShortLink ( $ longLink ) { $ this -> client -> setMethod ( 'POST' ) ; $ this -> client -> setUri ( 'https://www.googleapis.com/urlshortener/v1/url' ) ; $ data = array ( 'longUrl' => $ longLink ) ; $ this -> client -> setRawBody ( json_encode ( $ data ) ) ; $ contentJson = $ this -> client -> sen...
Generate a Short Link by Long link