idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
54,500
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 .
54,501
public function removeGroup ( GroupInterface $ group ) : void { if ( ! $ group instanceof Production ) { throw new Exception ( 'Group type not supported.' ) ; } $ this -> groups -> removeElement ( $ group ) ; }
Remove group .
54,502
public function addEvent ( Event $ event ) : self { $ event -> setSchedule ( $ this ) ; $ this -> events [ ] = $ event ; return $ this ; }
Add event .
54,503
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 .
54,504
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 .
54,505
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 .
54,506
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
54,507
public function setApplication ( ApplicationInterface $ application ) { $ this -> setParam ( 'application' , $ application ) ; $ this -> application = $ application ; return $ this ; }
Set application instance
54,508
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
54,509
public static function create ( $ template = null , $ action = null , $ method = 'POST' , $ encType = null ) { return new static ( $ template , $ action , $ method , $ encType ) ; }
Create instance allows chaining
54,510
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
54,511
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
54,512
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
54,513
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
54,514
public function setAttributes ( array $ attrs ) { foreach ( $ attrs as $ k => $ v ) { $ this -> setAttribute ( $ k , $ v ) ; } return $ this ; }
sets sevaral form attributes stored in associative array
54,515
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
54,516
public function render ( ) { if ( $ this -> loadTemplate ( ) ) { $ this -> primeTemplate ( ) -> insertFormFields ( ) -> insertErrorMessages ( ) -> insertFormStart ( ) -> insertFormEnd ( ) -> cleanupHtml ( ) ; return $ this -> html ; } }
renders complete form markup
54,517
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
54,518
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
54,519
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
54,520
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
54,521
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
54,522
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
54,523
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
54,524
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
54,525
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
54,526
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
54,527
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
54,528
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
54,529
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
54,530
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 .
54,531
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 .
54,532
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 .
54,533
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
54,534
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 .
54,535
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 .
54,536
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 .
54,537
public function not ( Expr $ subexpression ) { $ not = new Condition \ Logical \ Not ; $ not -> add ( $ subexpression -> condition ) ; return $ this ; }
Add a NOT clause to the expression .
54,538
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 .
54,539
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
54,540
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
54,541
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
54,542
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 .
54,543
public function implode ( $ glue = '' , callable $ callback = null ) { return implode ( $ glue , $ callback ? array_map ( $ callback , $ this -> items ) : $ this -> items ) ; }
Implode the collection values .
54,544
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
54,545
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
54,546
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
54,547
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 .
54,548
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 .
54,549
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 .
54,550
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 .
54,551
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 .
54,552
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 .
54,553
public function setAgent ( AgentContract $ agent = null ) { if ( ! $ agent ) { $ agent = new Agents \ SystemAgent ( ) ; } $ this -> agent = $ agent ; return $ this ; }
set agent .
54,554
public function create ( $ parameters ) { return $ this -> update ( $ this -> repository -> newEntity ( ) , $ parameters , Tokens :: PERMISSION_CREATE ) ; }
Create a new EntityContract given parameters .
54,555
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 .
54,556
public function fill ( EntityContract $ entity , $ parameters ) { $ result = new Result ( ) ; foreach ( $ this -> getAttributes ( ) as $ attribute ) { $ result -> addErrors ( $ attribute -> update ( $ entity , $ parameters ) ) ; } return $ result ; }
Fill entity .
54,557
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 .
54,558
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 .
54,559
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 .
54,560
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 .
54,561
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
54,562
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
54,563
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
54,564
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
54,565
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
54,566
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
54,567
public function findByParams ( $ params = [ ] ) { $ query = $ this -> paramsToQuery ( $ params ) ; return $ this -> findByQuery ( $ query , $ params ) ; }
Finds Records using params array
54,568
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 .
54,569
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
54,570
public function getLongLinkbyShort ( $ shortLink ) { $ this -> client -> setMethod ( 'GET' ) ; $ this -> client -> setUri ( "https://www.googleapis.com/urlshortener/v1/url?shortUrl={$shortLink}" ) ; $ contentJson = $ this -> client -> send ( ) -> getContent ( ) ; $ responseArray = json_decode ( $ contentJson , true ) ;...
Return Long url bu Short url
54,571
public function start ( $ iMaxDuration , $ iHeartbeat ) { $ fNow = microtime ( true ) ; $ this -> aData = [ 'ts_limit' => $ fNow + $ iMaxDuration , 'lap_duration' => $ iHeartbeat , 'lap_start' => $ fNow , 'lap_end' => $ fNow + $ iHeartbeat , 'lap_nb_events' => 0 , 'total_nb_events' => 0 ] ; return $ this ; }
Init data structure .
54,572
public function doTic ( ) { $ aData = & $ this -> aData ; $ fNow = microtime ( true ) ; if ( $ fNow >= $ aData [ 'lap_end' ] || $ this -> isTimeLimitExceeded ( ) ) { $ iNbEventsPerSec = round ( $ aData [ 'lap_nb_events' ] / ( $ fNow - $ aData [ 'lap_start' ] ) ) ; $ sMsg = sprintf ( $ this -> sFormat , $ iNbEventsPerSe...
Display stats about number of processed events since last display .
54,573
protected function getCart ( ShopInterface $ shop , ClientInterface $ client = null , $ sessionId , $ currency ) { $ cart = $ this -> repository -> findCart ( $ client , $ sessionId , $ shop ) ; if ( null === $ cart ) { $ cart = $ this -> createCart ( $ shop , $ client ) ; } else { $ this -> updateCart ( $ cart , $ cli...
Returns an existent cart or creates a new one if needed
54,574
protected function createCart ( ShopInterface $ shop , ClientInterface $ client = null ) { $ cart = $ this -> initResource ( ) ; $ cart -> setShop ( $ shop ) ; $ cart -> setClient ( $ client ) ; $ this -> createResource ( $ cart ) ; return $ cart ; }
Creates cart using factory
54,575
protected function execute ( string $ username , ServerRequestInterface $ request ) : \ PDOStatement { $ stmt = $ this -> pdo -> prepare ( $ this -> getSql ( ) ) ; $ stmt -> execute ( [ $ username ] ) ; return $ stmt ; }
Queries the database table .
54,576
protected function fetchResult ( array $ results , string $ username ) : array { if ( count ( $ results ) > 1 ) { throw new \ Caridea \ Auth \ Exception \ UsernameAmbiguous ( $ username ) ; } elseif ( count ( $ results ) == 0 ) { throw new \ Caridea \ Auth \ Exception \ UsernameNotFound ( $ username ) ; } return curren...
Fetches a single result from the database resultset .
54,577
public function addEventFilter ( FilterCollectionEvent $ event ) : void { $ now = new \ DateTime ( ) ; $ qb = $ event -> getQueryBuilder ( ) ; $ query = $ qb -> query ( ) -> bool ( ) -> addMust ( $ qb -> query ( ) -> term ( [ '_index' => 'event' ] ) ) -> addMust ( $ qb -> query ( ) -> term ( [ 'active' => true ] ) ) ->...
Add the event filter to search .
54,578
public function addScheduleFilter ( FilterCollectionEvent $ event ) : void { $ now = new \ DateTime ( ) ; $ qb = $ event -> getQueryBuilder ( ) ; $ query = $ qb -> query ( ) -> bool ( ) -> addMust ( $ qb -> query ( ) -> term ( [ '_index' => 'schedule' ] ) ) -> addMust ( $ qb -> query ( ) -> term ( [ 'active' => true ] ...
Add the schedule filter to search .
54,579
public function fetchTree ( $ rootId = null , $ depth = null ) { $ wrappers = $ this -> fetchTreeAsArray ( $ rootId , $ depth ) ; return ( ! is_array ( $ wrappers ) || empty ( $ wrappers ) ) ? null : $ wrappers [ 0 ] ; }
Fetches the complete tree returning the root node of the tree
54,580
public function fetchTreeAsArray ( $ rootId = null , $ depth = null ) { $ config = $ this -> getConfiguration ( ) ; $ lftField = $ config -> getLeftFieldName ( ) ; $ rgtField = $ config -> getRightFieldName ( ) ; $ rootField = $ config -> getRootFieldName ( ) ; $ hasManyRoots = $ config -> hasManyRoots ( ) ; if ( $ roo...
Fetches the complete tree returning a flat array of node wrappers with parent children ancestors and descendants pre - populated .
54,581
public function fetchBranch ( $ pk , $ depth = null ) { $ wrappers = $ this -> fetchBranchAsArray ( $ pk , $ depth ) ; return ( ! is_array ( $ wrappers ) || empty ( $ wrappers ) ) ? null : $ wrappers [ 0 ] ; }
Fetches a branch of a tree returning the starting node of the branch . All children and descendants are pre - populated .
54,582
public function fetchBranchAsArray ( $ pk , $ depth = null ) { $ config = $ this -> getConfiguration ( ) ; $ lftField = $ config -> getLeftFieldName ( ) ; $ rgtField = $ config -> getRightFieldName ( ) ; $ rootField = $ config -> getRootFieldName ( ) ; $ hasManyRoots = $ config -> hasManyRoots ( ) ; if ( $ depth === 0 ...
Fetches a branch of a tree returning a flat array of node wrappers with parent children ancestors and descendants pre - populated .
54,583
public function createRoot ( Node $ node ) { if ( $ node instanceof NodeWrapper ) { throw new \ InvalidArgumentException ( 'Can\'t create a root node from a NodeWrapper node' ) ; } $ node -> setLeftValue ( 1 ) ; $ node -> setRightValue ( 2 ) ; if ( $ this -> getConfiguration ( ) -> hasManyRoots ( ) ) { $ rootValue = $ ...
Creates a new root node
54,584
public function wrapNode ( Node $ node ) { if ( $ node instanceof NodeWrapper ) { throw new \ InvalidArgumentException ( 'Can\'t wrap a NodeWrapper node' ) ; } $ oid = spl_object_hash ( $ node ) ; if ( ! isset ( $ this -> wrappers [ $ oid ] ) || $ this -> wrappers [ $ oid ] -> getNode ( ) !== $ node ) { $ this -> wrapp...
wraps the node using the NodeWrapper class
54,585
public function updateLeftValues ( $ first , $ last , $ delta , $ rootVal = null ) { $ hasManyRoots = $ this -> getConfiguration ( ) -> hasManyRoots ( ) ; foreach ( $ this -> wrappers as $ wrapper ) { if ( ! $ hasManyRoots || ( $ wrapper -> getRootValue ( ) == $ rootVal ) ) { if ( $ wrapper -> getLeftValue ( ) >= $ fir...
Internal Updates the left values of managed nodes
54,586
public function updateRightValues ( $ first , $ last , $ delta , $ rootVal = null ) { $ hasManyRoots = $ this -> getConfiguration ( ) -> hasManyRoots ( ) ; foreach ( $ this -> wrappers as $ wrapper ) { if ( ! $ hasManyRoots || ( $ wrapper -> getRootValue ( ) == $ rootVal ) ) { if ( $ wrapper -> getRightValue ( ) >= $ f...
Internal Updates the right values of managed nodes
54,587
public function updateValues ( $ first , $ last , $ delta , $ oldRoot = null , $ newRoot = null ) { if ( ! $ this -> wrappers ) { return ; } $ hasManyRoots = $ this -> getConfiguration ( ) -> hasManyRoots ( ) ; foreach ( $ this -> wrappers as $ wrapper ) { if ( ! $ hasManyRoots || ( $ wrapper -> getRootValue ( ) == $ o...
Internal Updates the left right and root values of managed nodes
54,588
public function removeNodes ( $ left , $ right , $ root = null ) { $ hasManyRoots = $ this -> getConfiguration ( ) -> hasManyRoots ( ) ; $ removed = array ( ) ; foreach ( $ this -> wrappers as $ oid => $ wrapper ) { if ( ! $ hasManyRoots || ( $ wrapper -> getRootValue ( ) == $ root ) ) { if ( $ wrapper -> getLeftValue ...
Internal Removes managed nodes
54,589
public function filterNodeDepth ( $ nodes , $ depth ) { if ( empty ( $ nodes ) || $ depth === 0 ) { return array ( ) ; } $ newNodes = array ( ) ; $ stack = array ( ) ; $ level = 0 ; foreach ( $ nodes as $ node ) { $ parent = end ( $ stack ) ; while ( $ parent && $ node -> getLeftValue ( ) > $ parent -> getRightValue ( ...
Internal Filters an array of nodes by depth
54,590
public function addHintToQuery ( \ Doctrine \ ORM \ Query $ query ) { return $ query -> setHint ( $ this -> getConfiguration ( ) -> GetQueryHintName ( ) , $ this -> getConfiguration ( ) -> GetQueryHintValue ( ) ) ; }
Adds a Query hint to a Query Object
54,591
protected function getMapsOptions ( ) { return [ 'dragndrop' => Translate :: t ( 'map.options.dragndrop' , [ ] , 'mapfield' ) , 'streetview' => Translate :: t ( 'map.options.streetview' , [ ] , 'mapfield' ) , 'zoomcontrol' => Translate :: t ( 'map.options.zoomcontrol' , [ ] , 'mapfield' ) , 'mapcontrol' => Translate ::...
Return all available maps options .
54,592
private function saveToCache ( $ rawCacheKey , $ value ) { $ cacheKey = $ rawCacheKey . self :: $ CACHE_SALT ; $ this -> cache -> save ( $ cacheKey , $ value ) ; if ( $ this -> debug ) $ this -> cache -> save ( '[C]' . $ cacheKey , time ( ) ) ; }
Saves a value to the cache .
54,593
private function isCacheFresh ( $ cacheKey , \ ReflectionClass $ class ) { if ( false === $ filename = $ class -> getFileName ( ) ) return true ; return $ this -> cache -> fetch ( '[C]' . $ cacheKey ) >= filemtime ( $ filename ) ; }
Checks if the cache is fresh .
54,594
public function findLoader ( \ SplFileInfo $ source ) { foreach ( $ this -> loaders as $ loader ) { if ( $ loader -> isSupported ( $ source ) ) { return $ loader ; } } throw new \ OutOfBoundsException ( sprintf ( 'No configuration loader found for "%s"' , $ source -> getPathname ( ) ) ) ; }
Picks a config loader for the given file and returns it .
54,595
public function validate ( $ value , Constraint $ constraint ) : void { $ item_values = [ ] ; foreach ( $ value as $ item ) { $ item_value = $ this -> property_accessor -> getValue ( $ item , $ constraint -> property ) ; if ( isset ( $ item_values [ $ item_value ] ) ) { $ this -> context -> buildViolation ( $ constrain...
Validate a constraint .
54,596
public function getPathInfo ( ) { if ( $ this -> pathInfo === null ) { $ end = strpos ( $ this -> uri , '?' ) ; if ( $ end === false ) { $ this -> pathInfo = $ this -> uri ; } else { $ this -> pathInfo = substr ( $ this -> uri , 0 , $ end ) ; } if ( empty ( $ this -> pathInfo ) ) { $ this -> pathInfo = '/' ; } } return...
Get the path info which is the uri without the query parameters
54,597
public function getMaxAllowedPacket ( ) { if ( $ this -> maxAllowedPacket === null ) { $ statement = $ this -> prepare ( 'SELECT @@global.max_allowed_packet' ) ; $ statement -> execute ( ) ; $ this -> maxAllowedPacket = ( int ) $ statement -> fetchColumn ( ) ; } return $ this -> maxAllowedPacket ; }
Gets the MySQL max allowed packet constant .
54,598
protected function Init ( ) { $ this -> layout = new Layout ( Request :: GetData ( 'layout' ) ) ; if ( ! $ this -> layout -> Exists ( ) ) { Response :: Redirect ( BackendRouter :: ModuleUrl ( new LayoutList ( ) ) ) ; return true ; } $ this -> listProvider = new AreaListProvider ( $ this -> layout ) ; $ this -> area = $...
Initializes the list
54,599
protected function CreateAfterUrl ( Area $ area ) { $ args = array ( 'layout' => $ this -> layout -> GetID ( ) ) ; $ args [ 'previous' ] = $ area -> GetID ( ) ; return BackendRouter :: ModuleUrl ( new AreaForm ( ) , $ args ) ; }
The create url for an area after another