idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
234,500
protected function loadModel ( $ modelName , $ directories ) : ModelAbstract { if ( empty ( $ directories ) ) { throw new ModelException ( "Could not load model. No directories provided" , 1 ) ; } $ class = trim ( $ modelName , '/' ) ; if ( ( $ last_slash = strrpos ( $ class , '/' ) ) !== FALSE ) { $ subdir = substr ( ...
Load and return a model .
234,501
public function removeModelPath ( $ directory ) { if ( ( $ key = array_search ( $ directory , $ this -> modelPaths ) ) !== false ) { unset ( $ this -> modelPaths [ $ key ] ) ; } }
Remove a path where models can be found
234,502
public static function setDefaultEncoding ( $ encoding = null ) { if ( ! is_null ( $ encoding ) && is_string ( $ encoding ) && ! empty ( $ encoding ) ) { self :: $ defaultencoding = $ encoding ; } else { self :: $ defaultencoding = null ; } }
Set global default encoding
234,503
public function newInstance ( $ value = null ) { $ class = $ this -> getClassName ( ) ; $ o = new $ class ( $ value , $ this -> encoding ) ; return $ o ; }
Creates new instance of current class type
234,504
protected function getEncoding ( $ encoding = null ) { if ( is_null ( $ encoding ) ) { if ( ! is_null ( $ this -> encoding ) ) { return $ this -> encoding ; } return self :: getDefaultEncoding ( ) ; } return $ encoding ; }
Helper function to set default encoding
234,505
public function substr ( $ start , $ length = null ) { return $ this -> newInstance ( mb_substr ( $ this -> toString ( ) , $ start , $ length , $ this -> getEncoding ( ) ) ) ; }
Return a substring of value
234,506
public function split ( $ separator ) { $ temp = explode ( $ separator , $ this -> toString ( ) ) ; $ list = ArrayList :: asType ( $ this -> getClassName ( ) , $ temp ) ; return $ list ; }
Split string by separator
234,507
protected function padDynamic ( $ padstr , $ length , $ type ) { return $ this -> newInstance ( str_pad ( $ this -> toString ( ) , $ length , $ padstr , $ type ) ) ; }
Helper function for string padding
234,508
protected function indexOfDyamic ( $ function , $ needle , $ offset ) { $ r = $ function ( $ this -> toString ( ) , $ needle , $ offset , $ this -> getEncoding ( ) ) ; return ( $ r === false ? - 1 : $ r ) ; }
Helper function for strpos
234,509
protected function lastIndexOfDynamic ( $ function , $ needle , $ offset = 0 ) { $ r = $ function ( $ this -> toString ( ) , $ needle , $ offset , $ this -> getEncoding ( ) ) ; return ( $ r === false ? - 1 : $ r ) ; }
Helper function for strrpos
234,510
protected function endsWithDynamic ( $ function , $ needle ) { $ enc = $ this -> getEncoding ( ) ; $ strlen = $ this -> length ( $ enc ) ; $ testlen = mb_strlen ( $ needle , $ enc ) ; if ( $ testlen <= $ strlen ) { return ( $ function ( $ this -> toString ( ) , $ needle , ( $ strlen - $ testlen ) , $ enc ) !== false ) ...
Helper function for endsWith
234,511
public function match ( $ regex ) { $ match = array ( ) ; if ( $ this -> isValidRegex ( $ regex ) && preg_match ( $ regex , $ this -> toString ( ) , $ match ) === 1 ) { return new ObjectArray ( $ match ) ; } return null ; }
Match value against regex
234,512
public function matchAll ( $ regex ) { $ matches = array ( ) ; $ result = preg_match_all ( $ regex , $ this -> toString ( ) , $ matches , PREG_SET_ORDER ) ; if ( $ this -> isValidRegex ( $ regex ) && $ result !== false && $ result > 0 ) { return ArrayList :: asObjectArray ( $ matches ) ; } return null ; }
Get all matches by regex
234,513
public function CreateArray ( ) { $ allPackages = $ this -> allLaSalleSoftwarePackages ( ) ; $ installedPackages = [ ] ; foreach ( $ allPackages as $ class ) { if ( defined ( "\\" . $ class . "\\Version::VERSION" ) ) { $ installedPackages [ ] = [ 'class' => $ class , 'version' => constant ( "\\" . $ class . "\\Version:...
What LaSalle Software packages are installed?
234,514
public function addStyle ( $ href , $ path = null ) { $ key = $ this -> calculateKey ( $ href , $ path ) ; $ this -> styles [ $ key ] = 1 ; return $ this ; }
this method add css file
234,515
public function deleteStyle ( $ href , $ path = null ) { $ key = $ this -> calculateKey ( $ href , $ path ) ; if ( isset ( $ this -> styles [ $ key ] ) ) { unset ( $ this -> styles [ $ key ] ) ; } return $ this ; }
This method remove css file from list
234,516
public function buildCode ( ) { $ res = '' ; foreach ( $ this -> styles as $ href => $ val ) { $ res .= '<link href="' . $ href . '" rel="stylesheet" type="text/css" />' . "\r\n" ; } return $ res ; }
This method generate code for include css files
234,517
public static function fromQName ( $ qn ) { $ qname = new QNameValue ( ) ; $ qname -> LocalName = $ qn -> localName ; $ qname -> Prefix = $ qn -> prefix ; $ qname -> NamespaceUri = $ qn -> namespaceURI ; if ( strlen ( $ qn -> localName ) == 0 || ! preg_match ( "/^" . NameValue :: $ ncName . "$/u" , $ qn -> localName ) ...
Create a QNameValue from a QName
234,518
public static function fromXPathNavigator ( $ node ) { return QNameValue :: fromQName ( new \ lyquidity \ xml \ qname ( $ node -> getPrefix ( ) , $ node -> getNamespaceURI ( ) , $ node -> getLocalName ( ) ) ) ; }
Create a QNameValue instance fron an XPathNavigator instance
234,519
public function isValid ( $ discount , $ request ) { $ code = $ this -> validate ( $ discount , $ request ) ; if ( $ code == Discount_Engine :: VALIDATION_CODE_VALID ) return true ; return false ; }
Check if give discount is valid or not .
234,520
private function buildUrl ( $ mode , $ params = [ ] ) { $ urlParams = array_merge ( [ 'mode' => $ mode , 'apikey' => $ this -> apiKey , 'output' => 'json' ] , $ params ) ; return 'http://' . $ this -> url . ':' . $ this -> port . "/api?" . http_build_query ( $ urlParams ) ; }
Url builder helper
234,521
public function queue ( $ start = 0 , $ limit = 100 ) { $ url = $ this -> buildUrl ( 'queue' , [ 'start' => $ start , 'limit' => $ limit ] ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ 'queue' ] ; }
Returns all items currently in the queue and some additional information
234,522
public function history ( $ category = '' , $ start = 0 , $ limit = 100 , $ failedOnly = false ) { $ url = $ this -> buildUrl ( 'history' , [ 'start' => $ start , 'limit' => $ limit , 'failed_only' => $ failedOnly , 'category' => $ category ] ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_d...
Returns all items in the history and some additional information
234,523
public function deleteQueueEntries ( $ entries ) { $ url = $ this -> buildUrl ( 'queue' , [ 'name' => 'delete' , 'value' => implode ( ',' , $ entries ) ] ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ 'status' ] ; }
Deletes multiple entries with the given ids from the queue
234,524
public function switchQueueEntries ( $ first , $ second ) { $ url = $ this -> buildUrl ( 'switch' , [ 'value' => $ first , 'value2' => $ second ] ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ 'result' ] ; }
Switches two entries in the queue
234,525
public function pauseQueue ( ) { $ url = $ this -> buildUrl ( 'set_pause' ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ 'status' ] ; }
Pauses the whole queue
234,526
public function pauseQueueTemporary ( $ time ) { $ url = $ this -> buildUrl ( 'config' , [ 'name' => 'set_pause' , 'value' => $ time ] ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ 'status' ] ; }
Pauses the queue temporarely for the given amount of time .
234,527
public function addUrl ( $ url , $ niceName = null , $ priority = - 100 , $ category = '' , $ postProcessing = 3 , $ script = '' ) { $ params = [ 'name' => $ url , 'priority' => $ priority , 'category' => $ category , 'pp' => $ postProcessing , 'script' => $ script ] ; if ( $ niceName ) { $ params [ 'nzbname' ] = $ nic...
Adds a file to the queue via the given link to the file
234,528
public function deleteHistoryEntries ( $ ids , $ withFiles = true ) { $ params = [ 'name' => 'delete' , 'del_files' => $ withFiles , 'value' => implode ( ',' , $ ids ) ] ; $ url = $ this -> buildUrl ( 'history' , $ params ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> ...
Deletes the history entry with the given id
234,529
public function deleteAllHistoryEntries ( $ withFiles = true ) { $ params = [ 'name' => 'delete' , 'del_files' => $ withFiles , 'value' => 'all' ] ; $ url = $ this -> buildUrl ( 'history' , $ params ) ; $ request = $ this -> guzzle -> request ( 'GET' , $ url ) ; return json_decode ( $ request -> getBody ( ) , true ) [ ...
Deletes all history entries
234,530
public function getLocaleNativeAttribute ( ) { $ locale = $ this -> getAttributeFromArray ( 'locale' ) ; try { return localization ( ) -> getSupportedLocales ( ) -> get ( $ locale ) -> native ( ) ; } catch ( \ Exception $ e ) { return strtoupper ( $ locale ) ; } }
Get the locale s native name .
234,531
public function runningInStrictMode ( ) : bool { $ strictMode = true ; $ settings = $ this -> getSettings ( ) ; if ( is_array ( $ settings ) && ! empty ( $ settings ) ) { $ mode = $ settings [ 'mode' ] ; if ( $ mode != self :: STRICT_MODE ) { $ strictMode = false ; } } return $ strictMode ; }
Checks if T3v DataMapper is running in strict mode .
234,532
public function runningInFallbackMode ( ) : bool { $ fallbackMode = false ; $ settings = $ this -> getSettings ( ) ; if ( is_array ( $ settings ) && ! empty ( $ settings ) ) { $ mode = $ settings [ 'mode' ] ; if ( $ mode === self :: FALLBACK_MODE ) { $ fallbackMode = true ; } } return $ fallbackMode ; }
Checks if T3v DataMapper is running in fallback mode .
234,533
protected function __initInputValidate ( array & $ data ) { if ( ! is_array ( $ data ) ) { throw \ Exception ( "Entity\Base expects a array for it's first argument" ) ; } switch ( static :: $ inputValidate ) { case self :: VALIDATE_DISABLE : break ; case self :: VALIDATE_STRIP : $ data = \ array_intersect_key ( $ data ...
Constructor input validation . External to the constructor so that the constructor may itself be overloaded more easily .
234,534
public function copy ( $ deep = false ) { $ data = $ this -> data ; foreach ( static :: $ keyProperties as $ key ) { $ data [ $ key ] = null ; } foreach ( $ data as $ key => $ value ) { if ( is_object ( $ value ) and ! ( $ value instanceof self ) ) { $ data [ $ key ] = clone $ value ; } } try { if ( $ repository = $ th...
Make a shallow copy of a object clearing it s key fields
234,535
public function markDeleted ( ) { try { if ( $ repository = $ this -> r ( ) ) { $ repository -> detach ( $ this ) ; } } catch ( EntityMissingEntityManagerException $ e ) { } $ this -> checksum = null ; return $ this ; }
Mark a entity as deleted
234,536
public function markPersisted ( ) { try { if ( $ repository = $ this -> r ( ) ) { $ repository -> isNew ( $ this , false ) ; } } catch ( EntityMissingEntityManagerException $ e ) { } $ this -> checksumReset ( ) ; $ this -> clearDataInitialStore ( ) ; return $ this ; }
Mark a entity as persisted
234,537
public function uidGet ( ) { if ( isset ( $ this -> uid ) ) { return $ this -> uid -> key ; } elseif ( $ key = $ this -> keyGet ( $ this ) ) { return $ key ; } $ this -> uid = new Uid ( $ this ) ; return $ this -> uid -> key ; }
Get a uid for a object . This uid has the following properties .
234,538
protected function readOnlySafetyCheck ( ) { switch ( static :: $ isReadOnly ) { case self :: FULL_ACCESS : return false ; case self :: READONLY_DISABLE : return true ; case self :: READONLY_EXCEPTION : throw new ReadonlyException ( "Entity is readonly" ) ; case self :: READONLY_ON_PERSIST : if ( $ this -> isNew ( ) !=...
Is this object readonly?
234,539
public function initalPropertySet ( $ key , $ value ) { if ( is_array ( $ this -> dataInitial ) and $ repository = $ this -> r ( ) and in_array ( $ key , $ repository -> initialProperties ) ) { $ initialValue = $ this -> get ( $ key , self :: READONLY_EXCEPTION , $ source = self :: DATA ) ; if ( $ initialValue !== $ va...
InitialPropertiesSet helper method
234,540
public static function keyGet ( $ data ) { $ class = get_called_class ( ) ; if ( $ data instanceof $ class ) { $ keys = array ( ) ; foreach ( static :: $ keyProperties as $ property ) { $ value = $ data -> get ( $ property ) ; if ( $ value instanceof Base ) { $ value = call_user_func ( array ( get_class ( $ value ) , '...
Key entity key
234,541
public function canValidateProperty ( $ key ) { return isset ( $ this -> data [ $ key ] ) and is_object ( $ this -> data [ $ key ] ) and $ this -> data [ $ key ] instanceof Base ; }
Has validation property?
234,542
private function filterSpecialCharacters ( $ string ) { $ string = str_replace ( '<' , ' <' , $ string ) ; $ string = strip_tags ( $ string ) ; $ string = trim ( $ string ) ; $ string = iconv ( 'UTF-8' , 'ASCII//TRANSLIT//IGNORE' , $ string ) ; $ string = str_replace ( array ( '+' , '=' , '!' , ',' , '.' , ';' , ':' , ...
Filter out all special characters like punctuation and characters with accents
234,543
public function fetchAll ( $ params = [ ] ) { return $ this -> table -> select ( function ( Select $ select ) { $ select -> columns ( [ ] ) ; $ select -> join ( $ this -> roleTableName , sprintf ( '%s.role_id=%s.role_id' , $ this -> roleTableName , $ this -> table -> getTable ( ) ) ) ; $ select -> where ( [ 'user_id' =...
Fetch all or a subset of resources
234,544
private function addCurrencySymbol ( string $ value , ? string $ currency = null ) : string { $ currency = $ currency ?? $ this -> defaultCurrency ; $ locale = \ Locale :: getDefault ( ) ; if ( ! isset ( self :: $ patterns [ $ locale ] ) ) { self :: $ patterns [ $ locale ] = [ ] ; } if ( ! isset ( self :: $ patterns [ ...
Adds the currency symbol when missing .
234,545
private function removeCurrencySymbol ( string $ value , string $ currency ) : string { $ locale = \ Locale :: getDefault ( ) ; if ( ! isset ( self :: $ patterns [ $ locale ] [ $ currency ] ) ) { $ this -> addCurrencySymbol ( '123' , $ currency ) ; } return preg_replace ( '#(\s?' . preg_quote ( self :: $ patterns [ $ l...
Removes the currency symbol .
234,546
public function getFirst ( $ sql = null ) { if ( $ sql ) { $ this -> setLastQuery ( $ sql ) ; try { $ result = $ this -> db -> query ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new DatabaseException ( $ e -> getMessage ( ) . '<br>' . $ this -> getLastQuery ( ) [ 0 ] ) ; } $ data = $ this -> fetchAssoc ( $ result...
Return the first the matching row
234,547
public function getById ( $ id ) { $ sql = "SELECT * FROM " . $ this -> getTable ( ) . " WHERE " . $ this -> getPrimaryKey ( ) . " = " . intval ( $ id ) . ";" ; try { $ result = $ this -> db -> query ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new DatabaseException ( $ e -> getMessage ( ) . '<br>' . $ sql ) ; } ...
Select a row by id from this table
234,548
public function setConnectionInfo ( array $ connections ) { foreach ( $ connections as $ connectionInfo ) { if ( empty ( $ connectionInfo [ 'hostname' ] ) ) $ connectionInfo [ 'hostname' ] = 'localhost' ; if ( empty ( $ connectionInfo [ 'port' ] ) ) $ connectionInfo [ 'port' ] = 3306 ; if ( empty ( $ connectionInfo [ '...
Validates required values are present for a database connection .
234,549
public function getConnection ( ) { if ( empty ( $ this -> connection ) ) { if ( empty ( $ this -> connectionConfig ) || ! is_array ( $ this -> connectionConfig ) ) throw new DatabaseException ( "Connection config is empty or not an array." ) ; $ connCount = count ( $ this -> connectionConfig ) ; for ( $ i = 0 ; $ i < ...
Gets the current PDO connection object
234,550
public function readField ( $ sql ) { $ result = $ this -> read ( $ sql ) ; $ result -> setFetchMode ( PDO :: FETCH_COLUMN , 0 ) ; $ row = $ result -> fetch ( ) ; unset ( $ result ) ; return $ row ; }
Returns the first column of the first row of the result set
234,551
public function readCol ( $ sql ) { $ result = $ this -> read ( $ sql ) ; $ row = $ result -> fetchAll ( PDO :: FETCH_COLUMN , 0 ) ; unset ( $ result ) ; return $ row ; }
Returns an array of values for the first column of the result set
234,552
public function readOne ( $ sql ) { $ result = $ this -> readAll ( $ sql , false ) ; if ( count ( $ result ) > 0 ) { return $ result [ 0 ] ; } }
Returns the first row of the result set as an associative array regardless of the overall number of rows
234,553
public function readAll ( $ sql , $ calcFoundRows = false ) { $ result = $ this -> read ( $ calcFoundRows ? $ this -> insertPagingFlag ( $ sql ) : $ sql ) ; $ rows = $ result -> fetchAll ( PDO :: FETCH_ASSOC ) ; unset ( $ result ) ; unset ( $ sql ) ; return $ rows ; }
Returns an associative array of rows and columns
234,554
public function bulkInsertRecords ( $ tablename , $ parameters , $ limit = 25 ) { if ( empty ( $ parameters ) ) throw new DatabaseException ( 'bulkInsertRecords: no parameters.' ) ; $ count = 0 ; $ tcount = 0 ; $ totalcount = count ( $ parameters ) ; foreach ( $ parameters as $ value ) { if ( ! is_array ( $ value ) ) t...
Inserts multiple records utilizing less INSERT statements .
234,555
public function insertRecord ( $ tablename , $ parameters , $ ignore = false ) { if ( empty ( $ parameters ) ) throw new DatabaseException ( 'insertRecord: no parameters.' ) ; $ insert_fields = array ( ) ; $ insert_values = array ( ) ; foreach ( $ parameters as $ name => $ value ) { $ insert_fields [ ] = $ name ; $ ins...
Provides a convenience method for inserting an single row of columns and values into a database table
234,556
public function updateRecord ( $ tablename , $ parameters , $ where ) { $ update = array ( ) ; foreach ( $ parameters as $ name => $ value ) { $ update [ ] = "$name = " . $ this -> quote ( $ value ) . "" ; } $ sql = "UPDATE " . $ tablename . " SET " . implode ( "," , $ update ) . " WHERE " . $ where ; return $ this -> ...
Provides convenience method for updating columns on a table for 1 or many records matching a WHERE clause
234,557
public function deleteRecord ( $ tablename , $ where ) { if ( ! empty ( $ tablename ) && ! empty ( $ where ) ) { $ sql = "DELETE FROM " . $ tablename . " WHERE " . $ where ; return $ this -> write ( $ sql , DatabaseInterface :: AFFECTED_ROWS ) ; } }
Provides convenience method for deleting records matching a WHERE clause
234,558
public function quote ( $ var ) { if ( is_null ( $ var ) || strtoupper ( $ var ) == 'NULL' ) return 'NULL' ; if ( $ var instanceof Date ) $ var = $ this -> DateFactory -> toStorageDate ( $ var ) -> toMySQLDate ( ) ; return $ this -> getConnection ( ) -> quote ( $ var ) ; }
Returns escaped value automatically wrapped in single quotes
234,559
public function read ( $ sql ) { $ sql = ( string ) $ sql ; $ conn = $ this -> getConnection ( ) ; $ this -> Benchmark -> start ( 'sql-query' ) ; try { $ result = $ conn -> query ( $ sql ) ; } catch ( PDOException $ pe ) { $ errorMessage = $ pe -> getMessage ( ) ; $ this -> Logger -> debug ( array ( 'Conn' => $ this ->...
Runs the SQL query in read - only mode from the database
234,560
public function import ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new Exception ( "File not found: $filename" ) ; } $ sql_queries = file_get_contents ( $ filename ) ; $ sql_queries = $ this -> _removeRemarks ( $ sql_queries ) ; $ sql_queries = StringUtils :: smartSplit ( $ sql_queries , ";" , "'" , "\...
Imports and runs sql contained in the specified file . The file must contain only valid sql .
234,561
private function _removeRemarks ( $ sql ) { $ sql = preg_replace ( '/\n{2,}/' , "\n" , preg_replace ( '/^[-].*$/m' , "\n" , $ sql ) ) ; $ sql = preg_replace ( '/\n{2,}/' , "\n" , preg_replace ( '/^#.*$/m' , "\n" , $ sql ) ) ; return $ sql ; }
remove_remarks will strip the sql comment lines out of an uploaded sql file
234,562
public function identifyEntity ( ModelInterface $ model , & $ entity , $ identifier ) { $ primaryKeys = $ model -> primaryFields ( ) ; if ( count ( $ primaryKeys ) !== 1 ) { return ; } $ field = reset ( $ primaryKeys ) -> name ( ) ; $ this -> setPropertyValue ( $ entity , $ field , $ identifier ) ; }
Assigns passed identifier to primary key Possible only when entity has one primary key
234,563
public function getPropertyValue ( $ entity , $ field , $ default = null ) { $ this -> assertEntity ( $ entity ) ; if ( is_array ( $ entity ) || $ entity instanceof \ ArrayAccess ) { return isset ( $ entity [ $ field ] ) ? $ entity [ $ field ] : $ default ; } $ ref = $ this -> getReflection ( $ entity ) ; if ( ! $ ref ...
Returns property value
234,564
public function setPropertyValue ( & $ entity , $ field , $ value ) { $ this -> assertEntity ( $ entity ) ; if ( is_array ( $ entity ) || $ entity instanceof \ ArrayAccess ) { $ entity [ $ field ] = $ value ; return ; } $ ref = $ this -> getReflection ( $ entity ) ; if ( ! $ ref -> hasProperty ( $ field ) ) { $ entity ...
Sets property value
234,565
private function getReflection ( $ object ) { $ key = get_class ( $ object ) ; if ( ! array_key_exists ( $ key , $ this -> buffer ) ) { $ this -> buffer [ $ key ] = new \ ReflectionClass ( $ object ) ; } return $ this -> buffer [ $ key ] ; }
Returns object reflection instance
234,566
private function getProperty ( \ ReflectionClass $ ref , $ property ) { $ prop = $ ref -> getProperty ( $ property ) ; $ prop -> setAccessible ( true ) ; return $ prop ; }
Returns object property instance
234,567
public function addPropertyValue ( & $ entity , $ field , $ value ) { $ container = $ this -> getPropertyValue ( $ entity , $ field , $ entity ) ; if ( ! is_array ( $ container ) ) { $ container = empty ( $ container ) ? [ ] : [ $ container ] ; } $ container [ ] = $ value ; $ this -> setPropertyValue ( $ entity , $ fie...
Adds value to array property If property is not an array - will be converted into one preserving existing value as first element
234,568
public function getTableAlias ( $ table_name = null ) { if ( ! $ table_name ) { $ table_name = $ this -> getTableName ( ) ; } $ bits = explode ( "_" , $ table_name ) ; $ alias = '' ; foreach ( $ bits as $ bit ) { $ alias .= strtolower ( substr ( $ bit , 0 , 1 ) ) ; } return $ alias ; }
Get the short alias name of a table .
234,569
public function getTablePrimaryKey ( ) { trigger_error ( 'getTablePrimaryKey() is deprecated. Use getIDField() instead.' , E_USER_DEPRECATED ) ; $ keys = $ this -> getPrimaryKeyIndex ( ) ; return isset ( $ keys [ 0 ] ) ? $ keys [ 0 ] : false ; }
Get table primary key column name
234,570
public function getPrimaryKeyIndex ( ) { $ database = DatabaseLayer :: getInstance ( ) ; $ columns = array ( ) ; if ( $ this instanceof VersionedActiveRecord ) { $ schema = $ this -> getClassSchema ( ) ; $ firstColumn = reset ( $ schema ) [ 'name' ] ; $ columns = [ $ firstColumn => $ firstColumn , "sequence" => "sequen...
Get a unique key to use as an index
234,571
public function getId ( ) { $ col = $ this -> getIDField ( ) ; if ( property_exists ( $ this , $ col ) ) { $ id = $ this -> $ col ; if ( $ id > 0 ) { return $ id ; } } return false ; }
Get object ID
234,572
public function getLabel ( ) { if ( property_exists ( $ this , '_label_column' ) ) { if ( property_exists ( $ this , $ this -> _label_column ) ) { $ label_column = $ this -> _label_column ; return $ this -> $ label_column ; } } if ( property_exists ( $ this , 'name' ) ) { return $ this -> name ; } if ( property_exists ...
Get a label for the object . Perhaps a Name or Description field .
234,573
public function __calculateSaveDownRows ( ) { if ( ! $ this -> _columns ) { foreach ( get_object_vars ( $ this ) as $ potential_column => $ discard ) { switch ( $ potential_column ) { case 'table' : case substr ( $ potential_column , 0 , 1 ) == "_" : break ; default : $ this -> _columns [ ] = $ potential_column ; break...
Work out which columns should be saved down .
234,574
public function save ( $ automatic_reload = true ) { $ this -> preSave ( ) ; $ this -> __fieldFix ( ) ; $ this -> __calculateSaveDownRows ( ) ; $ primary_key_column = $ this -> getIDField ( ) ; $ data = array ( ) ; foreach ( $ this -> _columns as $ column ) { if ( $ column != $ primary_key_column || $ this instanceof V...
Save the selected record . This will do an INSERT or UPDATE as appropriate
234,575
public function reload ( ) { $ item = $ this -> getById ( $ this -> getId ( ) ) ; if ( $ item !== false ) { $ this -> loadFromRow ( $ item ) ; return $ this ; } else { return false ; } }
Reload the selected record
234,576
public function delete ( ) { $ database = DatabaseLayer :: getInstance ( ) ; $ delete = $ database -> delete ( $ this -> getTableName ( ) , $ this -> getTableAlias ( ) ) ; $ delete -> setModel ( $ this ) ; $ delete -> condition ( $ this -> getIDField ( ) , $ this -> getId ( ) ) ; $ delete -> execute ( $ this -> getClas...
Delete the selected record
234,577
public static function getBySlug ( $ slug ) { $ slug_parts = explode ( "-" , $ slug , 2 ) ; $ class = get_called_class ( ) ; $ temp_this = new $ class ( ) ; $ primary_key = $ temp_this -> getIDField ( ) ; return self :: search ( ) -> where ( $ primary_key , $ slug_parts [ 0 ] ) -> execOne ( ) ; }
Pull a database record by the slug we re given .
234,578
public function __fieldFix ( ) { $ schema = $ this -> getClassSchema ( ) ; foreach ( $ this -> __calculateSaveDownRows ( ) as $ column ) { if ( ! isset ( $ schema [ $ column ] [ 'type' ] ) ) { throw new Exception ( "No type hinting/docblock found for '{$column}' in '" . get_called_class ( ) . "'." , E_USER_WARNING ) ; ...
Fix types of fields to match definition
234,579
protected function respondNotFound ( $ message = '' ) { if ( empty ( $ message ) ) { $ message = ucfirst ( $ this -> baseClass ) . ' does not exist' ; } return $ this -> respondWithError ( $ message , 404 ) ; }
Respond with an error in case the resource request is not found
234,580
public function loadMessages ( $ className ) { $ map = [ ] ; if ( class_exists ( $ className ) ) { $ class = new \ ReflectionClass ( $ className ) ; $ file = $ class -> getFileName ( ) ; $ nfile = substr_replace ( $ file , '.' . $ this -> language . '.php' , - 4 ) ; if ( file_exists ( $ nfile ) ) { $ res = include $ nf...
Load language file from the same directory of message class .
234,581
public function setNewValue ( $ attribute , $ value ) { $ this -> assertValidAttribute ( $ attribute ) ; $ this -> documentChangeSet [ $ attribute ] [ 1 ] = $ value ; $ this -> getDocumentManager ( ) -> getUnitOfWork ( ) -> setDocumentChangeSet ( $ this -> getDocument ( ) , $ this -> documentChangeSet ) ; }
Sets the new value of this attribute .
234,582
private function assertValidAttribute ( $ attribute ) { if ( ! isset ( $ this -> documentChangeSet [ $ attribute ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Attribute "%s" is not a valid attribute of the document "%s" in PreUpdateEventArgs.' , $ attribute , get_class ( $ this -> getDocument ( ) ) ) ) ; } ...
Asserts the attribute exists in changeset .
234,583
final public function getPathInfo ( $ path , $ use_include_path = false ) { if ( $ use_include_path ) { $ path = stream_resolve_include_path ( $ path ) ; } else { $ path = realpath ( $ path ) ; } if ( is_string ( $ path ) ) { list ( $ this -> dirname , $ this -> basename , $ this -> extension , $ this -> filename ) = a...
Retrieves information about path components
234,584
public function onEvent ( Event $ event ) : void { if ( ! $ event instanceof GetResponseEvent || ! $ this -> injected ) { if ( null !== ( $ filter = $ this -> getFilter ( ) ) ) { $ this -> injectParameters ( $ filter ) ; } } }
Action on the event .
234,585
protected function getFilter ( ) { $ supports = $ this -> supports ( ) ; $ filters = $ this -> entityManager -> getFilters ( ) -> getEnabledFilters ( ) ; $ fFilter = null ; foreach ( $ filters as $ name => $ filter ) { if ( $ filter instanceof $ supports ) { $ fFilter = $ filter ; break ; } } return $ fFilter ; }
Get the supported filter .
234,586
public function isMatch ( $ method , $ url ) { $ match = false ; if ( \ in_array ( $ method , $ this -> responds_to ) ) { \ preg_match ( $ this -> compile ( ) , $ url , $ matches ) ; if ( ! empty ( $ matches ) ) { $ this -> matched_params = \ array_merge ( $ this -> defaults , $ this -> method_defaults [ $ method ] , $...
Check to see if this route is a match .
234,587
public function url ( $ params = array ( ) ) { if ( $ this -> isStatic ( ) ) { return $ this -> pattern ; } $ url = $ this -> pattern ; foreach ( $ this -> getSegments ( $ url ) as $ segment ) { $ func = $ segment [ 'optional' ] === true ? 'replaceOptional' : 'replaceRequired' ; $ url = $ this -> { $ func } ( $ url , $...
A reverse routing helper .
234,588
protected function compile ( ) { if ( $ this -> compiled !== false ) { return $ this -> compiled ; } if ( $ this -> isStatic ( ) ) { $ this -> compiled = '~^' . $ this -> pattern . '$~' ; return $ this -> compiled ; } $ compiled = $ this -> pattern ; foreach ( $ this -> getSegments ( $ compiled ) as $ segment ) { $ com...
Compiles the pattern into one suitable for regex .
234,589
protected function getSegments ( $ pattern ) { $ segments = array ( ) ; $ parts = \ explode ( "/" , ltrim ( $ pattern , "/" ) ) ; foreach ( $ parts as $ segment ) { if ( \ strpos ( $ segment , ":" ) !== false ) { $ segments [ ] = $ this -> parseSegment ( $ segment ) ; } } return $ segments ; }
Gets an array of url segments
234,590
protected function parseSegment ( $ segment ) { $ optional = false ; list ( $ regex , $ name ) = \ explode ( ":" , $ segment ) ; if ( \ substr ( $ name , - 1 ) === "?" ) { $ name = \ substr ( $ name , 0 , - 1 ) ; $ optional = true ; } if ( $ regex === "" ) { $ regex = "[^\/]+" ; } $ regex = "/(?P<{$name}>{$regex})" ; i...
Pulls out relevent information on a given segment .
234,591
public function nodeRouteAction ( NodeRoute $ nodeRoute ) { if ( $ node = $ this -> get ( 'mm_cmf_routing.node_resolver' ) -> resolve ( $ nodeRoute ) ) { if ( $ nodeRoute instanceof RedirectNodeRoute ) { return $ this -> redirectAction ( $ nodeRoute ) ; } else { if ( $ nodeRoute -> getNode ( ) instanceof TemplatableNod...
process the the node route call
234,592
public static function genRandomStr ( $ l ) { $ p = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ s = '' ; for ( $ i = 0 ; $ i < $ l ; $ i ++ ) { $ s .= $ p [ mt_rand ( 0 , ( mb_strlen ( $ p ) - 1 ) ) ] ; } return $ s ; }
Generate a random string of letters and numbers of a specific length .
234,593
public static function uniqid ( $ length = false ) { if ( $ length <= 13 ) { return uniqid ( ) ; } $ uniq = strrev ( str_replace ( '.' , '' , uniqid ( '' , true ) ) ) ; $ uniqlen = mb_strlen ( $ uniq ) ; if ( $ length === false || $ length === $ uniqlen ) { return $ uniq ; } elseif ( $ length < $ uniqlen ) { return mb_...
Generate a guaranteed unique value of a specified length .
234,594
public function addPrefix ( $ prefix , $ baseDirs , $ prepend = FALSE ) { $ baseDirs = ( array ) $ baseDirs ; $ prefix = trim ( $ prefix , '\\' ) . '\\' ; if ( ! isset ( $ this -> prefixes [ $ prefix ] ) ) { $ this -> prefixes [ $ prefix ] = [ ] ; } foreach ( $ baseDirs as $ ndx => $ dir ) { $ baseDirs [ $ ndx ] = rtri...
add a base directory for a namespace prefix
234,595
public function setPrefixes ( array $ prefixes ) { $ this -> prefixes = [ ] ; foreach ( $ prefixes as $ prefix => $ baseDir ) { $ this -> addPrefix ( $ prefix , $ baseDir ) ; } }
set all namespace prefixes and their base directories ; overwrites existing prefixes
234,596
protected function loadFile ( $ prefix , $ relativeClass ) { if ( ! isset ( $ this -> prefixes [ $ prefix ] ) ) { $ this -> debug [ ] = $ prefix . ': no base dirs' ; return FALSE ; } foreach ( $ this -> prefixes [ $ prefix ] as $ baseDir ) { $ file = $ baseDir . str_replace ( '\\' , DIRECTORY_SEPARATOR , $ relativeClas...
loads mapped file for a namespace prefix and relative class
234,597
public function nodesFormAction ( Request $ request ) { $ node = new Node ( ) ; $ this -> currentNode = $ request -> get ( 'node' ) ; if ( $ this -> currentNode ) { $ node = $ this -> get ( "ydle.node.manager" ) -> find ( $ request -> get ( 'node' ) ) ; } $ action = $ this -> get ( 'router' ) -> generate ( 'submitNodeF...
Display a form to create or edit a node .
234,598
public function setObject ( $ object , $ throwExceptionOnFailure = true ) { if ( ! is_object ( $ object ) ) { throw new BadTaskException ( "A task must be object" ) ; return false ; } $ error = null ; if ( $ isCompatible = static :: isCompatible ( $ object , $ error ) ) { $ this -> object = $ object ; return true ; } i...
Set a task s object property
234,599
protected function getConfigInject ( $ type ) { switch ( strtolower ( $ type ) ) { case 'all' : case 'a' : return engineGet ( 'inject' , 'all' ) ; case 'controllers' : case 'controller' : case 'c' : return array_merge ( engineGet ( 'inject' , 'all' ) , engineGet ( 'inject' , 'controllers' ) ) ; case 'services' : case '...
Fetches classes to inject from the config file . If given type is not all the required is merged with the all