idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
59,300
public static function instance ( $ name = null ) { $ fieldset = \ Fieldset :: instance ( $ name ) ; return $ fieldset === false ? false : $ fieldset -> form ( ) ; }
Returns the default instance of Form
59,301
public static function password ( $ field , $ value = null , array $ attributes = array ( ) ) { return static :: $ instance -> password ( $ field , $ value , $ attributes ) ; }
Create a password input field
59,302
public static function checkbox ( $ field , $ value = null , $ checked = null , array $ attributes = array ( ) ) { return static :: $ instance -> checkbox ( $ field , $ value , $ checked , $ attributes ) ; }
Create a checkbox
59,303
public function save ( Language $ model ) : void { if ( ! $ model -> save ( ) ) { throw new \ RuntimeException ( $ this -> i18n -> t ( 'setrun/sys' , 'Saving error' ) ) ; } }
Save a language item .
59,304
public function remove ( Language $ model ) : void { if ( ! $ model -> delete ( ) ) { throw new \ RuntimeException ( $ this -> i18n -> t ( 'setrun/sys' , 'Removing error' ) ) ; } }
Remove a language item .
59,305
public function getUser ( ) { if ( $ this -> _user !== NULL ) return $ this -> _user ; else $ this -> _user = Users :: model ( ) -> findByAttributes ( array ( 'email' => $ this -> username ) ) ; if ( $ this -> _user == NULL ) $ this -> errorCode = YII_DEBUG ? self :: ERROR_USERNAME_INVALID : self :: ERROR_UNKNOWN_IDENT...
Retrieves the user s model and presets an error code if one does not exists
59,306
private function setup ( $ force = false ) { $ this -> errorCode = NULL ; $ this -> force = $ force ; $ this -> getUser ( ) ; $ this -> _cost = Cii :: getBcryptCost ( ) ; $ this -> getPasswordAttempts ( ) ; return ; }
Handles setting up all the data necessary for the workflow
59,307
protected function getPasswordAttempts ( ) { if ( $ this -> _user == NULL ) return false ; $ this -> _attempts = UserMetadata :: model ( ) -> getPrototype ( 'UserMetadata' , array ( 'user_id' => $ this -> getUser ( ) -> id , 'key' => 'passwordAttempts' ) , array ( 'user_id' => $ this -> getUser ( ) -> id , 'key' => 'pa...
Retrieves the number of password login attempts so that we can automatically lock users out of they attempt a brute force attack
59,308
private function validateTwoFactorCode ( ) { $ otpSeed = $ this -> getUser ( ) -> getMetadataObject ( 'OTPSeed' , false ) -> value ; if ( $ otpSeed === false ) return false ; $ otplib = new TOTP ( Cii :: decrypt ( $ otpSeed ) ) ; return $ otplib -> validate ( $ this -> twoFactorCode ) ; }
Validates the users two factor authentication code
59,309
public function authenticate ( $ force = false ) { $ this -> setup ( $ force ) ; if ( $ this -> errorCode != NULL ) return ! $ this -> errorCode ; $ this -> validatePassword ( ) ; if ( $ this -> _attempts -> value >= 5 ) { if ( ( strtotime ( $ this -> _attempts -> updated ) + strtotime ( "+15 minutes" ) ) >= time ( ) )...
Authenticates the user into the system
59,310
public function validatePassword ( ) { if ( $ this -> _user -> status == Users :: BANNED || $ this -> _user -> status == Users :: INACTIVE || $ this -> _user -> status == Users :: PENDING_INVITATION ) $ this -> errorCode = self :: ERROR_UNKNOWN_IDENTITY ; else if ( ! $ this -> password_verify_with_rehash ( $ this -> pa...
Do some basic password validation
59,311
protected function setIdentity ( ) { $ this -> _id = $ this -> _user -> id ; $ this -> setState ( 'email' , $ this -> _user -> email ) ; $ this -> setState ( 'username' , $ this -> _user -> username ) ; $ this -> setState ( 'displayName' , $ this -> _user -> username ) ; $ this -> setState ( 'status' , $ this -> _user ...
Sets the identity attributes
59,312
protected function generateApiKey ( ) { $ factory = new CryptLib \ Random \ Factory ; $ meta = UserMetadata :: model ( ) -> getPrototype ( 'UserMetadata' , array ( 'user_id' => $ this -> getUser ( ) -> id , 'key' => 'api_key' . $ this -> app_name ) , array ( 'user_id' => $ this -> getUser ( ) -> id , 'key' => 'api_key'...
Generates a new API key for this application
59,313
public static function getInfo ( $ image ) { if ( is_string ( $ image ) && false !== ( $ info = getimagesizefromstring ( $ image ) ) && ! ! ( $ width = $ info [ 0 ] ) && ! ! ( $ height = $ info [ 1 ] ) ) { $ result = imagecreatefromstring ( $ image ) ; } else if ( is_resource ( $ image ) && ! ! ( $ width = imagesx ( $ ...
Returns an array holding width height and an image resource for the specified image . If these details cannot be obtained FALSE is returned .
59,314
public static function parse ( RouteInterface $ route ) { extract ( self :: transpilePattern ( $ route -> getPattern ( ) , false , $ route -> getConstraints ( ) , $ route -> getDefaults ( ) ) ) ; $ host = self :: parseHostVars ( $ route ) ; return new RouteContext ( $ staticPath , $ expression , $ tokens , $ host [ 'ex...
Parses a route object .
59,315
public static function transpilePattern ( $ pattern , $ host = false , array $ requirements = [ ] , array $ defaults = [ ] ) { $ tokens = self :: tokenizePattern ( $ pattern , $ host , $ requirements , $ defaults ) ; $ staticPath = ! $ tokens [ 0 ] instanceof Variable ? $ tokens [ 0 ] -> value : '/' ; $ regex = self ::...
Transpiles the the given pattern into a useful format .
59,316
public static function transpileMatchRegex ( array $ tokens ) { $ regex = [ ] ; foreach ( $ tokens as $ token ) { $ var = $ token instanceof Variable ? $ token : ( $ token instanceof Delimiter ? $ token -> next : null ) ; if ( null !== $ var && $ var instanceof Variable && null !== ( $ optgrp = self :: makeOptGrp ( $ v...
Transpiles tokens to a regex .
59,317
private static function makeOptGrp ( Variable $ var ) { if ( $ var -> required ) { return ; } list ( $ next , $ nextIsOpt ) = self :: findNextOpt ( $ var ) ; if ( ! $ nextIsOpt ) { return ; } $ optgrp = null !== $ next ? self :: makeOptGrp ( $ next ) : '' ; $ p = $ var -> prev instanceof Delimiter ? $ var -> prev : '' ...
Recursively iterates over tailing optional variables .
59,318
private static function findNextOpt ( Variable $ var ) { $ nextIsOpt = true ; $ next = null ; $ n = $ var -> next ; while ( null !== $ n ) { if ( ! $ n instanceof Variable ) { $ n = $ n -> next ; $ nextIsOpt = true ; continue ; } if ( ! $ n -> required ) { $ nextIsOpt = true ; $ next = $ n ; break ; } $ nextIsOpt = fal...
Finds next optional valiable token
59,319
public function handle ( RequestInterface $ request ) { $ response = $ request -> send ( ) ; $ headers = $ response -> getHeaders ( ) -> getAll ( ) ; $ body = $ response -> getBody ( true ) ; $ statusCode = $ response -> getStatusCode ( ) ; $ symfonyHeaders = array ( ) ; foreach ( $ headers as $ keys ) { if ( $ keys ->...
This method wrapper Guzzle response in symfony response
59,320
public function sendRequest ( $ method = 'GET' , $ uri = null , $ headers = null , $ body = null ) { $ request = $ this -> createRequest ( $ method , $ uri , $ headers , $ body ) ; return $ this -> handle ( $ request ) ; }
Send a request from client for the api
59,321
public function create_record ( array $ data ) { if ( is_array ( $ data ) && count ( $ data ) ) { $ params = array ( ) ; $ sqlFields = "" ; $ sqlValues = "" ; foreach ( $ data as $ field => $ value ) { $ sqlFields = ToolBox :: create_list ( $ sqlFields , $ field , ", " ) ; $ sqlValues = ToolBox :: create_list ( $ sqlVa...
Insert a new record into the table .
59,322
public function get_records ( array $ filter = null , $ orderBy = null , $ limit = null , $ offset = null ) { $ data = null ; $ limitOffsetStr = '' ; if ( is_numeric ( $ limit ) && $ limit > 0 ) { $ limitOffsetStr = ' LIMIT ' . $ limit ; if ( is_numeric ( $ offset ) && $ offset > 0 ) { $ limitOffsetStr .= ' OFFSET ' . ...
Retrieves a number of records based on arguments .
59,323
public function update_record ( $ recId , array $ updates ) { if ( ( ( is_numeric ( $ recId ) && $ recId >= 0 ) OR ( is_array ( $ recId ) && count ( $ recId ) ) ) && is_array ( $ updates ) && count ( $ updates ) > 0 ) { $ updateString = "" ; $ params = array ( ) ; foreach ( $ updates as $ f => $ v ) { $ updateString = ...
Update a single record with the given changes .
59,324
public function execute ( array $ variables = null ) { if ( null === $ variables ) { $ variables = $ _SERVER ; } $ arguments = $ this -> arguments ( $ variables ) ; if ( count ( $ arguments ) < 1 ) { throw new RuntimeException ( 'No arguments provided.' ) ; } switch ( $ arguments [ 0 ] ) { case '-h' : case '--help' : $...
Runs the Liftoff command line application .
59,325
protected function arguments ( array $ variables ) { if ( ! array_key_exists ( 'argv' , $ variables ) || ! is_array ( $ variables [ 'argv' ] ) ) { throw new RuntimeException ( 'Unable to determine arguments.' ) ; } $ arguments = $ variables [ 'argv' ] ; array_shift ( $ arguments ) ; return $ arguments ; }
Parse the command line arguments from the supplied environment variables .
59,326
public function prepareForm ( ModelInterface $ model = null , array $ data = null , $ useInputFilter = false , $ useHydrator = false ) { $ argv = compact ( 'model' , 'data' ) ; $ argv = $ this -> prepareEventArguments ( $ argv ) ; $ this -> getEventManager ( ) -> trigger ( self :: EVENT_PRE_PREPARE_FORM , $ this , $ ar...
Prepares form for the service .
59,327
public function getForm ( string $ name = null , array $ options = [ ] ) : Form { $ name = $ name ?? $ this -> form ?? $ this -> serviceAlias ; $ sl = $ this -> getServiceLocator ( ) ; $ formElementManager = $ sl -> get ( 'FormElementManager' ) ; $ argv = compact ( 'options' ) ; $ argv = $ this -> prepareEventArguments...
Gets the default form or on specified for the service .
59,328
public function getModel ( $ model = null ) { $ model = $ model ?? $ this -> model ?? $ this -> serviceAlias ; $ sl = $ this -> getServiceLocator ( ) ; $ modelManager = $ sl -> get ( ModelManager :: class ) ; $ model = $ modelManager -> get ( $ model ) ; return $ model ; }
Gets model from ModelManager
59,329
public function getInputFilter ( $ inputFilter = null ) { $ inputFilter = $ inputFilter ?? $ this -> inputFilter ?? $ this -> serviceAlias ; $ sl = $ this -> getServiceLocator ( ) ; $ inputFilterManager = $ sl -> get ( 'InputFilterManager' ) ; $ inputFilter = $ inputFilterManager -> get ( $ inputFilter ) ; return $ inp...
Gets input filter from InputFilterManager
59,330
public function getHydrator ( $ hydrator = null ) { $ hydrator = $ hydrator ?? $ this -> hydrator ?? $ this -> serviceAlias ; $ sl = $ this -> getServiceLocator ( ) ; $ hydratorManager = $ sl -> get ( 'HydratorManager' ) ; $ hydrator = $ hydratorManager -> get ( $ hydrator ) ; return $ hydrator ; }
Gets hydrator from HydratorManager
59,331
public function getAction ( Request $ request , $ name ) { $ value = $ this -> getDynamicVariableManager ( ) -> getVariableValueByName ( $ name ) ; $ view = $ this -> view ( $ value ) ; return $ this -> handleView ( $ view ) ; }
Get value by code from variables vars
59,332
protected function createFile ( $ filePath , $ contents ) { $ this -> createDirectory ( dirname ( $ filePath ) ) ; if ( is_file ( $ filePath ) ) { $ this -> output -> setDecorated ( true ) ; $ this -> output -> writeln ( sprintf ( "<comment>file exists <cyan>%s</cyan></comment>" , $ this -> prettyPath ( $ filePath ) )...
Creates a file with console otput .
59,333
protected function createDirectory ( $ dirPath ) { if ( ! is_dir ( $ dirPath ) ) { $ this -> output -> writeln ( sprintf ( "<info>create <cyan>%s</cyan></info>" , $ this -> prettyPath ( $ dirPath ) ) ) ; mkdir ( $ dirPath , 0775 , true ) ; } }
Creates a directory with console otput .
59,334
public function clear ( ) { $ this -> setCookies ( array ( ) ) ; $ this -> setStatusCode ( 200 ) ; $ this -> setHeaders ( array ( ) ) ; $ this -> setHeader ( 'Content-Type' , 'application/json; charset=utf8' ) ; $ this -> setCacheControl ( 'no-cache' ) ; $ this -> setCharSet ( 'utf8' ) ; $ this -> setBody ( '' ) ; $ th...
clear - Clear all properties
59,335
public function setCompression ( bool $ active = true , int $ level = - 1 ) { if ( $ active ) { $ acceptEncoding = getAllheaders ( ) [ 'Accept-Encoding' ] ?? '' ; if ( strpos ( $ acceptEncoding , 'gzip' ) !== FALSE ) { ini_set ( "zlib.output_compression" , 2048 ) ; ini_set ( "zlib.output_compression_level" , - 1 ) ; } ...
Sets Output Compression On or OFf
59,336
public function send ( ) { http_response_code ( $ this -> statusCode ) ; if ( empty ( $ this -> getHeader ( 'Cache-Control' ) ) ) { $ this -> setHeader ( 'Cache-Control' , $ this -> cacheControl ) ; } foreach ( $ this -> headers as $ header => $ value ) { header ( $ header . ': ' . $ value ) ; } foreach ( $ this -> coo...
Send response to client
59,337
public function getHeader ( string $ header , string $ default = '' ) : string { return array_change_key_case ( $ this -> headers , CASE_LOWER ) [ strtolower ( $ header ) ] ?? $ default ; }
Gets the value of a header
59,338
public function setJsonBody ( array $ data , int $ options = JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK ) { $ this -> setContentType ( 'application/json' ) -> setBody ( json_encode ( $ data , $ options ) ) ; return $ this ; }
setJsonBody - Encodes array as JSON response
59,339
public function setFileBody ( string $ fileBody , string $ contentType = '' ) { $ this -> setBody ( '' ) ; if ( ! empty ( $ contentType ) ) { $ this -> setContentType ( $ contentType ) ; } $ this -> fileBody = $ fileBody ; return $ this ; }
Set a file as the response with optional content - type
59,340
public function setCookie ( string $ name , string $ value = '' , int $ expire = 0 , string $ path = '' , string $ domain = '' , bool $ secure = false , bool $ httponly = false ) { $ cookie = array ( ) ; $ cookie [ 'name' ] = $ name ; $ cookie [ 'value' ] = $ value ; $ cookie [ 'expire' ] = $ expire ; $ cookie [ 'path'...
Sets a Cookie in the Response
59,341
protected function getPageUrls ( $ SHDObject ) { $ urls = array ( ) ; foreach ( $ SHDObject -> find ( '.txt_lg' ) as $ object ) { $ href = $ object -> href ; $ urls [ ] = $ this -> cleanUrl ( $ href , array ( '/^\/url\?q=/' , '/\/&amp;sa=.*/' , '/&amp;sa.*/' ) ) ; } return $ this -> normalizeResult ( $ urls ) ; }
Get all urls for a given Ask SERP page .
59,342
protected function initDirection ( string $ direction ) { $ direction = \ strtoupper ( \ trim ( $ direction ) ) ; if ( \ strlen ( $ direction ) != 1 ) { throw new GISError ( GISError :: ERROR_TYPE_DIRECTION , \ sprintf ( "'%s' is not allowed." , $ direction ) ) ; } if ( 'O' == $ direction ) { $ direction = 'E' ; } $ al...
Changes the current direction value .
59,343
protected function initMinutes ( $ minutes , $ seconds ) { if ( ! TypeTool :: IsDecimal ( $ minutes ) ) { throw new GISError ( GISError :: ERROR_TYPE_MINUTES , \ sprintf ( "'%s' is not of required decimal number format." , $ minutes ) ) ; } $ this -> extractTime ( $ minutes , $ seconds ) ; }
Changes the current minutes value .
59,344
public function copyWithFile ( $ object , $ file ) { if ( $ object instanceof \ Puzzlout \ Framework \ Interfaces \ IDocument ) { $ object -> setFilename ( $ this -> GetFileNameToSaveInDatabase ( $ file ) ) ; $ fileExists = \ Puzzlout \ Framework \ Core \ DirectoryManager :: FileExists ( $ this -> GetUploadDirectory ( ...
Location specific PDF document requirement Copies the file which is passed to it with the generated name
59,345
private function getResolvableValue ( \ Twig_Node_Expression $ node ) { if ( $ node instanceof \ Twig_Node_Expression_Constant && 'not_used' !== $ node -> getAttribute ( 'value' ) ) { return $ node -> getAttribute ( 'value' ) ; } return false ; }
Check an expression node to be sure it is a constant value we can resolve at compile time .
59,346
protected function getQuery ( $ table = null ) { $ qSchema = $ this -> adapter -> quoteValue ( $ this -> schema ) ; if ( $ table !== null ) { $ qTable = $ this -> adapter -> quoteValue ( $ table ) ; $ table_clause = "and (t.TABLE_NAME = $qTable or (kcu.referenced_table_name = $qTable and kcu.constraint_name = 'FOREIGN ...
Return information schema query .
59,347
protected function executeQuery ( $ table = null ) { $ query = $ this -> getQuery ( $ table ) ; $ this -> disableInnoDbStats ( ) ; try { $ results = $ this -> adapter -> query ( $ query ) -> getArrayObject ( ) ; } catch ( \ Exception $ e ) { $ this -> restoreInnoDbStats ( ) ; throw new Exception \ ErrorException ( __ME...
Execute information schema query .
59,348
public static function createContactsFromObjects ( array $ objects = null ) { if ( $ objects === null ) { return null ; } $ contacts = [ ] ; foreach ( $ objects as $ object ) { $ contact = new static ( ) ; $ contact -> updateFromObject ( $ object ) ; $ contacts [ ] = $ contact ; } return $ contacts ; }
Create an array of contacts from an array of stdClass objects .
59,349
private function getCustomerBalanceBase ( \ Magento \ Quote \ Model \ Quote $ quote ) { $ result = 0 ; $ customerId = $ quote -> getCustomerId ( ) ; $ storeId = $ quote -> getStoreId ( ) ; if ( $ customerId ) { $ account = $ this -> daoAccount -> getCustomerAccByAssetCode ( $ customerId , Cfg :: CODE_TYPE_ASSET_WALLET ...
Get customer balance nominated in base currency .
59,350
private function validateBalance ( $ quote , $ balanceBase , $ partialBase , $ partial ) { if ( $ partialBase > $ balanceBase ) { if ( $ balanceBase > 0 ) { $ partialBase = $ balanceBase ; $ currTo = $ quote -> getQuoteCurrencyCode ( ) ; $ partial = $ this -> priceCurrency -> convertAndRound ( $ partialBase , null , $ ...
Partial amounts should not be greater then customer balance .
59,351
public function beforeValidate ( $ event ) { $ formName = $ event -> sender -> formName ( ) ; $ primaryKey = $ event -> sender -> primaryKey ; $ sender = $ event -> sender ; $ metaTags = $ sender -> { $ this -> relationName } ; if ( ! $ metaTags ) { $ metaTags = Yii :: createObject ( MetaTags :: class ) ; $ metaTags ->...
before validate event function - populate relation
59,352
public function delete ( $ event ) { $ formName = $ event -> sender -> formName ( ) ; $ primaryKey = $ event -> sender -> primaryKey ; $ this -> model :: deleteAll ( [ 'model' => $ formName , 'model_id' => $ primaryKey , ] ) ; }
Delete event function
59,353
public function handleCommand ( Event $ event , Queue $ queue ) { $ queue -> ircPrivmsg ( $ event -> getSource ( ) , $ this -> getResponse ( $ event ) ) ; }
Handle the main pong command
59,354
public function handleCommandHelp ( Event $ event , Queue $ queue ) { foreach ( $ this -> getHelpLines ( ) as $ helpLine ) { $ queue -> ircPrivmsg ( $ event -> getSource ( ) , $ helpLine ) ; } }
Handle the help command
59,355
final public function setDomain ( $ dir , $ domain , $ codeset = 'UTF-8' ) { bindtextdomain ( $ domain , $ dir ) ; bind_textdomain_codeset ( $ domain , $ codeset ) ; $ this -> domains [ ] = $ domain ; return $ this ; }
Set domain name .
59,356
public function setDomainWithAlias ( $ alias , $ dir , $ domain , $ codeset = 'UTF-8' ) { $ this -> setDomain ( $ dir , $ domain , $ codeset ) ; $ this -> aliases [ $ alias ] = $ domain ; return $ this ; }
Set domain name with it s alias .
59,357
public function getDomain ( $ alias ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { return $ this -> aliases [ $ alias ] ; } return $ alias ; }
Provide domain name by it s alias .
59,358
public function withExpression ( string $ expression ) : self { if ( ! ( new \ ReflectionClass ( $ expression ) ) -> implementsInterface ( Expression :: class ) ) { throw new DomainException ( $ expression ) ; } $ self = clone $ this ; $ self -> expression = new $ expression ( $ self -> name ) ; return $ self ; }
Not ideal technic but didn t find a better to reduce duplicated code
59,359
protected function _prefixField ( $ pField , $ pDbContainer = NULL ) { if ( $ pDbContainer === NULL ) { $ dbContainer = $ this -> _dbContainer ; } else { $ dbContainer = $ pDbContainer ; } return $ dbContainer . static :: PREFIX_SEPARATOR . $ pField ; }
Prefix field according to DB container .
59,360
protected function _loadByAttribute ( $ pAttribute , $ pValue , array $ pArgs = array ( ) ) { $ args = $ pArgs ; if ( ! isset ( $ args [ DbInterface :: FILTER_CONDITIONS ] ) or ! $ args [ DbInterface :: FILTER_CONDITIONS ] instanceof Conditions ) { $ args [ DbInterface :: FILTER_CONDITIONS ] = new Conditions ( ) ; } $ ...
Load item by attribute code and value .
59,361
public function loadById ( $ pId ) { if ( ! $ pId instanceof Id ) { $ id = new Id ( $ pId ) ; } else { $ id = $ pId ; } return $ this -> _loadByAttribute ( static :: IDFIELD , $ id -> getOrig ( ) ) ; }
Load item by ID .
59,362
public function load ( $ pArgs = array ( ) ) { if ( ! is_array ( $ pArgs ) ) { return $ this -> loadById ( $ pArgs ) ; } $ select = new Select ( $ this -> _dbContainer ) ; if ( isset ( $ pArgs [ DbInterface :: FILTER_ORDER ] ) ) { $ select -> addOrder ( $ pArgs [ DbInterface :: FILTER_ORDER ] ) ; } else { $ select -> a...
Load an item with conditions filtering .
59,363
public function setId ( $ pValue ) { $ idField = $ this -> _dbContainer . static :: PREFIX_SEPARATOR . static :: IDFIELD ; if ( ! $ pValue instanceof Id ) { $ id = new Id ( $ pValue ) ; } else { $ id = $ pValue ; } $ this -> _fields [ $ idField ] = $ id ; $ this -> _origFields [ $ idField ] = $ id ; return $ this ; }
Set the Item ID .
59,364
public function getIdField ( $ pDbContainer = NULL ) { if ( $ pDbContainer === NULL ) { $ pDbContainer = $ this -> _dbContainer ; } return $ pDbContainer . static :: PREFIX_SEPARATOR . static :: IDFIELD ; }
Return the prefixed ID field name .
59,365
public function getFieldValue ( $ pField , $ pRaw = false ) { if ( ! $ pRaw ) { $ field = $ this -> _dbContainer . static :: PREFIX_SEPARATOR . $ pField ; } else { $ field = $ pField ; } if ( isset ( $ this -> _fields [ $ field ] ) ) { return $ this -> _fields [ $ field ] ; } return NULL ; }
Return the value corresponding to and attribute code if exists .
59,366
public function getOrigFieldValue ( $ pField , $ pRaw = false ) { if ( ! $ pRaw ) { $ field = $ this -> _dbContainer . static :: PREFIX_SEPARATOR . $ pField ; } else { $ field = $ pField ; } if ( isset ( $ this -> _origFields [ $ field ] ) ) { return $ this -> _origFields [ $ field ] ; } return NULL ; }
Return the value corresponding to and attribute code if exists . Search in the origFields array .
59,367
public function save ( ) { if ( ! $ this -> getOrigFieldValue ( static :: IDFIELD ) ) { throw new Exception ( "Cannot save an item without ID" ) ; } Observer :: dispatch ( Observer :: EVENT_ITEM_SAVE_BEFORE , array ( 'item' => $ this ) ) ; $ this -> { static :: DATEUPDATEFIELD } = DateData :: now ( ) ; $ update = new U...
Save the item in the database . By default the update query is conditioned to the item s ID .
59,368
public function insert ( ) { Observer :: dispatch ( Observer :: EVENT_ITEM_INSERT_BEFORE , array ( 'item' => $ this ) ) ; $ this -> { static :: DATEADDFIELD } = DateData :: now ( ) ; $ insert = new Insert ( $ this -> _dbContainer ) ; $ insert -> addFields ( $ this -> _fields ) ; $ insert -> commit ( ) ; $ this -> setId...
Insert a new item in the database .
59,369
public function delete ( $ pWithChilds = false ) { Observer :: dispatch ( Observer :: EVENT_ITEM_DELETE_BEFORE , array ( 'item' => $ this ) ) ; $ delete = new Delete ( $ this ) ; $ delete -> commit ( $ pWithChilds ) ; Observer :: dispatch ( Observer :: EVENT_ITEM_DELETE_AFTER , array ( 'item' => $ this ) ) ; return $ t...
Delete the item from the database .
59,370
public function getParents ( $ pDbContainer , array $ pArgs = array ( ) , $ pFirst = false ) { Agl :: validateParams ( array ( 'RewritedString' => $ pDbContainer ) ) ; if ( ! $ this -> getId ( ) ) { throw new Exception ( "getParents: Item must exist in database" ) ; } $ args = $ pArgs ; if ( isset ( $ args [ DbInterfac...
Return a collection of parents or a single parent in the required collection .
59,371
public function getChilds ( $ pDbContainer , array $ pArgs = array ( ) , $ pFirst = false ) { Agl :: validateParams ( array ( 'RewritedString' => $ pDbContainer ) ) ; if ( ! $ this -> getId ( ) ) { throw new Exception ( "getChilds: Item must exist in database" ) ; } $ args = $ pArgs ; if ( isset ( $ args [ DbInterface ...
Return a collection of childs or a single child in the required collection .
59,372
public function addParent ( ItemAbstract $ pItem ) { if ( ! $ pItem -> getId ( ) ) { throw new Exception ( "addParent: Parent must exist in database" ) ; } $ parentsValue = $ this -> getFieldValue ( $ pItem -> getIdField ( ) , true ) ; if ( ! $ parentsValue ) { $ parents = array ( ) ; } else { $ parents = explode ( ','...
Add a parent relation to the current Item .
59,373
public function removeParent ( ItemAbstract $ pItem ) { if ( ! $ pItem -> getId ( ) ) { throw new Exception ( "addParent: Parent must exist in database" ) ; } $ parentsValue = $ this -> getFieldValue ( $ pItem -> getIdField ( ) , true ) ; if ( ! $ parentsValue ) { $ parents = array ( ) ; } else { $ parents = explode ( ...
Remove a parent relation to the current Item .
59,374
public function removeChilds ( $ pDbContainer = NULL ) { if ( $ pDbContainer === NULL ) { $ containers = Agl :: app ( ) -> getDb ( ) -> listCollections ( array ( $ this -> getIdField ( ) ) ) ; } else { $ containers = array ( $ pDbContainer ) ; } foreach ( $ containers as $ container ) { if ( $ container === $ this -> g...
Remove Item s childs in the given DB container or in all containers .
59,375
public function build ( ) { if ( isset ( $ this -> attribute [ 'href' ] ) && ( ! isset ( $ this -> attribute [ 'alt' ] ) ) ) { $ this -> attribute [ 'alt' ] = $ this -> attribute [ 'href' ] ; } return parent :: build ( ) ; }
Build method with href and set alt check
59,376
public function add ( $ error , $ key = NULL ) { if ( $ key ) { $ errorContainer = $ this -> get ( $ key , new static ( ) ) ; $ errorContainer -> push ( $ error ) ; $ this [ $ key ] = $ errorContainer ; } else { $ this -> push ( $ error ) ; } }
Add an error to the collection
59,377
public function parse ( \ Request $ request ) { $ uri = $ request -> uri -> get ( ) ; $ method = $ request -> get_method ( ) ; if ( $ uri === '' and $ this -> path === '_root_' ) { return $ this -> matched ( ) ; } $ result = $ this -> _parse_search ( $ uri , null , $ method ) ; if ( $ result ) { return $ result ; } ret...
Attempts to find the correct route for the given URI
59,378
public function matched ( $ uri = '' , $ named_params = array ( ) ) { foreach ( $ named_params as $ key => $ val ) { if ( is_numeric ( $ key ) ) { unset ( $ named_params [ $ key ] ) ; } } $ this -> named_params = $ named_params ; if ( $ this -> translation instanceof \ Closure ) { $ this -> callable = $ this -> transla...
Parses a route match and returns the controller action and params .
59,379
public static function homePage ( ) { if ( ! class_exists ( 'SiteTree' ) || self :: $ site_home ) { return self :: $ site_home ; } $ home = null ; if ( class_exists ( 'HomePage' ) ) { $ home = DataList :: create ( 'HomePage' ) -> first ( ) ; } if ( ! $ home ) { $ home = \ SiteTree :: get_by_link ( \ RootUrlController :...
Get home page
59,380
public static function query_string ( $ request = null ) { if ( ! $ request ) { $ request = Controller :: curr ( ) -> Request ; } if ( ! $ request ) { return '' ; } $ vars = $ request -> getVars ( ) ; if ( isset ( $ vars [ 'url' ] ) ) { unset ( $ vars [ 'url' ] ) ; } return empty ( $ vars ) ? '' : '?' . http_build_quer...
Convert the get vars into a query string automatically eliminates the url get var
59,381
protected function setCast ( $ key , $ value ) { if ( is_null ( $ value ) ) { return $ value ; } $ type = $ this -> getCastType ( $ key ) ; $ method = 'setCast' . Str :: studly ( $ type ) . 'Type' ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( $ key , $ value ) ; } return $ value ; }
Set an attribute and cast value to a native PHP type .
59,382
protected function setCasStringType ( $ key , $ value ) { if ( ( $ key == '_id' ) && ( is_string ( $ value ) ) ) { return Builder :: convertKey ( $ value ) ; } return trim ( ( string ) $ value ) ; }
SET Type string and _id .
59,383
protected function setCastDatetimeType ( $ key , $ value ) { if ( $ value instanceof UTCDateTime ) { return $ value ; } $ value = $ this -> getCastDateTimeType ( $ key , $ value ) ; return new UTCDateTime ( $ value -> getTimestamp ( ) * 1000 ) ; }
SET Type datetime .
59,384
public function addArticleItem ( WxSendNewsMsgItem $ item ) { if ( sizeof ( $ this -> articles ) >= self :: MAX_ITEMS_COUNT ) { array_shift ( $ this -> articles ) ; } $ this -> articles [ ] = $ item ; }
add a article item
59,385
public function fire ( $ name , $ params = [ ] ) { if ( $ this -> prefixEventName === null ) { $ reflector = new \ ReflectionClass ( $ this ) ; $ this -> prefixEventName = 'e' . $ reflector -> getShortName ( ) ; } $ event = new Event ( $ params ) ; if ( method_exists ( $ this , $ this -> prefixEventHandler . $ name ) )...
Trigger global event
59,386
public function consumeReadBuffer ( int $ bytes ) : string { if ( $ this -> getBufferLength ( ) < $ bytes ) { throw new \ RuntimeException ( "BufferedSocket::getAndConsumeReadBuffer requested more bytes than are currently available. Requested=" . $ bytes . ", available=" . $ this -> getBufferLength ( ) . "." ) ; } $ da...
This is a convenience method for when you know the exact size of the message
59,387
protected function getListCommands ( ) { $ commands = $ this -> application -> all ( ) ; $ commandsArray = array ( ) ; foreach ( $ commands as $ command ) { $ commandsArray [ ] = array ( 'class' => get_class ( $ command ) , 'name' => $ command -> getName ( ) ) ; } return $ commandsArray ; }
Get list commands to array strings
59,388
protected function initSymfonyConsoleProvider ( ) { if ( ! $ this -> mvc -> hasCvpp ( 'symfony.console' ) ) { $ this -> mvc -> registerProvider ( new ConsoleSymfonyProvider ( array ( 'modules' => $ this -> mvc -> setModules ( ) , 'commands' => array ( new ListCommand ( ) ) ) ) ) ; } return $ this ; }
Init the Symfony Console Provider
59,389
public function clear ( ? string $ documentClass = null ) : void { if ( null === $ documentClass ) { $ this -> identityMap = $ this -> objects = $ this -> documentStates = $ this -> documentPersisters = $ this -> documentDeletions = $ this -> documentUpdates = $ this -> documentChangeSets = $ this -> readOnlyObjects = ...
Clears the unit of work . If document class is given only documents of that class will be detached .
59,390
public function getDocumentPersister ( string $ documentClass ) : DocumentPersister { if ( isset ( $ this -> documentPersisters [ $ documentClass ] ) ) { return $ this -> documentPersisters [ $ documentClass ] ; } return $ this -> documentPersisters [ $ documentClass ] = new DocumentPersister ( $ this -> manager , $ th...
Gets the document persister for a given document class .
59,391
public function isInIdentityMap ( $ object ) : bool { $ oid = spl_object_hash ( $ object ) ; if ( ! isset ( $ this -> objects [ $ oid ] ) ) { return false ; } $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ id = $ class -> getSingleIdentifier ( $ object ) ; if ( empty ( $ id ) ) { return ...
Checks if a document is attached to this unit of work .
59,392
public function getDocumentState ( $ document , ? int $ assume = null ) { $ oid = spl_object_hash ( $ document ) ; if ( isset ( $ this -> documentStates [ $ oid ] ) ) { return $ this -> documentStates [ $ oid ] ; } if ( null !== $ assume ) { return $ assume ; } $ class = $ this -> manager -> getClassMetadata ( get_clas...
Gets the document state .
59,393
public function commit ( ) { if ( $ this -> evm -> hasListeners ( Events :: preFlush ) ) { $ this -> evm -> dispatchEvent ( Events :: preFlush , new PreFlushEventArgs ( $ this -> manager ) ) ; } $ this -> computeChangeSets ( ) ; if ( ! ( $ this -> documentInsertions || $ this -> documentDeletions || $ this -> documentU...
Commits all the operations pending in this unit of work .
59,394
private function addToIdentityMap ( $ object ) { $ oid = spl_object_hash ( $ object ) ; if ( isset ( $ this -> objects [ $ oid ] ) ) { return ; } $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ id = $ class -> getSingleIdentifier ( $ object ) ; if ( empty ( $ id ) ) { throw new InvalidIde...
Adds a document to the identity map . The identifier MUST be set before trying to add the document or this method will throw an InvalidIdentifierException .
59,395
private function removeFromIdentityMap ( $ object ) { $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ id = $ class -> getSingleIdentifier ( $ object ) ; if ( empty ( $ id ) ) { throw new InvalidIdentifierException ( 'Documents must have an identifier in order to be added to the identity m...
Removes an object from identity map .
59,396
private function doPersist ( $ object , array & $ visited ) : void { $ oid = spl_object_hash ( $ object ) ; if ( isset ( $ visited [ $ oid ] ) ) { return ; } $ visited [ $ oid ] = true ; $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ documentState = $ this -> getDocumentState ( $ object ...
Executes a persist operation .
59,397
private function doRemove ( $ object , array & $ visited ) : void { $ oid = spl_object_hash ( $ object ) ; if ( isset ( $ visited [ $ oid ] ) ) { return ; } $ visited [ $ oid ] = true ; $ this -> cascadeRemove ( $ object , $ visited ) ; $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ docu...
Executes a remove operation .
59,398
private function doDetach ( $ object , array & $ visited ) { $ oid = spl_object_hash ( $ object ) ; if ( isset ( $ visited [ $ oid ] ) ) { return ; } $ visited [ $ oid ] = true ; $ state = $ this -> getDocumentState ( $ object , self :: STATE_DETACHED ) ; if ( self :: STATE_MANAGED !== $ state ) { return ; } unset ( $ ...
Execute detach operation .
59,399
private function scheduleForInsert ( $ object ) { $ oid = spl_object_hash ( $ object ) ; $ class = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ this -> documentInsertions [ $ oid ] = $ object ; if ( null !== $ class -> getSingleIdentifier ( $ object ) ) { $ this -> addToIdentityMap ( $ object ) ...
Schedule a document for insertion . If the document already has an identifier it will be added to the identity map .