idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
47,500
public static function set_Hstore ( $ store ) { if ( $ store instanceof Hstore ) { return $ store ; } try { $ store = new Hstore ( $ store ) ; return $ store ; } catch ( \ InvalidArgumentException $ e ) { return null ; } }
Set entity Hstore
47,501
public static function get_Json ( & $ json ) { if ( $ json instanceof Json ) { return $ json ; } return ! is_null ( $ json ) ? new Json ( $ json ) : null ; }
Get Json from Entity
47,502
public static function set_Json ( $ json , $ inputValidate ) { if ( $ json instanceof Json ) { return $ json ; } elseif ( null === $ json ) { return null ; } elseif ( ! is_string ( $ json ) ) { return Json :: makeFromObject ( $ json ) ; } return new Json ( $ json , $ inputValidate ) ; }
Set entity json property
47,503
public static function get_StockState ( & $ state ) { if ( $ state instanceof StockState or null === $ state ) { $ state = StockState :: makeFromString ( $ state ) ; } return $ state ; }
Get StockState from Entity
47,504
public static function set_StockState ( $ state ) { if ( $ state instanceof StockState or null === $ state ) { $ state = StockState :: makeFromString ( $ state ) ; } return $ state ; }
Set entity StockState
47,505
public static function get_PgLargeObject ( & $ value , Base $ entity ) { if ( $ value instanceof PgLargeObject ) { return $ value -> isDeleted ( ) ? null : $ value ; } if ( is_intish ( $ value ) ) { $ value = new Oid ( $ value , $ entity -> r ( ) -> db ) ; } return ! is_null ( $ value ) ? new PgLargeObject ( $ value ) ...
Get entity PgLargeObject
47,506
public static function set_PgLargeObject ( $ value , $ inputValidate , Base $ entity ) { if ( $ value instanceof PgLargeObject ) { return $ value ; } if ( is_intish ( $ value ) ) { $ value = new Oid ( $ value , $ entity -> r ( ) -> db ) ; } return is_null ( $ value ) ? null : new PgLargeObject ( $ value ) ; }
Set PgLargeObject on entity
47,507
public function getResourceUri ( $ path , $ package = null ) { if ( strpos ( $ path , 'resource://' ) === 0 ) { $ matches = array ( ) ; if ( preg_match ( '#^resource://([^/]+)/Public/(.*)#' , $ path , $ matches ) === 1 ) { $ package = $ matches [ 1 ] ; $ path = $ matches [ 2 ] ; } else { throw new \ Exception ( sprintf...
Appends a shortened md5 of the file .
47,508
public function odd ( array $ storage ) { return $ this -> filter ( $ storage , function ( $ value ) { return $ this -> helper -> math ( ) -> isOdd ( $ value ) ; } ) ; }
1 3 5 ...
47,509
public function even ( array $ storage ) { return $ this -> filter ( $ storage , function ( $ value ) { return $ this -> helper -> math ( ) -> isEven ( $ value ) ; } ) ; }
0 2 4 ...
47,510
final function LoadToBackend ( ) { foreach ( $ this -> Dependencies ( ) as $ depedency ) { $ bundleName = $ depedency -> BundleName ( ) ; if ( ! in_array ( $ bundleName , self :: $ _loadedBundles ) ) { $ depManifest = ClassFinder :: Manifest ( $ bundleName ) ; $ depManifest -> LoadToBackend ( ) ; } } $ this -> LoadBack...
Loads the bundle with all dependencies
47,511
protected function LoadToFrontend ( Site $ site ) { foreach ( $ this -> Dependencies ( ) as $ depedency ) { $ bundleName = $ depedency -> BundleName ( ) ; if ( ! in_array ( $ bundleName , self :: $ _loadedBundles ) ) { $ depManifest = ClassFinder :: Manifest ( $ bundleName ) ; $ depManifest -> LoadToFrontend ( $ site )...
Loads the bundle code and translations to the f
47,512
static function LoadInstalledToBackend ( ) { $ bundles = InstalledBundle :: Schema ( ) -> Fetch ( ) ; foreach ( $ bundles as $ bundle ) { $ manifest = ClassFinder :: Manifest ( $ bundle -> GetBundle ( ) ) ; $ manifest -> LoadToBackend ( ) ; } }
Loads all installed bundles to the backend
47,513
static function LoadInstalledToFrontend ( Site $ site ) { $ bundles = InstalledBundle :: Schema ( ) -> Fetch ( ) ; foreach ( $ bundles as $ bundle ) { $ manifest = ClassFinder :: Manifest ( $ bundle -> GetBundle ( ) ) ; $ manifest -> LoadToFrontend ( $ site ) ; } }
Loads installed bundles to the frontend
47,514
public function getRawContent ( int $ max_length = - 1 ) { $ max_length = $ max_length < 0 ? $ this -> content_length : $ max_length ; $ max_length = min ( 4096 * 1024 , $ max_length , $ this -> content_length ) ; $ str = $ this -> getContentStream ( ) ; $ data = stream_get_contents ( $ str , $ this -> content_length )...
Get the raw content as a string
47,515
public function getParsedContent ( ) { $ filetype = FileType :: getExtension ( $ this -> content_type ) ; if ( empty ( $ filetype ) ) throw new ParseException ( "Unknown content type" ) ; $ filename = "content." . $ filetype ; $ reader = ReaderFactory :: factory ( $ filename ) ; $ parsed = $ reader -> readFileHandle ( ...
Return the parsed content . The FileFormats readers will be used to parse the data and store it in a dictionary .
47,516
public function configurationObjectAfter ( GetConfigurationObjectDTO $ serviceDataTransferObject ) { $ this -> delay ( self :: PRIORITY_SAVE_OBJECTS_WITH_PARENTS_PATHS , function ( GetConfigurationObjectDTO $ serviceDataTransferObject ) { if ( false === empty ( $ this -> objectsWithParentsPaths ) ) { $ serviceDataTrans...
This function will first save the entire storage of properties paths set in the function objectConversionAfter .
47,517
protected function insertParents ( $ entity , array $ path , array $ parents ) { $ propertyName = reset ( $ path ) ; $ propertyValue = Core :: get ( ) -> getObjectService ( ) -> getObjectProperty ( $ entity , $ propertyName ) ; if ( 1 === count ( $ path ) ) { if ( is_object ( $ propertyValue ) && Core :: get ( ) -> get...
Internal function to fill the parents .
47,518
public function import ( $ input ) { if ( is_array ( $ input ) ) { $ this -> fromArray ( $ input ) ; } else { $ this -> fromString ( $ input ) ; } return $ this ; }
Import the given input
47,519
public function toArray ( ) { $ qs = $ this -> query instanceof QueryString ? $ this -> query -> toString ( ) : '' ; return array ( 'scheme' => $ this -> scheme , 'host' => $ this -> host , 'port' => $ this -> port , 'user' => $ this -> user , 'pass' => $ this -> pass , 'path' => $ this -> path , 'basename' => $ this -...
Convert to an array
47,520
public function toString ( ) { $ result = "" ; if ( ! empty ( $ this -> scheme ) ) { $ result .= "{$this->scheme}://" ; } if ( ! empty ( $ this -> user ) ) { $ result .= ! empty ( $ this -> pass ) ? "{$this->user}:{$this->pass}@" : "{$this->user}@" ; } $ result .= $ this -> host ; if ( ! empty ( $ this -> port ) && ( i...
Convert to a string .
47,521
protected function buildPath ( ) { $ this -> basename = $ this -> filename ; if ( ! empty ( $ this -> extension ) ) { $ this -> basename .= '.' . $ this -> extension ; } $ this -> path = $ this -> dirname ; if ( ! empty ( $ this -> basename ) ) { $ this -> path .= '/' . $ this -> basename ; } return $ this ; }
Rebuild the path using the path components
47,522
protected function fromArray ( $ array ) { if ( empty ( $ array ) ) { return $ this ; } $ this -> query = new QueryString ( ) ; if ( ! empty ( $ array [ 'query' ] ) ) { $ this -> query -> import ( $ array [ 'query' ] ) ; } $ keys = array ( 'scheme' , 'host' , 'port' , 'user' , 'pass' , 'path' , 'fragment' , 'dirname' ,...
Import from an array
47,523
protected function fromString ( $ uri ) { if ( empty ( $ uri ) ) { return $ this ; } $ this -> fromArray ( parse_url ( $ uri ) ) ; return $ this ; }
Import from a string
47,524
protected function parsePath ( $ path = null ) { $ this -> dirname = '' ; $ this -> basename = '' ; $ this -> extension = '' ; $ this -> filename = '' ; if ( empty ( $ path ) ) { return $ this ; } $ parts = pathinfo ( $ path ) ; if ( isset ( $ parts [ 'dirname' ] ) ) { $ this -> dirname = rtrim ( $ parts [ 'dirname' ] ...
Extract the path components from the current path
47,525
public function withLevel ( $ level ) { if ( ! isset ( self :: $ levels [ $ level ] ) ) { throw new InvalidArgumentException ( 'Unsupported log level "' . $ level . '"' ) ; } $ this -> level = $ level ; }
Set log level for logger
47,526
public static function validateURI ( $ uri ) { if ( ! empty ( trim ( $ uri ) ) ) { return filter_var ( trim ( $ uri ) , FILTER_VALIDATE_URL ) ; } return false ; }
Validates that a URI is valid
47,527
protected function doExecuteActions ( $ method , array $ actionManagers ) { $ actions = array ( 'post' => array ( ) , 'notExecuted' => array ( ) ) ; $ this -> executeFailedActions ( $ method ) ; if ( 0 !== count ( $ actionManagers ) ) { $ actions = $ this -> execute ( $ method , $ actionManagers ) ; if ( ! empty ( $ ac...
Executes the given method defined by the given ActionsManager
47,528
protected function executeFailedActions ( $ action ) { $ fileName = $ this -> basePath . '/.' . $ action ; if ( file_exists ( $ fileName ) ) { $ actionManagers = $ this -> decode ( $ fileName ) ; $ actions = $ this -> execute ( $ action , $ actionManagers ) ; $ this -> writeFailedActions ( '.' . $ action , $ actions [ ...
Executes the failed action
47,529
protected function execute ( $ method , array $ actionManagers ) { $ actions = array ( 'post' => array ( ) , 'notExecuted' => array ( ) ) ; foreach ( $ actionManagers as $ bundleName => $ actionManager ) { $ this -> actionManagerGenerator -> generate ( $ actionManager ) ; $ actionManagerClass = $ this -> actionManagerG...
Executes the actions
47,530
protected function writePostActions ( $ fileName , array $ actions ) { $ fileName = $ this -> basePath . '/' . $ fileName ; $ this -> encode ( $ fileName , $ actions ) ; }
Writes the post actions file
47,531
protected function writeFailedActions ( $ fileName , $ actions ) { $ fileName = $ this -> basePath . '/' . $ fileName ; $ this -> filesystem -> remove ( $ fileName ) ; if ( ! empty ( $ actions ) ) $ this -> encode ( $ fileName , $ actions ) ; }
Writes the failed actions file
47,532
protected function validateSignature ( ) { $ check = [ ] ; foreach ( $ this -> data as $ key => $ value ) { if ( $ key !== 'brq_signature' ) { $ check [ $ key ] = $ value ; } } $ signature = new Signature ( $ check , $ this -> secretKey ) ; if ( empty ( $ this -> data [ 'brq_signature' ] ) || ( string ) $ signature !==...
Validate the transaction .
47,533
public function input ( $ key = null , $ default = null ) { $ input = $ this -> getInputSource ( ) ; return $ this -> inputSift ( $ input , $ key , $ default ) ; }
Retrieves an input .
47,534
protected function transform ( $ data , $ hypertextRoutes = [ ] ) { $ links = $ this -> getHypertextJson ( $ hypertextRoutes ) ; if ( $ links && is_array ( $ data ) ) { $ data [ '_links' ] = $ links ; } elseif ( $ links && ! is_array ( $ data ) ) { $ data = [ $ data , '_links' => $ links ] ; } return json_encode ( $ da...
Transforms the data into a json response .
47,535
private function getHypertextJson ( $ routes = [ ] ) { if ( ! $ routes ) { return false ; } $ links = [ ] ; foreach ( $ routes as $ name => $ route ) { $ links [ ] = [ 'rel' => $ name , 'href' => $ route ] ; } return $ links ; }
Transforms the hypertext routes into an array for the json string .
47,536
public function filterLoad ( AssetInterface $ asset ) { static $ format = <<<'EOF'#!/usr/bin/env rubyrequire %s%soptions = { :load_path => [], :source_files => [%s], :expand_paths => false }%ssecretary = Sprockets::Secretary.new(options)secretary.install_assets if options[:asset_root]print sec...
Hack around a bit get the job done .
47,537
private function strposArray ( $ haystack , $ needles ) { if ( is_array ( $ needles ) ) { foreach ( $ needles as $ needle ) { if ( ( $ strpos = strpos ( $ haystack , $ needle ) ) !== false ) { return $ strpos ; } } } return false ; }
Find the position of the first occurrence of any of several substrings in a string
47,538
public function load ( $ test = true ) { $ missingTables = false ; if ( $ test ) { $ missingTables = $ this -> test ( ) ; } if ( ! $ test || ( $ test && $ missingTables !== false ) ) { foreach ( explode ( ';' , $ this -> schema ) as $ query ) { if ( ! empty ( trim ( $ query ) ) ) { if ( ! $ test || $ this -> strposArra...
Load the schema into the database
47,539
public function assertEmail ( $ subject , $ address ) { $ message = $ this -> getMailCatcherClient ( ) -> searchOne ( [ Message :: SUBJECT_CRITERIA => $ subject , Message :: TO_CRITERIA => $ address ] ) ; if ( is_null ( $ message ) ) { throw new Exception ( "Message not found." ) ; } }
Check for email .
47,540
protected function getQueryBuilder ( $ alias = null , $ indexBy = null ) { $ qb = $ this -> traitGetQueryBuilder ( $ alias , $ indexBy ) ; $ alias = $ alias ? : $ this -> getAlias ( ) ; return $ qb -> addSelect ( 'translation' ) -> leftJoin ( $ alias . '.translations' , 'translation' ) ; }
Returns the singe result query builder .
47,541
protected function getCollectionQueryBuilder ( $ alias = null , $ indexBy = null ) { $ qb = $ this -> traitGetCollectionQueryBuilder ( $ alias , $ indexBy ) ; $ alias = $ alias ? : $ this -> getAlias ( ) ; return $ qb -> addSelect ( 'translation' ) -> leftJoin ( $ alias . '.translations' , 'translation' ) ; }
Returns the collection query builder .
47,542
public function createNew ( ) { $ resource = $ this -> traitCreateNew ( ) ; if ( ! $ resource instanceof TranslatableInterface ) { throw new \ InvalidArgumentException ( 'Resource must implement TranslatableInterface.' ) ; } $ resource -> setCurrentLocale ( $ this -> localeProvider -> getCurrentLocale ( ) ) ; $ resourc...
Returns a new resource instance .
47,543
public function getUserEndorsement ( $ user ) { return $ this -> endorsements -> filter ( function ( $ e ) use ( $ user ) { return $ e -> getUser ( ) == $ user ; } ) -> first ( ) ; }
Get the current endorsement for a specific user_id
47,544
public function validate ( array $ credentials = [ ] ) { $ credentials = [ $ this -> storageKey => $ credentials [ $ this -> inputKey ] ] ; if ( $ this -> auth -> retrieveByCredentials ( $ credentials ) ) return true ; return false ; }
Validate a acct s credentials .
47,545
protected function _createInternalException ( $ message = null , $ code = null , $ previous = null ) { return new InternalException ( $ message , $ code , $ previous ) ; }
Creates a new Internal exception .
47,546
public function encompasses ( DateTimeRange $ otherRange ) : bool { return $ this -> start -> comesBeforeOrEqual ( $ otherRange -> start ) && $ this -> end -> comesAfterOrEqual ( $ otherRange -> end ) ; }
Returns whether the supplied date time range is encompassed by this date time range .
47,547
public function method ( ) { $ emulated = filter_input ( INPUT_GET , '_method' , FILTER_SANITIZE_STRING ) ; if ( ! $ emulated ) { $ emulated = filter_input ( INPUT_POST , '_method' , FILTER_SANITIZE_STRING ) ; } if ( $ this -> app -> config ( 'request.emulate' ) && $ emulated ) { return $ emulated ; } return $ _SERVER ...
Retrieves the request method
47,548
public function token ( ) { $ inputs = $ this -> getInputs ( ) ; $ headers = $ this -> headers ( ) ; if ( isset ( $ headers [ 'X-Auth-Token' ] ) ) { return $ headers [ 'X-Auth-Token' ] ; } if ( isset ( $ inputs [ 'token' ] ) ) { return $ inputs [ 'token' ] ; } return false ; }
Retrieves the token
47,549
public function input ( $ input = null , $ default = null ) { $ inputs = array_merge ( $ this -> getInputs ( ) , $ this -> additionalInputs ) ; foreach ( $ inputs as $ key => $ value ) { if ( in_array ( $ key , $ this -> reserved ) ) { unset ( $ inputs [ $ key ] ) ; } } if ( $ input ) { return isset ( $ inputs [ $ inpu...
Returns a request input
47,550
public function file ( $ input = null ) { if ( ! isset ( $ input ) || ! isset ( $ _FILES [ $ input ] ) ) { throw new \ InvalidArgumentException ( 'Invalid file' , 400 ) ; } return $ _FILES [ $ input ] ; }
Gets a request file
47,551
public function storeFile ( $ input = null , $ target ) { if ( ! isset ( $ input ) || ! isset ( $ target ) ) { throw new \ InvalidArgumentException ( 'Undefined input name or target' , 400 ) ; } $ result = move_uploaded_file ( $ _FILES [ $ input ] [ 'tmp_name' ] , $ target ) ; if ( ! $ result ) { throw new \ InvalidArg...
Stores a request file
47,552
private function getInputs ( ) { if ( $ this -> inputs ) { return $ this -> inputs ; } if ( isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) && strpos ( $ _SERVER [ 'CONTENT_TYPE' ] , 'application/json' ) === 0 ) { $ input = file_get_contents ( 'php://input' ) ; $ decoded = json_decode ( $ input , true ) ; if ( $ decoded ) { $ t...
Stores the parameters from the request in the inputs array
47,553
public function getSdkCommand ( $ parameters = [ ] ) { return $ this -> injectMiddleware ( $ this -> dm -> getClient ( ) -> getCommand ( static :: $ sdkName , array_merge ( $ this -> parameters , $ parameters ) ) ) ; }
Return the prepared AWS SDK Command object to be executed .
47,554
private function getReferredParentId ( $ customerId ) { $ result = $ customerId ; $ area = $ this -> state -> getAreaCode ( ) ; if ( $ area == \ Magento \ Framework \ App \ Area :: AREA_ADMINHTML ) { $ defRootMlmId = $ this -> hlpConfig -> getReferralsRootAnonymous ( ) ; $ parent = $ this -> daoDwnlCust -> getByMlmId (...
Analyze referral code and get parent for the customer if parent ID was missed in request .
47,555
public function getParameter ( $ name ) { if ( array_key_exists ( $ name , $ this -> parameters ) ) { return $ this -> parameters [ $ name ] ; } if ( func_num_args ( ) > 1 ) { return func_get_arg ( 1 ) ; } throw new ContextParamNotFoundException ( sprintf ( 'Container parameter "%s" was not found' , $ name ) ) ; }
Get the value of the given parameter .
47,556
public function bind ( $ typeName ) { if ( $ this -> proxyTypes !== NULL ) { $ this -> proxyTypes = NULL ; } $ key = strtolower ( $ typeName ) ; switch ( $ key ) { case 'koolkode\config\configuration' : case 'koolkode\context\containerinterface' : case 'koolkode\context\exposedcontainerinterface' : case 'koolkode\conte...
Create a binding for the given type the binding is registered in the builder and will be bound by the created DI container binding multiple times to the same type will modify the existing binding instead of creating a new binding!
47,557
public function getProxyBindings ( ) { if ( $ this -> proxyTypes === NULL ) { $ this -> proxyTypes = [ ] ; foreach ( $ this -> bindings as $ binding ) { $ scope = $ binding -> getScope ( ) ; if ( $ scope === NULL ) { continue ; } if ( Singleton :: class == $ scope ) { continue ; } $ this -> proxyTypes [ strtolower ( $ ...
Get all bindings that require a scope proxy .
47,558
public function subQuery ( $ table , $ alias = null ) { $ sub = new self ( ) ; if ( ! $ alias ) $ alias = 'sub_' . $ this -> subQueryCount ++ ; $ sub -> table ( $ table , $ alias ) ; $ sub -> setParentTable ( $ this -> getAliasOrTable ( ) ) ; return $ sub ; }
return a new Sql|Query object as sub - query .
47,559
public function value ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { $ this -> values += $ name ; } elseif ( func_num_args ( ) > 1 ) { $ this -> values [ $ name ] = $ value ; } return $ this ; }
set values for insert or update .
47,560
public function handleAddAcl ( string $ role , string $ resource = null , string $ privilege = null ) { $ idRole = $ this -> identityAuthorizator -> getIdRoleByName ( $ role ) ; $ idResource = null ; if ( $ resource ) { $ idResource = $ this -> identityAuthorizator -> getIdResourceByName ( $ resource ) ; } $ idPrivileg...
Handle add acl .
47,561
public static function all ( $ locale = null ) { return static :: keys ( ) -> mapWithKeys ( function ( $ key ) use ( $ locale ) { return [ $ key => trans ( "blog::posts.statuses.{$key}" , [ ] , $ locale ) ] ; } ) ; }
Get all posts status
47,562
public static function get ( $ key , $ default = null , $ locale = null ) { return self :: all ( $ locale ) -> get ( $ key , $ default ) ; }
Get a post status .
47,563
public function renderMedia ( MediaInterface $ media , array $ params = [ ] ) { switch ( $ media -> getType ( ) ) { case MediaTypes :: VIDEO : return $ this -> renderVideo ( $ media , $ params ) ; case MediaTypes :: FLASH : return $ this -> renderFlash ( $ media , $ params ) ; case MediaTypes :: AUDIO : return $ this -...
Renders the media .
47,564
public function renderVideo ( MediaInterface $ video , array $ params = [ ] ) { if ( $ video -> getType ( ) !== MediaTypes :: VIDEO ) { throw new \ InvalidArgumentException ( 'Expected media with "video" type.' ) ; } $ params = array_merge ( [ 'responsive' => false , 'aspect_ratio' => '16by9' , 'attr' => [ 'id' => 'med...
Renders the video .
47,565
public function renderFlash ( MediaInterface $ flash , array $ params = [ ] ) { if ( $ flash -> getType ( ) !== MediaTypes :: FLASH ) { throw new \ InvalidArgumentException ( 'Expected media with "flash" type.' ) ; } $ params = array_merge ( [ 'attr' => [ 'id' => 'media-flash-' . $ flash -> getId ( ) , 'class' => 'swf-...
Renders the flash swf .
47,566
public function renderAudio ( MediaInterface $ audio , array $ params = [ ] ) { if ( $ audio -> getType ( ) !== MediaTypes :: AUDIO ) { throw new \ InvalidArgumentException ( 'Expected media with "audio" type.' ) ; } $ params = array_merge ( [ 'attr' => [ 'id' => 'media-audio-' . $ audio -> getId ( ) , ] , ] , $ params...
Renders the audio .
47,567
public function getIsSingleIterator ( ) { $ iter = $ this -> CloneInstance ( ) ; $ part1 = $ iter -> MoveNext ( ) ; if ( $ part1 ) { $ part2 = ! $ iter -> MoveNext ( ) ; if ( $ part2 ) return true ; } return false ; }
Check to see if the iterator has just one item
47,568
public function init ( ) { if ( ! $ this -> serviceContainer -> isRegistered ( ServiceContainer :: SERVICE_LOGGER ) || ! ( $ this -> getLogger ( ) instanceof LoggerInterface ) ) { $ this -> setService ( ServiceContainer :: SERVICE_LOGGER , new NullLogger ( ) ) ; } $ this -> getControllerDispatcher ( ) -> setLogger ( $ ...
Initialize application before execution
47,569
public function run ( Request $ request = null ) { $ this -> init ( ) ; $ this -> getLogger ( ) -> debug ( 'Application launched' ) ; if ( ! ( $ request instanceof Request ) ) { $ appMode = $ this -> detectRunMode ( ) ; if ( $ appMode == self :: MODE_WEB ) { $ request = Request \ Web :: makeFromGlobals ( ) ; } else { $...
Run Application and output content
47,570
function getSchema ( ) { $ schema = 'CREATE TABLE IF NOT EXISTS ' . $ this -> table . ' (' ; $ sep = PHP_EOL ; foreach ( $ this -> schema as $ fld ) { $ schema .= $ sep . $ fld ; $ sep = ', ' . PHP_EOL ; } $ schema .= PHP_EOL . ');' . PHP_EOL ; foreach ( $ this -> indecies as $ index ) { foreach ( $ index as $ type => ...
Creates the schema of the DB according to the defined
47,571
public function getFirst ( $ q = [ ] , $ data = [ ] ) { $ q [ 'limit' ] = 1 ; $ list = $ this -> get ( $ q , $ data ) ; return ( count ( $ list ) ) ? $ list [ 0 ] : null ; }
Gets the first item as predfined by any previous functional operators
47,572
public function where ( $ column , $ value , $ operator = '=' , $ table = null ) { $ table = $ table ? $ table : $ this -> table ; $ this -> db ( ) -> where ( $ column , $ value , $ operator , $ table ) ; return $ this ; }
Sets a where condition
47,573
public function whereIn ( $ column , $ values , $ table = null ) { $ this -> db ( ) -> whereIn ( $ column , $ values , $ table ) ; return $ this ; }
Sets a where in condition
47,574
public function search ( $ filters = [ ] ) { $ resolved = [ ] ; if ( ! isset ( $ filters ) || ! is_array ( $ filters ) ) { throw new \ InvalidArgumentException ( 'Undefined search filters' , 400 ) ; } if ( isset ( $ filters [ 'limit' ] ) ) { $ this -> limit ( $ filters [ 'limit' ] ) ; } if ( isset ( $ filters [ 'offset...
Sets an array of filters as where conditions
47,575
public function get ( ) { $ this -> beforeGet ( ) ; $ this -> db ( ) -> table ( $ this -> table ) -> select ( $ this -> columns ) -> limit ( $ this -> limit ) -> offset ( $ this -> offset ) -> orderBy ( $ this -> orderBy ) ; $ this -> hasOne ( ) -> belongsToMany ( ) ; $ this -> records = $ this -> db ( ) -> get ( ) ; $...
Returns an array of models
47,576
public function count ( ) { $ this -> db ( ) -> table ( $ this -> table ) -> groupBy ( $ this -> table . '.' . $ this -> primaryKey ) ; $ this -> hasOne ( ) -> belongsToMany ( ) ; $ count = $ this -> db ( ) -> count ( $ this -> primaryKey ) ; return $ count ; }
Returns the total number of models
47,577
public function find ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to find' , 400 ) ; } $ result = $ this -> where ( $ this -> primaryKey , $ id , '=' , $ this -> table ) -> limit ( 1 ) -> first ( ) ; return $ result ; }
Returns a single model by primary key
47,578
public function first ( ) { $ result = $ this -> get ( ) ; if ( ! $ result || ! is_array ( $ result ) || empty ( $ result ) ) { return false ; } return reset ( $ result ) ; }
Returns the first model found
47,579
public function create ( $ attributes = [ ] ) { if ( ! ( isset ( $ attributes ) ) || ! is_array ( $ attributes ) ) { throw new \ InvalidArgumentException ( 'Undefined attributes' , 400 ) ; } $ attributes = $ this -> beforeCreate ( $ attributes ) ; $ fields = array_intersect_key ( $ attributes , array_flip ( $ this -> f...
Creates a new model
47,580
public function update ( $ id = null , $ attributes = [ ] ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to update' , 400 ) ; } if ( ! ( isset ( $ attributes ) ) || ! is_array ( $ attributes ) ) { throw new \ InvalidArgumentException ( 'Undefined attributes' , 400 ) ; } $ attributes ...
Updates a model
47,581
public function destroy ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to destroy' , 400 ) ; } $ this -> beforeDestroy ( $ id ) ; $ result = $ this -> db ( ) -> table ( $ this -> table ) -> where ( $ this -> primaryKey , $ id ) -> limit ( 1 ) -> delete ( ) ; if ( ! $ re...
Destroys a model
47,582
private function hasOne ( ) { if ( ! isset ( $ this -> relationships [ 'hasOne' ] ) || empty ( $ this -> relationships [ 'hasOne' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'hasOne' ] as $ join ) { $ this -> db ( ) -> join ( $ join [ 'table' ] , $ join [ 'localKey' ] , '=' , $ join [ 'foreignKey' ] )...
Resolves one to one relationships
47,583
private function hasMany ( ) { if ( ! isset ( $ this -> relationships [ 'hasMany' ] ) || empty ( $ this -> relationships [ 'hasMany' ] ) ) { return $ this ; } $ ids = array_column ( $ this -> records , 'id' ) ; if ( empty ( $ ids ) ) { return $ this ; } $ records = array_combine ( $ ids , $ this -> records ) ; foreach ...
Resolves one to many relationships
47,584
private function belongsToMany ( ) { if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } $ this -> db ( ) -> groupBy ( $ this -> table . '.' . $ this -> primaryKey ) ; foreach ( $ this -> relationships [ 'belongsToMany' ] as $ join ...
Resolves many to many relationships
47,585
private function sync ( $ id , $ attributes ) { if ( ! isset ( $ id ) || ! isset ( $ attributes ) || empty ( $ attributes ) ) { return $ this ; } if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } foreach ( $ this -> relationships ...
Syncs many to many relationships
47,586
private function formatBelongsToMany ( ) { if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'belongsToMany' ] as $ join ) { $ this -> records = array_map ( function ( $ record ) use ( $ join ) ...
Format many to many relationships results
47,587
private function formatHasOne ( ) { if ( ! isset ( $ this -> relationships [ 'hasOne' ] ) || empty ( $ this -> relationships [ 'hasOne' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'hasOne' ] as $ join ) { $ this -> records = array_map ( function ( $ record ) use ( $ join ) { foreach ( $ record as $ ke...
Format has many relationships results
47,588
public function validationErrors ( $ attributes , $ rules = null ) { $ this -> rules = $ this -> setValidationRules ( ) ; $ ruleSet = isset ( $ rules ) ? $ rules : $ this -> validate ; $ errors = [ ] ; $ attributes = array_intersect_key ( $ attributes , array_flip ( array_keys ( $ ruleSet ) ) ) ; foreach ( $ ruleSet as...
Validates a model
47,589
public function onLogin ( Login $ event ) { $ ip = $ this -> request -> getClientIp ( ) ; $ this -> updateFields ( $ this -> auth , $ ip ) ; }
Listener for the login event .
47,590
public function classExists ( $ className ) { if ( ! $ className ) { return false ; } if ( false === isset ( $ this -> existingClassList [ $ className ] ) ) { $ this -> existingClassList [ $ className ] = class_exists ( $ className ) || interface_exists ( $ className ) ; } return $ this -> existingClassList [ $ classNa...
Internal function which will check if the given class exists . This is useful because of the calls to undefined class which can lead to a lack of performance due to the auto - loader called if the name of the class is not registered yet .
47,591
public function getGettablePropertiesOfObject ( $ object ) { $ className = get_class ( $ object ) ; if ( false === isset ( $ this -> gettablePropertiesOfObjects [ $ className ] ) ) { $ this -> gettablePropertiesOfObjects [ $ className ] = [ ] ; $ properties = $ this -> getReflectionService ( ) -> getClassPropertyNames ...
Returns the list of properties which are accessible for this given object .
47,592
public function preparing ( Promised $ started , Promised $ stopping ) : Promised { $ starts = [ ] ; foreach ( $ this -> dr ( ) -> servers ( ) as $ api ) { foreach ( $ this -> dr ( ) -> services ( $ api ) as $ service => $ route ) { DI :: set ( $ class = $ route [ 1 ] , $ server = DI :: object ( $ class ) ) ; if ( $ se...
bind service implementer
47,593
public static function getNonce ( string $ action , Session $ session , array $ context = [ ] , int $ timestamp = null ) { $ timestamp = $ timestamp ?? time ( ) ; $ hashable = $ action . $ timestamp . $ session -> getSessionSalt ( ) ; foreach ( $ context as $ key => $ value ) { if ( $ value === null ) $ value = "NULL" ...
Get a nonce for the specified action optionally including context
47,594
public static function validateNonce ( string $ action , Session $ session , Dictionary $ arguments , array $ context = [ ] ) { if ( ! $ arguments -> has ( self :: $ nonce_parameter , Type :: STRING ) ) { return null ; } $ context_values = [ ] ; foreach ( $ context as $ key => $ value ) { if ( is_int ( $ key ) ) { $ ke...
Check if a nonce was posted and if it matches the data
47,595
public function required ( string $ alias , string $ type ) : EntityDefinitionOptions { return $ this -> required [ $ alias ] = new EntityDefinitionOptions ( $ alias , $ type ) ; }
Adds a required column
47,596
public function optional ( string $ alias , string $ type ) : EntityDefinitionOptions { return $ this -> optional [ $ alias ] = new EntityDefinitionOptions ( $ alias , $ type ) ; }
Adds an optional column
47,597
public function timestamps ( ) : void { $ this -> optional ( 'created_at' , Timestamp :: class ) -> readOnly ( ) ; $ this -> optional ( 'updated_at' , Timestamp :: class ) -> readOnly ( ) ; }
Adds created_at and updated_at timestamps
47,598
public function hasMany ( string $ alias , string $ entity ) : Relation { return $ this -> has_many [ $ entity ] = new Relation ( $ alias , $ this -> full_name , $ entity ) ; }
Add a has many relationship
47,599
public function hasManyThrough ( string $ alias , string $ entity_join , string $ entity_foreign ) : HasManyThrough { return $ this -> has_many_through [ ] = new HasManyThrough ( $ alias , $ entity_join , $ entity_foreign ) ; }
Add a has many through relationship