idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
54,200
final public function walk ( Callable $ callback , $ userdata = null ) { array_walk ( $ this -> { self :: MAGIC_PROPERTY } , $ callback ) ; return $ this ; }
Apply a user supplied function to every member of an array
54,201
final public function filter ( Callable $ callback , $ flags = 0 ) { $ arr = array_filter ( $ this -> { self :: MAGIC_PROPERTY } , $ callback ) ; return static :: createFromArray ( $ arr ) ; }
Filters elements of an array using a callback function
54,202
final public function reduce ( Callable $ callback , $ initial = null ) { $ result = array_reduce ( $ this -> { self :: MAGIC_PROPERTY } , $ callback , $ initial ) ; return static :: from ( $ result ) ; }
Iteratively reduce the array to a single value using a callback function
54,203
public function cmdGetPayment ( ) { $ result = $ this -> getListPayment ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePayment ( $ result ) ; $ this -> output ( ) ; }
Callback for payment - get command
54,204
protected function getErrorCode ( ) { $ content = $ this -> content ; return is_object ( $ content ) && property_exists ( $ content , 'code' ) ? ( integer ) $ content -> code : 0 ; }
returns the response error code
54,205
public function flush ( ) { if ( empty ( $ this -> memcache ) ) { return false ; } $ flushStatus = $ this -> memcache -> flush ( ) ; return $ flushStatus ; }
Flush the server
54,206
public static function createTemporary ( string $ data , string $ clientFileName = null ) : File { $ tempFilePath = tempnam ( sys_get_temp_dir ( ) , 'dms' ) ; file_put_contents ( $ tempFilePath , $ data ) ; return new self ( $ tempFilePath , $ clientFileName ) ; }
Create a temporary temporary file .
54,207
protected function readChunkHeader ( ) { static $ m = NULL ; if ( preg_match ( "'([a-fA-F0-9]+).*\r\n'" , $ this -> buffer , $ m ) ) { $ this -> remainder = hexdec ( $ m [ 1 ] ) ; $ this -> buffer = ( string ) substr ( $ this -> buffer , strlen ( $ m [ 0 ] ) ) ; } else { $ this -> remainder = 0 ; } }
Compute number of remaining bytes using chunk header
54,208
protected function BeforeDelete ( ) { foreach ( self :: $ deleteHooks as $ hook ) { $ hook -> BeforeDelete ( $ this -> item ) ; } $ logger = new Logger ( BackendModule :: Guard ( ) -> GetUser ( ) ) ; $ logger -> ReportAreaAction ( $ this -> item , Action :: Delete ( ) ) ; }
Execute delete hooks
54,209
public function normalizeData ( PathUserResponse $ response ) { $ return = $ response -> getResponse ( ) ; $ provider = $ response -> getResourceOwner ( ) -> getName ( ) ; $ token = $ response -> getAccessToken ( ) ; switch ( $ provider ) { case 'google' : $ data = $ this -> normalizeGoogle ( $ return ) ; break ; case ...
Get oAuth data and normalize it to same var names
54,210
public function normalizeGoogle ( $ return ) { $ genders = [ 'male' => 'M' , 'female' => 'F' ] ; $ data = [ 'id' => $ return [ 'id' ] , 'name' => $ this -> ensureUtf8 ( $ return [ 'name' ] ) , 'firstName' => $ this -> ensureUtf8 ( $ return [ 'given_name' ] ) , 'lastName' => $ this -> ensureUtf8 ( $ return [ 'family_nam...
Mapping data from Google
54,211
public function normalizeFacebook ( $ return ) { $ genders = [ 'male' => 'M' , 'female' => 'F' ] ; $ data = [ 'id' => $ return [ 'id' ] , 'name' => $ return [ 'name' ] , 'firstName' => $ return [ 'first_name' ] , 'lastName' => $ return [ 'last_name' ] , 'facebookProfileLink' => $ return [ 'link' ] , 'username' => $ ret...
Mapping data from facbook
54,212
public function normalizeGithub ( $ return , $ token ) { $ data = [ 'id' => $ return [ 'id' ] , 'username' => $ return [ 'login' ] , 'name' => $ return [ 'name' ] , 'email' => $ return [ 'email' ] , 'gravatar' => $ return [ 'gravatar_id' ] , 'avatar' => $ return [ 'avatar_url' ] , 'gitHubProfileLink' => $ return [ 'htm...
Mapping data from github
54,213
protected function httpRequest ( $ url , $ resource = '/' , $ content = null , $ headers = [ ] , $ method = 'GET' ) { $ request = new HttpRequest ( $ method , $ resource , $ url ) ; $ response = new HttpResponse ( ) ; $ headers = array_merge ( [ 'User-Agent: WobbleCodeUserBundle' ] , $ headers ) ; $ request -> setHeade...
Performs an HTTP request
54,214
public function GetReferencedContainer ( Content $ content ) { $ contentContainer = ContentContainer :: Schema ( ) -> ByContent ( $ content ) ; return $ contentContainer ? $ contentContainer -> GetContainer ( ) : null ; }
Gets a container referenced by a content
54,215
protected function activationComplete ( ) { try { $ activation = Activation :: create ( $ this -> model ) ; if ( ! Activation :: complete ( $ this -> model , $ activation -> code ) ) { throw new ActivateException ( $ this -> model -> id , $ activation -> code , 'fail' ) ; } if ( $ this -> callerActivationMethod ( debug...
set activation complete
54,216
protected function activateGroupAction ( $ class ) { $ users = $ class :: whereIn ( 'id' , $ this -> request -> id ) -> get ( ) ; foreach ( $ users as $ user ) { $ this -> setModel ( $ user ) ; $ this -> activationComplete ( ) ; } return true ; }
activate group action
54,217
protected function notActivateGroupAction ( $ class ) { $ users = $ class :: whereIn ( 'id' , $ this -> request -> id ) -> get ( ) ; foreach ( $ users as $ user ) { $ this -> setModel ( $ user ) ; $ this -> activationRemove ( ) ; } return true ; }
not activate group action
54,218
public static function addDirectory ( $ directory , $ extensionToFind = '.php' , $ bypassDirectories = '' ) { self :: register ( ) ; $ dir = new SplFileInfo ( $ directory ) ; if ( ! $ dir -> isDir ( ) ) { throw new ApplicationContextException ( 'Cannot add directory to ClassLoader, directory does not exist: ' . $ direc...
Scans a directory recursively for all files with a particular extension and will add any classes it finds with the full path .
54,219
public static function addFile ( $ filePath , $ extensionToFind = '.php' ) { if ( ! $ filePath instanceof SplFileInfo ) { $ filePath = new SplFileInfo ( $ filePath ) ; } $ firstChar = substr ( $ filePath -> getBasename ( ) , 0 , 1 ) ; $ extension = substr ( $ filePath -> getFilename ( ) , strlen ( $ extensionToFind ) *...
Evaluates a file and if it looks like a php class it will add it . This prevents odd php files that aren t classes from being auto loaded like bootstrap . php or autoload . php etc .
54,220
public static function addClass ( $ className , $ filePath ) { if ( self :: classExists ( $ className ) ) { throw new ApplicationContextException ( 'Cannot add class file [' . $ filePath . '], class with same name already defined by [' . self :: $ classNames [ $ className ] . ']' ) ; } self :: $ classNames [ $ classNam...
Adds a class name and file path .
54,221
public static function isVcsFile ( $ fileName ) { foreach ( self :: $ vcsPatterns as $ pattern ) { if ( strpos ( $ fileName , $ pattern ) !== false ) { return true ; } } return false ; }
Returns true if file path contains a vcs name .
54,222
public function apply ( $ value ) { return htmlspecialchars ( ( string ) $ value , $ this -> quoteStyle , $ this -> charset , $ this -> doubleEncode ) ; }
Converts special characters to HTML entities
54,223
private function __connect ( ) { if ( ! is_null ( $ db ) ) return true ; $ config = Config :: get ( 'db' ) ; if ( is_null ( $ config ) ) { throw new \ Lollipop \ Exception \ Configuration ( 'Lollipop is initialized with wrong database configuration' ) ; } $ host = isset ( $ config -> host ) ? $ config -> host : 'localh...
Connect to MySQL server
54,224
public function initialize ( $ csrf = false ) { $ this -> _tokenRequired = $ csrf ; if ( $ csrf ) { $ currentToken = App :: $ Session -> get ( '_csrf_token' , false ) ; $ newToken = Crypt :: randomString ( mt_rand ( 32 , 64 ) ) ; App :: $ Session -> set ( '_csrf_token' , $ newToken ) ; if ( $ this -> send ( ) ) { if ( ...
Initialize validator . Set csrf protection token from request data if available .
54,225
final public function send ( ) { if ( ! Str :: equalIgnoreCase ( $ this -> _sendMethod , App :: $ Request -> getMethod ( ) ) ) { return false ; } return $ this -> getRequest ( 'submit' , $ this -> _sendMethod ) !== null ; }
Check if model get POST - based request as submit of SEND data
54,226
public function getRequest ( $ param , $ method = null ) { if ( $ method === null ) { $ method = $ this -> _sendMethod ; } $ method = Str :: lowerCase ( $ method ) ; switch ( $ method ) { case 'get' : $ request = App :: $ Request -> query -> get ( $ this -> getFormName ( ) , null ) ; break ; case 'post' : $ request = A...
Get input value based on param path and request method
54,227
public static function fromRepository ( $ repository ) { $ message = sprintf ( 'Could not add invalid OptionRepository of type "%1$s" to AggregateOptionRepository.' , is_object ( $ repository ) ? get_class ( $ repository ) : gettype ( $ repository ) ) ; return new static ( $ message ) ; }
Get a new exception based on the type of an invalid repository .
54,228
public static function fromInstantiationException ( $ class , Exception $ exception ) { $ message = sprintf ( 'Could not instantiate OptionRepository of type "%1$s". Reason: %2$s' , is_object ( $ class ) ? get_class ( $ class ) : gettype ( $ class ) , $ exception -> getMessage ( ) ) ; return new static ( $ message , 0 ...
Get a new exception based on an exception that was thrown during instantiation of a class .
54,229
public static function fromConfig ( Config $ config ) { $ message = sprintf ( 'Could not instantiate OptionRepository from Config with starting key "%1$s".' , empty ( $ config -> getKeys ( ) ) ? '<none>' : $ config -> getKeys ( ) [ 0 ] ) ; return new static ( $ message ) ; }
Get a new exception based on a Config that did not produce a valid repository .
54,230
protected function setValue ( $ value ) { $ enumKey = array_search ( ( string ) $ value , static :: $ enumConstants [ get_class ( $ this ) ] ) ; if ( $ enumKey === false ) { throw new Exception \ InvalidEnumerationValueException ( sprintf ( 'Invalid value %s for %s' , $ value , __CLASS__ ) , 1381615295 ) ; } $ this -> ...
Set the Enumeration value to the associated enumeration value by a loose comparison . The value that is used as the enumeration value will be of the same type like defined in the enumeration
54,231
protected function isValid ( $ value ) { $ value = ( string ) $ value ; foreach ( static :: $ enumConstants [ get_class ( $ this ) ] as $ constantValue ) { if ( $ value === ( string ) $ constantValue ) { return true ; } } return false ; }
Check if the value on this enum is a valid value for the enum
54,232
public static function getConstants ( $ include_default = false ) { static :: loadValues ( ) ; $ enumConstants = static :: $ enumConstants [ get_called_class ( ) ] ; if ( ! $ include_default ) { unset ( $ enumConstants [ '__DEFAULT' ] ) ; } return $ enumConstants ; }
Get the valid values for this enum Defaults to constants you define in your subclass override to provide custom functionality
54,233
public static function cast ( $ value ) { $ currentClass = get_called_class ( ) ; if ( ! is_object ( $ value ) || get_class ( $ value ) !== $ currentClass ) { $ value = new $ currentClass ( $ value ) ; } return $ value ; }
Cast value to enumeration type
54,234
public function readConfig ( $ pipe ) { $ filename = $ this -> pipesDir . '/' . $ pipe ; if ( file_exists ( $ filename . '.yml' ) ) { return Yaml :: parse ( file_get_contents ( $ filename . '.yml' ) ) ; } elseif ( $ this -> allowPhp && file_exists ( $ filename . '.php' ) ) { return include ( $ filename . '.php' ) ; } e...
Reads pipe config from file .
54,235
public static function pregMatchArray ( $ patterns , $ subject ) { if ( ! is_array ( $ patterns ) ) { throw new \ Exception ( '$patterns is not an array' ) ; } if ( ! is_string ( $ subject ) ) { throw new \ Exception ( '$subject is not a string' ) ; } foreach ( $ patterns as $ pattern ) { if ( preg_match ( $ pattern , ...
Preg match array
54,236
final public function requireBasicLogin ( $ realm = 'Restricted' ) { if ( ! ( array_key_exists ( 'PHP_AUTH_USER' , $ _SERVER ) and array_key_exists ( 'PHP_AUTH_PW' , $ _SERVER ) ) ) { $ this -> _basicAuthFailed ( $ realm ) ; } else { $ this -> loginWith ( [ 'user' => $ _SERVER [ 'PHP_AUTH_USER' ] , 'password' => $ _SER...
Check for Basic Auth credentials and attempt to login if present
54,237
protected function loadEntity ( ) { $ params = array_merge ( $ this -> params ( ) -> fromPost ( ) , $ this -> params ( ) -> fromRoute ( ) ) ; if ( empty ( $ params [ 'id' ] ) ) { throw new EntityNotFoundException ( 'Bad Request' ) ; } $ objectManager = $ this -> getServiceLocator ( ) -> get ( 'Doctrine\ORM\EntityManage...
Find entity by id
54,238
public function getTranslation ( $ identifier , $ defaultTranslation = null ) : string { if ( $ this -> _useNumericId ) { if ( ! \ is_int ( $ identifier ) ) { throw new \ InvalidArgumentException ( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' ) ; } if ( ! isset ( $ this -> _translations [ $ identif...
Gets the translation with the defined identifier
54,239
public function getTranslations ( $ category = null ) : array { $ translations = [ ] ; if ( \ is_null ( $ category ) ) { foreach ( $ this -> _translations as $ identifier => $ transData ) { if ( is_string ( $ transData ) ) { $ translations [ $ identifier ] = $ transData ; continue ; } if ( ! \ is_array ( $ transData ) ...
Gets all translations of an specific category . If not category is defined all translations of all categories are returned .
54,240
public static function LoadFromFolder ( string $ folder , Locale $ locale , bool $ useNumericId = false ) { $ languageFolderBase = rtrim ( $ folder , '\\/' ) ; if ( ! empty ( $ languageFolderBase ) ) { $ languageFolderBase .= '/' ; } $ languageFile = $ languageFolderBase . $ locale -> getLID ( ) . '_' . $ locale -> get...
Loads a translation array source from a specific folder that contains one or more locale depending PHP files .
54,241
public function add ( $ productId , $ count , $ attributesAndValues = null , $ additionalProducts = [ ] , $ combinationId = null ) { if ( ! empty ( $ attributesAndValues ) ) { $ attributesAndValues = Json :: decode ( $ attributesAndValues ) ; } if ( $ this -> saveSelectedCombination ) { $ combination = Combination :: f...
Adds product to cart .
54,242
private function saveProductToDataBase ( $ productId , $ count , $ attributesAndValues = null , $ additionalProducts = null , $ combinationId = null ) { $ order = $ this -> getIncompleteOrderFromDB ( ) ; if ( \ Yii :: $ app -> getModule ( 'shop' ) -> enableCombinations ) { if ( ! empty ( $ attributesAndValues ) ) { $ c...
Saves product to database if the corresponding property is true .
54,243
private function getIncompleteOrderFromDB ( ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( empty ( $ order ) ) { $ order = new Order ( ) ; $ order -> uid = $ this -> generateUniqueId ( $ this -> uidPrefix , $ th...
Gets or creates incomplete order record from database .
54,244
public function saveSelectedCombinationToSession ( $ combination ) { if ( ! empty ( $ combination ) ) { $ items = Yii :: $ app -> session [ self :: SESSION_KEY_SELECTED_COMBINATIONS ] ; $ itemIsExist = false ; if ( ! empty ( $ items ) ) { foreach ( $ items as $ key => $ item ) { if ( $ item [ 'productId' ] == $ combina...
Saves last selected product combinations to session .
54,245
public function getSelectedCombinationFromSession ( $ productId ) { $ combination = null ; if ( ! empty ( $ productId ) ) { $ items = Yii :: $ app -> session [ self :: SESSION_KEY_SELECTED_COMBINATIONS ] ; if ( ! empty ( $ items ) ) { $ combinationId = null ; foreach ( $ items as $ item ) { if ( $ item [ 'productId' ] ...
Gets last selected product combinations from session .
54,246
public function getOrderItems ( ) { if ( \ Yii :: $ app -> user -> isGuest ) { $ session = \ Yii :: $ app -> session ; $ products = $ session [ self :: SESSION_KEY ] ; } else { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ...
Gets order items .
54,247
public function getOrderItemsCount ( ) { if ( \ Yii :: $ app -> user -> isGuest ) { $ session = \ Yii :: $ app -> session ; return count ( $ session [ self :: SESSION_KEY ] ) ; } else { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) ...
Gets order items count .
54,248
public function getAllUserOrders ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && $ this -> saveToDataBase === true ) { $ orders = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id ] ) -> andWhere ( [ '!=' , 'status' , OrderStatus :: STATUS_INCOMPLETE ] ) -> all ( ) ; return $ orders ; } else re...
Gets all user orders from database .
54,249
public function removeItem ( int $ productId , int $ combinationId = null ) { if ( ! \ Yii :: $ app -> user -> isGuest ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) { $ orderProduct = Orde...
Removes item from order .
54,250
public function getIncompleteOrder ( ) { if ( ! \ Yii :: $ app -> user -> isGuest ) { $ user = User :: findOne ( \ Yii :: $ app -> user -> id ) ; $ order = Order :: find ( ) -> where ( [ 'user_id' => $ user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) { return $ order...
Gets registered user s incomplete order
54,251
public function clearCart ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && $ this -> saveToDataBase === true ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) $ order -> delete ( ) ; } else {...
Clears cart .
54,252
public function getCost ( ) { $ totalCost = 0 ; if ( Yii :: $ app -> user -> isGuest ) { $ session = Yii :: $ app -> session ; $ products = $ session [ self :: SESSION_KEY ] ; if ( ! empty ( $ products ) ) { foreach ( $ products as $ product ) { if ( ! empty ( $ product [ 'combinationId' ] ) ) { $ combination = Combina...
Gets cost of user s incomplete order without discounts
54,253
public function getTotalCost ( ) { $ totalCost = $ this -> getCost ( ) ; $ adjustmentTotal = 0 ; foreach ( $ this -> adjustments as $ adjustment ) { $ adjustmentObject = Yii :: createObject ( $ adjustment ) ; if ( $ adjustmentObject instanceof CartSumAdjustment ) { $ adjustmentTotal += $ adjustmentObject -> countAdjust...
Gets total cost of user s incomplete order from session if user is guest or from DB if user is authenticated
54,254
public function isContainsProduct ( $ productId , $ combinationId = null ) { if ( Yii :: $ app -> user -> isGuest ) { if ( ! empty ( Yii :: $ app -> session [ self :: SESSION_KEY ] ) ) { $ sessionProducts = Yii :: $ app -> session [ self :: SESSION_KEY ] ; foreach ( $ sessionProducts as $ item ) { $ condition = ( empty...
Checks if the cart contains the product .
54,255
public static function init ( ) { if ( is_null ( self :: $ storage ) ) { self :: $ storage = new NativeSessionStorage ( ) ; } self :: $ storage -> start ( ) ; }
initialize session storage mechanism currently only wraps PHP native session storage
54,256
public function decrypt ( $ input ) { $ input = base64_decode ( $ input ) ; $ iv = substr ( $ input , 0 , Cipher :: IV_SIZE ) ; return openssl_decrypt ( substr ( $ input , Cipher :: IV_SIZE ) , "AES-256-CBC" , $ this -> secretKey , 0 , $ iv ) ; }
Decrypts the input text from the cipher key
54,257
public function filter ( callable $ callback ) : ArrayObject { $ arrayCopy = $ this -> getArrayCopy ( ) ; $ filteredData = array_filter ( $ arrayCopy , $ callback ) ; return new ArrayObject ( $ filteredData ) ; }
Iterates over each value in the array passing them to the callback function . If the callback function returns true the current value from array is returned into the result ArrayObject . Array keys are preserved .
54,258
public function first ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ keys = $ this -> keys ( ) ; $ keyOfTheFirstElement = $ keys -> shift ( ) ; return $ this -> offsetGet ( $ keyOfTheFirstElement ) ; }
Returns the first element ignoring the type of the keys .
54,259
public function shift ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ arrayCopy = $ this -> getArrayCopy ( ) ; $ firstElement = array_shift ( $ arrayCopy ) ; $ this -> exchangeArray ( $ arrayCopy ) ; return $ firstElement ; }
Shift an element off the beginning of array
54,260
public function last ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ keys = $ this -> keys ( ) ; $ keyOfTheLastElement = $ keys -> pop ( ) ; return $ this -> offsetGet ( $ keyOfTheLastElement ) ; }
Returns the last element ignoring the type of the keys .
54,261
public function pop ( ) { $ this -> throwExceptionIfEmpty ( ) ; $ arrayCopy = $ this -> getArrayCopy ( ) ; $ lastElement = array_pop ( $ arrayCopy ) ; $ this -> exchangeArray ( $ arrayCopy ) ; return $ lastElement ; }
Pop the element off the end of array
54,262
public function initCategories ( $ overrideExisting = true ) { if ( null !== $ this -> collCategories && ! $ overrideExisting ) { return ; } $ collectionClassName = CategoryTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collCategories = new $ collectionClassName ; $ this -> collCategories -> setM...
Initializes the collCategories collection .
54,263
public function getCategories ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collCategoriesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCategories || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCategories ) { $ this...
Gets an array of ChildCategory objects which contain a foreign key that references this object .
54,264
public function countCategories ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collCategoriesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCategories || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> co...
Returns the number of related Category objects .
54,265
public function addCategory ( ChildCategory $ l ) { if ( $ this -> collCategories === null ) { $ this -> initCategories ( ) ; $ this -> collCategoriesPartial = true ; } if ( ! $ this -> collCategories -> contains ( $ l ) ) { $ this -> doAddCategory ( $ l ) ; if ( $ this -> categoriesScheduledForDeletion and $ this -> c...
Method called to associate a ChildCategory object to this object through the ChildCategory foreign key attribute .
54,266
public function initMedias ( $ overrideExisting = true ) { if ( null !== $ this -> collMedias && ! $ overrideExisting ) { return ; } $ collectionClassName = MediaTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collMedias = new $ collectionClassName ; $ this -> collMedias -> setModel ( '\Attogram\S...
Initializes the collMedias collection .
54,267
public function getMedias ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collMediasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMedias || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMedias ) { $ this -> initMedias (...
Gets an array of ChildMedia objects which contain a foreign key that references this object .
54,268
public function countMedias ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collMediasPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collMedias || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collMedias ) {...
Returns the number of related Media objects .
54,269
public function addMedia ( ChildMedia $ l ) { if ( $ this -> collMedias === null ) { $ this -> initMedias ( ) ; $ this -> collMediasPartial = true ; } if ( ! $ this -> collMedias -> contains ( $ l ) ) { $ this -> doAddMedia ( $ l ) ; if ( $ this -> mediasScheduledForDeletion and $ this -> mediasScheduledForDeletion -> ...
Method called to associate a ChildMedia object to this object through the ChildMedia foreign key attribute .
54,270
public function initPages ( $ overrideExisting = true ) { if ( null !== $ this -> collPages && ! $ overrideExisting ) { return ; } $ collectionClassName = PageTableMap :: getTableMap ( ) -> getCollectionClassName ( ) ; $ this -> collPages = new $ collectionClassName ; $ this -> collPages -> setModel ( '\Attogram\Shared...
Initializes the collPages collection .
54,271
public function getPages ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collPagesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPages || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collPages ) { $ this -> initPages ( ) ; ...
Gets an array of ChildPage objects which contain a foreign key that references this object .
54,272
public function countPages ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collPagesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collPages || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collPages ) { ret...
Returns the number of related Page objects .
54,273
public function addPage ( ChildPage $ l ) { if ( $ this -> collPages === null ) { $ this -> initPages ( ) ; $ this -> collPagesPartial = true ; } if ( ! $ this -> collPages -> contains ( $ l ) ) { $ this -> doAddPage ( $ l ) ; if ( $ this -> pagesScheduledForDeletion and $ this -> pagesScheduledForDeletion -> contains ...
Method called to associate a ChildPage object to this object through the ChildPage foreign key attribute .
54,274
public function submitMissingKeys ( ) { if ( $ this -> missing_keys_by_sources == null ) return ; $ params = array ( ) ; $ source_keys = array ( ) ; foreach ( $ this -> missing_keys_by_sources as $ source => $ keys ) { array_push ( $ source_keys , $ source ) ; $ keys_data = array ( ) ; foreach ( $ keys as $ key ) { $ j...
Submits missing keys to the service
54,275
public function up ( ) { $ record = new MigrationRecord ( ) ; if ( $ this -> connection !== null ) { $ record -> setConnection ( $ this -> connection ) ; } $ record -> migration = $ this -> name ; $ record -> save ( ) ; }
Insert data into migration table
54,276
public function down ( ) { $ record = new MigrationRecord ( ) ; if ( $ this -> connection !== null ) { $ record -> setConnection ( $ this -> connection ) ; } $ record -> where ( 'migration' , $ this -> name ) -> delete ( ) ; }
Remove data from migration table
54,277
public function run ( ) { $ this -> execute ( ) ; if ( $ handler = $ this -> getFormHandler ( @ $ _REQUEST [ '_form_name' ] ) ) call_user_func ( $ handler , $ _REQUEST ) ; }
The entry point for a plugin . This should be called immediately in your bootstrap file .
54,278
public function addResources ( ) { if ( $ this -> resourceChain === null ) $ this -> resourceChain = new ResourceChain ( $ this ) ; return $ this -> resourceChain ; }
Returns a ResourceChain object that can be used to add stylesheets and scripts .
54,279
public function run ( array $ sources , array $ destinations ) { $ fileSystem = new Filesystem ( ) ; if ( count ( $ sources ) !== count ( $ destinations ) && count ( $ destinations ) !== 1 ) { throw new Exception ( 'Sources and destinations count mismatch' ) ; } if ( count ( $ destinations ) === 1 && ! is_dir ( $ desti...
Copy the sources files to the destinations .
54,280
public function install ( $ module , $ version , $ options = null ) { $ module = strtolower ( $ module ) ; $ options = is_null ( $ options ) ? array ( ) : $ options ; $ modules = $ this -> findModules ( ) ; $ current = array ( ) ; foreach ( $ modules as $ name ) { $ modVersion = $ this -> getModuleVersion ( $ name ) ; ...
Install module dependencies
54,281
public function resolveDependencies ( $ module ) { $ version = $ this -> getModuleVersion ( $ module ) ; if ( null === $ version ) { throw new \ Exception ( sprintf ( "Unable to resolve dependencies for module '%s'. Module definitions are missing or incomplete." , $ module ) ) ; } $ resolved = new \ ArrayObject ( ) ; $...
Resolve module dependencies recursively
54,282
protected function resolveDepsRecursive ( $ module , $ version , \ ArrayObject $ resolved ) { $ module = strtolower ( $ module ) ; if ( $ resolved -> offsetExists ( $ module ) ) { $ new = new SoftwareVersion ( $ version ) ; if ( $ new -> isGt ( $ resolved [ $ module ] ) ) { unset ( $ resolved [ $ module ] ) ; $ resolve...
Resolve dependencies recursively . The level and order in module dependency hierarchy defines the module s priority .
54,283
public function findModules ( ) { $ dirs = $ this -> getOption ( 'module_dirs' ) ; $ modules = array ( ) ; foreach ( $ dirs as $ dir ) { $ iterator = new DirectoryIterator ( $ dir ) ; foreach ( $ iterator as $ file ) { if ( ( $ file -> isDir ( ) && substr ( $ file -> getBasename ( ) , 0 , 1 ) !== '.' ) || ( $ file -> i...
Find all modules installed in module directories
54,284
public function whichModule ( $ object ) { $ reflection = new \ ReflectionClass ( $ object ) ; $ ns = explode ( '\\' , $ reflection -> getNamespaceName ( ) ) ; if ( class_exists ( $ ns [ 0 ] . '\Module' ) ) { $ reflection = new \ ReflectionClass ( $ ns [ 0 ] . '\Module' ) ; return strtolower ( basename ( dirname ( $ re...
Detect the name of the module based on class
54,285
public function getModuleVersion ( $ module ) { $ config = $ this -> getModuleDefinition ( $ module ) ; if ( isset ( $ config [ 'version' ] ) ) { return $ config [ 'version' ] ; } else { return SoftwareVersion :: DEFAULT_UNRESOLVED_VERSION ; } }
Get current version for module
54,286
public function getModuleDefinition ( $ module ) { $ module = strtolower ( $ module ) ; if ( ! array_key_exists ( $ module , $ this -> definitions ) ) { $ path = $ this -> locateModule ( $ module ) ; $ config = array ( ) ; if ( $ path ) { $ definition = $ path . DIRECTORY_SEPARATOR . $ this -> getOption ( 'definition_f...
Get module definition as an array
54,287
public function getModuleDeps ( $ module ) { $ module = strtolower ( $ module ) ; if ( ! isset ( $ this -> deps [ $ module ] ) ) { $ map = array ( ) ; $ deps = array ( ) ; $ modules = $ this -> findModules ( ) ; foreach ( $ modules as $ name ) { $ config = $ this -> getModuleDefinition ( $ name ) ; $ map [ $ name ] = i...
Retrieve list of module dependencies
54,288
public function setConfig ( $ config ) { if ( is_string ( $ config ) && file_exists ( $ config ) ) { $ options = \ Zend \ Config \ Factory :: fromFile ( $ config ) ; $ this -> setOptions ( $ options ) ; } elseif ( ! is_array ( $ config ) && ! ( $ config instanceof \ Traversable ) ) { throw new \ InvalidArgumentExceptio...
Set service options
54,289
public static function getInstance ( Config $ config = null ) { if ( is_null ( self :: $ instance ) ) { if ( is_null ( $ config ) ) { throw new ApplicationException ( 'No configuration object provided. Cannot instantiate application.' ) ; } self :: $ instance = new Application ( $ config ) ; } return self :: $ instance...
Get Application instance .
54,290
public function registerPlugins ( ) { if ( $ this -> plugins ) { foreach ( $ this -> plugins as $ plugin ) { $ this -> eventDispatcher -> removeSubscriber ( $ plugin ) ; } } $ this -> plugins = array ( ) ; if ( $ this -> config -> plugins ) { foreach ( array_keys ( $ this -> config -> plugins ) as $ pluginId ) { $ this...
Unregister all previously registered plugins .
54,291
public function getDb ( ) { if ( empty ( $ this -> db ) ) { if ( empty ( $ this -> config -> db ) ) { try { return $ this -> getVxPDO ( ) ; } catch ( ApplicationException $ e ) { return null ; } } $ config = $ this -> config -> db ; $ this -> db = DatabaseInterfaceFactory :: create ( isset ( $ config -> type ) ? $ conf...
get default vxPDO instance
54,292
public function getVxPDO ( $ name = 'default' ) { if ( ! array_key_exists ( $ name , $ this -> vxPDOInstances ) ) { if ( empty ( $ this -> config -> vxpdo ) || ! array_key_exists ( $ name , $ this -> config -> vxpdo ) ) { throw new ApplicationException ( sprintf ( "vxPDO configuration for '%s' not found." , $ name ) ) ...
get a configured vxPDO instance identified by its datasource name
54,293
public function getService ( $ serviceId ) { $ args = func_get_args ( ) ; $ service = $ this -> initializeService ( $ serviceId , array_splice ( $ args , 1 ) ) ; $ this -> services [ ] = $ service ; return $ service ; }
return a service instance service instances are lazily initialized upon first request
54,294
public function hasService ( $ serviceId ) { return ! empty ( $ this -> config -> services ) && array_key_exists ( $ serviceId , $ this -> config -> services ) ; }
checks whether a service identified by service id is configured no further checks whether service can be invoked are conducted
54,295
public function runsLocally ( ) { if ( is_null ( $ this -> isLocal ) ) { $ remote = isset ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) || isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) || ! ( in_array ( @ $ _SERVER [ 'REMOTE_ADDR' ] , [ '127.0.0.1' , 'fe80::1' , '::1' ] ) || PHP_SAPI === 'cli-server' ) ; $ this -> isLocal = PHP_...
returns true when the application was called from the command line or in a localhost environment
54,296
public function getSourcePath ( ) { if ( is_null ( $ this -> sourcePath ) ) { $ this -> sourcePath = $ this -> rootPath . 'src' . DIRECTORY_SEPARATOR ; } return $ this -> sourcePath ; }
get absolute path to application source
54,297
public function setAbsoluteAssetsPath ( $ path ) { $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( ! is_null ( $ this -> rootPath ) && 0 !== strpos ( $ path , $ this -> rootPath ) ) { throw new ApplicationException ( sprintf ( "'%s' not within application path '%s'." , $ path , $ this -> ro...
set absolute assets path the relative assets path is updated
54,298
public function setRootPath ( $ path ) { $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( ! is_null ( $ this -> absoluteAssetsPath ) && 0 !== strpos ( $ this -> absoluteAssetsPath , $ path ) ) { throw new ApplicationException ( "'$path' not a parent of assets path '{$this->absoluteAssetsPath...
set root path of application if an assetspath is set the relative assets path is updated
54,299
public function getAvailableLocales ( ) { foreach ( $ this -> locales as $ id => $ l ) { if ( ! $ l ) { $ this -> locales [ $ id ] = new Locale ( $ id ) ; } } return $ this -> locales ; }
returns an array with available Locale instances because of lazy instantiation missing instances are created now