idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
42,100 | public function set ( $ key , $ value , $ ttl = 0 ) { if ( is_resource ( $ value ) ) { return false ; } $ used_key = $ this -> getUsedKey ( $ key ) ; $ res = $ this -> redis -> set ( $ used_key , $ this -> esc ( $ value ) ) ; if ( $ res !== 'OK' ) { return false ; } if ( $ ttl === 0 ) { return true ; } if ( $ ttl != 0 && $ ttl > 2592000 ) { $ ttl -= time ( ) ; } if ( $ ttl <= 0 ) { return true ; } return ( $ this -> redis -> expire ( $ used_key , $ ttl ) == 1 ) ; } | set a specific data in the cache |
42,101 | public function delete ( $ key ) { $ used_key = $ this -> getUsedKey ( $ key ) ; return ( $ this -> redis -> delete ( $ used_key ) > 0 ) ; } | delete a specific data in the cache |
42,102 | public function flush ( ) { if ( ! $ this -> key_prefix ) { return ( $ this -> redis -> flushdb ( ) == 'OK' ) ; } switch ( $ this -> key_prefix_flush_method ) { case 'direct' : $ this -> redis -> flushByPrefix ( $ this -> key_prefix ) ; return true ; case 'event' : jEvent :: notify ( 'jCacheRedisFlushKeyPrefix' , array ( 'prefix' => $ this -> key_prefix , 'profile' => $ this -> profileName ) ) ; return true ; case 'jcacheredisworker' : $ this -> redis -> rpush ( 'jcacheredisdelkeys' , $ this -> key_prefix ) ; return true ; } return false ; } | clear all data in the cache . |
42,103 | public function setWorklog ( $ date , $ ticket , $ timeSpent , $ comment = '' ) { $ this -> uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog" ; if ( is_numeric ( $ timeSpent ) ) { $ timeSpent .= 'h' ; } $ startedDate = $ this -> _formatTimestamp ( $ date ) ; $ data = [ 'timeSpent' => $ timeSpent , 'started' => $ startedDate , 'comment' => $ comment ] ; $ this -> output -> debug ( print_r ( $ data , true ) ) ; $ data = json_encode ( $ data ) ; $ response = $ this -> processRequest ( $ data ) ; $ this -> _handleError ( $ data , $ response ) ; return $ response ; } | Create worklog entry in Jira |
42,104 | protected function createUpgrade ( $ metaData ) { $ this -> ensureHomePath ( $ metaData ) ; if ( ! $ metaData -> has ( UpgradeTask :: SETTING_DATA_DIR ) ) { $ metaData -> set ( UpgradeTask :: SETTING_DATA_DIR , $ this -> home -> tensideDataDir ( ) ) ; } return new UpgradeTask ( $ metaData ) ; } | Create an upgrade task instance . |
42,105 | private function ensureHomePath ( JsonArray $ metaData ) { if ( $ metaData -> has ( AbstractPackageManipulatingTask :: SETTING_HOME ) ) { return ; } $ metaData -> set ( AbstractPackageManipulatingTask :: SETTING_HOME , $ this -> home -> homeDir ( ) ) ; } | Ensure the home path has been set in the passed meta data . |
42,106 | public function on ( $ type , $ callback ) { if ( ! isset ( $ this -> callbacks [ $ type ] ) ) { $ this -> callbacks [ $ type ] = [ ] ; } $ this -> callbacks [ $ type ] [ ] = $ callback ; return $ this ; } | Register event handler |
42,107 | public static function preSaveText ( $ text , $ controller , $ transTable = [ ] ) { $ module = Module :: getModuleByClassname ( Module :: className ( ) ) ; $ editorContentHelper = $ module -> contentHelper ; $ text = trim ( $ text ) ; if ( empty ( $ text ) ) return '' ; $ text = $ editorContentHelper :: afterSelectBody ( $ text ) ; $ text = strtr ( $ text , $ transTable ) ; $ html = $ text ; $ viewFile = dirname ( __DIR__ ) . '/views/news-archieve-text.php' ; if ( is_file ( $ viewFile ) ) { $ text = static :: START_TEXT_TAG . $ text . static :: END_TEXT_TAG ; $ html = Yii :: $ app -> view -> renderFile ( $ viewFile , [ 'text' => $ text ] , $ controller ) ; } return $ html ; } | Processing text before saving . |
42,108 | public static function getSlug ( $ model ) { $ i18nModels = $ model -> i18n ; $ slugs = [ ] ; foreach ( $ i18nModels as $ i18nModel ) { if ( empty ( $ i18nModel -> body ) ) continue ; $ slugs [ $ i18nModel -> lang_code ] = $ i18nModel -> slug ; } $ module = Module :: getModuleByClassname ( Module :: className ( ) ) ; $ langHelper = $ module -> langHelper ; $ langs = array_keys ( $ langHelper :: activeLanguages ( ) ) ; $ slug = '' ; foreach ( $ langs as $ lang ) { if ( ! empty ( $ slugs [ $ lang ] ) ) { $ slug = $ slugs [ $ lang ] ; break ; } } if ( strlen ( $ slug ) > static :: $ slugMaxLen ) { $ slug = substr ( $ slug , 0 , static :: $ slugMaxLen ) ; } $ slug = trim ( $ slug , '-' ) ; return $ slug ; } | Get first non - empty slug of news . Search in default languages priority . |
42,109 | public function contains ( $ key ) { if ( $ this -> inclusive && in_array ( $ key , array ( $ this -> min , $ this -> max ) ) ) { return true ; } return $ key > $ this -> min && $ key < $ this -> max ; } | Returns true if key is inside this range |
42,110 | public function setLinks ( ) { if ( $ this -> resource instanceof Collection && $ paginator = $ this -> resource -> getPaginator ( ) ) { $ pagination = new Pagination ( $ paginator ) ; $ this -> links = $ pagination -> generateCollectionLinks ( ) ; } else { unset ( $ this -> links ) ; } return $ this ; } | Set the response links data |
42,111 | public function setData ( ) { if ( $ this -> resource instanceof Collection ) { $ this -> data = [ ] ; foreach ( $ this -> resource -> getData ( ) as $ resource ) { $ this -> parseItem ( new Item ( $ resource , $ this -> resource -> getTransformer ( ) ) ) ; } } elseif ( $ this -> resource instanceof Item ) { $ this -> parseItem ( $ this -> resource ) ; } return $ this ; } | Creates the response |
42,112 | private function parseItem ( Item $ item ) { $ tmp = $ this -> getFormattedItem ( $ item ) ; $ relationships = $ this -> getRelationships ( $ item ) ; $ parseRelationships = function ( $ key , Item $ item , array $ relationships = [ ] ) { $ related = $ this -> getFormattedItem ( $ item ) ; if ( ! in_array ( $ related , $ this -> relationships ) ) { $ this -> relationships [ ] = $ related ; } unset ( $ related [ 'attributes' ] ) ; unset ( $ related [ 'links' ] ) ; $ relationships [ $ key ] [ 'data' ] [ ] = $ related ; return $ relationships ; } ; foreach ( $ relationships as $ key => $ value ) { if ( $ value instanceof Collection ) { foreach ( $ value -> getData ( ) as $ include_value ) { $ relationships = $ parseRelationships ( $ key , new Item ( $ include_value , $ value -> getTransformer ( ) ) , $ relationships ) ; } } else if ( $ value instanceof Item ) { $ relationships = $ parseRelationships ( $ key , $ value , $ relationships ) ; } } $ tmp [ 'relationships' ] = $ relationships ; if ( is_array ( $ this -> data ) ) { $ this -> data [ ] = $ tmp ; } else { $ this -> data = $ tmp ; } return $ this ; } | Parses an item into response data |
42,113 | private function getFormattedItem ( Item $ item ) { $ data = [ 'type' => $ this -> getFormattedName ( $ item -> getTransformer ( ) ) , 'id' => $ item -> getData ( ) -> id , 'attributes' => $ item -> sanitize ( ) , ] ; if ( $ links = $ item -> getLinks ( ) ) { $ data [ 'links' ] = $ links ; } return $ data ; } | Formats an item ready for response |
42,114 | private function getFormattedName ( $ class ) { $ class_name = ( substr ( strrchr ( get_class ( $ class ) , "\\" ) , 1 ) ) ; $ underscored = preg_replace ( '/([a-z])([A-Z])/' , '$1_$2' , $ class_name ) ; return strtolower ( $ underscored ) ; } | Formats a class name for readable use in the response |
42,115 | private function getRelationships ( Item $ item ) { if ( $ include_params = $ this -> resource -> getIncludeParams ( ) ) { $ item -> setIncludeParams ( $ include_params ) ; return $ item -> getIncluded ( ) ; } return [ ] ; } | Gets the related data for a resource item |
42,116 | public function setMeta ( ) { if ( $ meta = $ this -> resource -> getMeta ( ) ) { $ this -> meta = $ meta ; } else { unset ( $ this -> meta ) ; } return $ this ; } | Set the response meta data |
42,117 | public function setLinkFieldKey ( $ linkFieldKey ) { if ( ! is_string ( $ linkFieldKey ) ) { $ msg = "Link field key must be a string" ; throw new OpenStates_View_Exception ( $ msg ) ; } $ this -> linkFieldKey = $ linkFieldKey ; return $ this ; } | Set the link field key used by link pattern |
42,118 | public function setLabelPrefix ( $ labelPrefix ) { if ( ! is_string ( $ labelPrefix ) ) { $ msg = "Label prefix must be a string" ; throw new OpenStates_View_Exception ( $ msg ) ; } $ this -> labelPrefix = $ labelPrefix ; return $ this ; } | Set the common label prefix |
42,119 | private function loadFile ( string $ path ) { if ( ! file_exists ( $ path ) ) { throw new Exception ( 'Configuration file "' . $ path . '" is not found' ) ; } if ( ! is_readable ( $ path ) ) { throw new Exception ( 'Configuration file "' . $ path . '" is not readable' ) ; } $ content = include $ path ; if ( ! \ is_array ( $ content ) ) { throw new Exception ( "Passed file \"$path\" is not array" ) ; } return $ content ; } | Load parameters from filesystem |
42,120 | public function load ( string $ path , string $ key = null ) : ConfigInterface { try { $ parameters = $ this -> loadFile ( $ path ) ; if ( null !== $ key ) { $ parameters = [ $ key => $ parameters ] ; } $ this -> setter ( $ parameters ) ; } catch ( Exception $ e ) { } return $ this ; } | Load configuration file show config path if needed |
42,121 | private function setter ( array $ parameters ) { array_map ( function ( $ key , $ value ) { $ this -> set ( $ key , $ value ) ; } , array_keys ( $ parameters ) , $ parameters ) ; } | Put keys from array of parameters into internal array |
42,122 | public function set ( string $ key , $ value ) : ConfigInterface { $ this -> _config [ $ key ] = \ is_array ( $ value ) ? new Config ( $ value ) : $ value ; return $ this ; } | Set some parameter of configuration |
42,123 | public function get ( string $ key = null ) { $ result = ( null !== $ key ) ? $ this -> _config [ $ key ] ?? null : $ this -> _config ; return $ result ; } | Get single parameter by name or null or all available parameters |
42,124 | public function clean ( string $ key = null ) : ConfigInterface { if ( null !== $ key ) { unset ( $ this -> _config [ $ key ] ) ; } else { $ this -> _config = [ ] ; } return $ this ; } | Remove single value or clean config |
42,125 | protected function loadKey ( $ key ) { $ parts = explode ( '.' , $ key ) ; $ first = $ parts [ 0 ] ; if ( array_key_exists ( $ first , $ this -> items ) ) { return ; } if ( array_key_exists ( $ first , $ this -> finded ) ) { return ; } $ file = config_path ( sprintf ( '%s.php' , $ first ) ) ; if ( file_exists ( $ file ) ) { $ this -> set ( $ first , require $ file ) ; } $ this -> finded [ $ first ] = true ; } | Load key . |
42,126 | public function importContacts ( $ journal , $ journalId ) { $ this -> consoleOutput -> writeln ( "Importing journal's contacts..." ) ; $ settingsSql = "SELECT locale, setting_name, setting_value FROM journal_settings WHERE journal_id = :id" ; $ settingsStatement = $ this -> dbalConnection -> prepare ( $ settingsSql ) ; $ settingsStatement -> bindValue ( 'id' , $ journalId ) ; $ settingsStatement -> execute ( ) ; $ settings = array ( ) ; $ pkpSettings = $ settingsStatement -> fetchAll ( ) ; foreach ( $ pkpSettings as $ setting ) { $ name = $ setting [ 'setting_name' ] ; $ value = $ setting [ 'setting_value' ] ; $ settings [ $ name ] = $ value ; } $ contact = new JournalContact ( ) ; $ contact -> setFullName ( $ settings [ 'contactName' ] ) ; $ contact -> setEmail ( $ settings [ 'contactEmail' ] ) ; $ contact -> setPhone ( $ settings [ 'contactPhone' ] ) ; $ contact -> setAddress ( $ settings [ 'contactMailingAddress' ] ) ; $ types = $ this -> em -> getRepository ( 'VipaJournalBundle:ContactTypes' ) -> findAll ( ) ; ! empty ( $ types ) && $ contact -> setContactType ( $ types [ 0 ] ) ; $ journal -> addJournalContact ( $ contact ) ; } | Imports contacts of the given journal . |
42,127 | public function setViewParams ( $ view ) { foreach ( $ this -> url as $ url ) { if ( isset ( $ view -> params [ 'urls' ] ) && is_array ( $ view -> params [ 'urls' ] ) ) { $ view -> params [ 'urls' ] = $ this -> MenuMerge ( $ view -> params [ 'urls' ] , $ url ) ; } else { $ view -> params [ 'urls' ] = $ url ; } } if ( $ module = $ this -> getModule ( ) ) { $ view -> params [ 'urls' ] [ $ module ] [ 'active' ] = true ; } } | Registers url params on given View |
42,128 | public function getObjectChangeSet ( $ uow , $ object ) { $ changeSet = parent :: getObjectChangeSet ( $ uow , $ object ) ; $ meta = $ this -> getObjectManager ( ) -> getClassMetadata ( get_class ( $ object ) ) ; $ refl = $ meta -> getReflectionClass ( ) ; $ updates = $ uow -> getScheduledCollectionUpdates ( ) ; $ delitions = $ uow -> getScheduledCollectionDeletions ( ) ; foreach ( $ meta -> getAssociationNames ( ) as $ name ) { if ( $ meta -> isSingleValuedAssociation ( $ name ) ) { continue ; } $ property = $ refl -> getProperty ( $ name ) ; $ property -> setAccessible ( true ) ; $ assoc = $ property -> getValue ( $ object ) ; if ( in_array ( $ assoc , $ updates , true ) || in_array ( $ assoc , $ delitions , true ) ) { $ changeSet [ $ name ] = [ $ assoc , $ assoc ] ; } } return $ changeSet ; } | Overriden . Added support for ManyToMany association changes |
42,129 | public static function css ( $ files , $ nest = true ) { if ( is_array ( $ files ) ) { foreach ( $ files as $ file ) { self :: cssCall ( $ file , $ nest ) ; } } elseif ( is_string ( $ files ) ) { self :: cssCall ( $ files , $ nest ) ; } } | Call CSS files . |
42,130 | public static function cssCall ( $ file , $ nest ) { if ( strpos ( $ file , 'http://' ) !== false ) { $ path = $ file . '.css' ; } else { if ( $ nest ) { $ file = str_replace ( '.' , '/' , $ file ) ; $ path = path ( ) . 'assets/css/' . $ file . '.css' ; } else { $ path = $ file ; } } self :: cssTag ( $ path ) ; } | The process to CSS HTML Tag . |
42,131 | public static function js ( $ files , $ nest = true ) { if ( is_array ( $ files ) ) { foreach ( $ files as $ file ) { self :: jsCall ( $ file , $ nest ) ; } } elseif ( is_string ( $ files ) ) { self :: jsCall ( $ files , $ nest ) ; } } | Call JS files . |
42,132 | public static function jsCall ( $ file , $ nest ) { if ( strpos ( $ file , 'http://' ) !== false ) { $ path = $ file . '.js' ; } else { if ( $ nest ) { $ file = str_replace ( '.' , '/' , $ file ) ; $ path = path ( ) . 'assets/js/' . $ file . '.js' ; } else { $ path = $ file ; } } self :: jsTag ( $ path ) ; } | The process to JS HTML Tag . |
42,133 | public function defaultConfig ( $ name ) { $ config = $ this -> config ( ) ; $ default = array_key_exists ( 'default' , $ config ) ? $ config [ 'default' ] : array ( ) ; if ( ! array_key_exists ( $ name , $ default ) ) { return array ( ) ; } return $ default [ $ name ] ; } | Get default value for given attribute |
42,134 | public function lazySet ( array $ sets ) { $ config = $ this -> config ( ) ; if ( ! array_key_exists ( 'lazy-set' , $ config ) || ! is_array ( $ config [ 'lazy-set' ] ) ) { throw new \ Exception ( 'Config with key "lazy-set" does not exist or incorrect data type given in ' . __NAMESPACE__ ) ; } $ lazySetConfig = $ config [ 'lazy-set' ] ; foreach ( $ sets as $ set ) { if ( ! array_key_exists ( $ set , $ lazySetConfig ) ) { throw new \ Exception ( '"lazy-set" with name "' . $ set . '" does not exist in ' . __NAMESPACE__ ) ; } } $ lazySets = array ( ) ; foreach ( $ sets as $ setIdentifier ) { $ lazySet = $ lazySetConfig [ $ setIdentifier ] ; foreach ( $ lazySet as $ type => $ set ) { if ( ! is_array ( $ set ) ) { $ lazySet [ $ type ] = $ set ; continue ; } foreach ( $ set as $ index => $ attribute ) { $ deepArray = ! in_array ( $ type , $ this -> deepArrayFalse ) ; $ value = $ this -> configParser ( $ type , $ attribute ) ; if ( empty ( $ value ) ) { $ value = array ( ) ; } if ( $ deepArray ) { $ lazySet [ $ type ] [ $ index ] = $ value ; } else { $ lazySet [ $ type ] = $ value ; } } } $ lazySets = array_merge_recursive ( $ lazySet , $ lazySets ) ; } return $ lazySets ; } | Convert lazy - set format to zend - form compatible array format |
42,135 | private function closeFile ( ) { $ this -> filename = NULL ; if ( $ this -> fh !== NULL && $ this -> fh !== FALSE ) { $ rc = fclose ( $ this -> fh ) ; return $ rc ; } else { return TRUE ; } } | Closes the current file handle |
42,136 | public function dn_ ( $ domain , $ singular , $ plural , $ count ) { return $ this -> dngettext ( $ domain , $ singular , $ plural , $ count ) ; } | Plural version of d_ . Some languages have more than one form for plural messages dependent on the count . |
42,137 | public function dnp_ ( $ domain , $ context , $ singular , $ plural , $ count ) { return $ this -> dnpgettext ( $ domain , $ context , $ singular , $ plural , $ count ) ; } | Plural version of dp_ . Some languages have more than one form for plural messages dependent on the count . |
42,138 | public function np_ ( $ context , $ singular , $ plural , $ count ) { return $ this -> npgettext ( $ context , $ singular , $ plural , $ count ) ; } | Plural version of p_ . Some languages have more than one form for plural messages dependent on the count . |
42,139 | public function find ( $ column , $ value ) { return $ this -> getFirst ( ( is_null ( $ column ) ? $ this -> key : $ column ) . ' = ?' , [ $ value ] ) ; } | Find and return first entry by key . |
42,140 | public function getFirst ( $ conditions = null , $ values = [ ] , $ options = [ ] ) { return $ this -> processSingleResult ( $ this -> executeQuery ( null , $ conditions , $ values , $ options ) ) ; } | Retrieve first entry optionally filtered by search criteria . |
42,141 | public function getAll ( $ conditions = null , $ values = [ ] , $ options = [ ] ) { return $ this -> processMultipleResults ( $ this -> executeQuery ( null , $ conditions , $ values , $ options ) ) ; } | Retrieve all entries optionally filtered by search criteria . |
42,142 | public function save ( $ model ) { if ( isset ( $ model -> { $ this -> key } ) ) { return $ this -> update ( $ model ) ; } return $ this -> create ( $ model ) ; } | Save entry by inserting if ID is missing and updating if ID exists . |
42,143 | public function delete ( $ model ) { $ this -> db -> connect ( ) -> deleteFrom ( $ this -> table ) -> where ( $ this -> key . ' = ?' ) -> execute ( [ $ model -> { $ this -> key } ] ) ; $ model -> { $ this -> key } = null ; } | Delete entry . |
42,144 | public function count ( $ conditions = null , $ values = [ ] ) { $ res = $ this -> executeQuery ( 'COUNT(' . $ this -> key . ') AS num' , $ conditions , $ values ) -> fetch ( ) ; return ( isset ( $ res -> num ) ? ( int ) $ res -> num : 0 ) ; } | Count entries optionally filtered by search criteria . |
42,145 | protected function executeQuery ( $ select = null , $ conditions = null , $ values = [ ] , $ options = [ ] ) { $ query = $ this -> db -> connect ( ) ; if ( ! empty ( $ this -> fetchRefs ) ) { $ query = $ this -> setupJoin ( $ query , $ select , $ conditions , ( isset ( $ options [ 'order' ] ) ? $ options [ 'order' ] : null ) ) ; } else { $ query = ( ! is_null ( $ select ) ? $ query -> select ( $ select ) : $ query -> select ( ) ) ; $ query = $ query -> from ( $ this -> table ) ; if ( ! is_null ( $ conditions ) ) { $ query = $ query -> where ( $ conditions ) ; } if ( isset ( $ options [ 'order' ] ) ) { $ query = $ query -> orderBy ( $ options [ 'order' ] ) ; } } if ( isset ( $ options [ 'limit' ] ) ) { $ query = $ query -> limit ( $ options [ 'limit' ] ) ; } if ( isset ( $ options [ 'offset' ] ) ) { $ query = $ query -> offset ( $ options [ 'offset' ] ) ; } return $ query -> execute ( $ values ) ; } | Execute query for selection methods . |
42,146 | protected function populateModelFromJoin ( $ result ) { $ model = new $ this -> modelClass ( ) ; foreach ( array_keys ( get_object_vars ( $ model ) ) as $ attr ) { $ model -> $ attr = $ result -> $ attr ; } $ refs = $ model -> getReferences ( ) ; $ refs2 = ( is_array ( $ this -> fetchRefs ) ? $ this -> fetchRefs : array_keys ( $ refs ) ) ; sort ( $ refs2 ) ; foreach ( $ refs2 as $ idx => $ name ) { $ prefix = "REF{$idx}_{$name}__" ; if ( is_null ( $ result -> { $ prefix . $ refs [ $ name ] [ 'key' ] } ) ) { $ refModel = null ; } else { $ refModel = new $ refs [ $ name ] [ 'model' ] ( ) ; foreach ( array_keys ( get_object_vars ( $ refModel ) ) as $ attr ) { $ refModel -> $ attr = $ result -> { $ prefix . $ attr } ; } } if ( $ refModel && $ this -> manager ) { $ this -> manager -> manageModel ( $ refModel ) ; } $ model -> $ name = $ refModel ; } return $ model ; } | Populate model instance including retrieved references from join query result . |
42,147 | protected function processSingleResult ( $ query ) { if ( ! empty ( $ this -> fetchRefs ) ) { $ res = $ query -> fetch ( ) ; $ model = ( $ res ? $ this -> populateModelFromJoin ( $ res ) : $ res ) ; } else { $ model = $ query -> fetchClass ( $ this -> modelClass ) ; } if ( $ model && isset ( $ this -> manager ) ) { $ this -> manager -> manageModel ( $ model ) ; } $ this -> fetchReferences ( false ) ; return $ model ; } | Process single query result and return model instance . |
42,148 | protected function processMultipleResults ( $ query ) { if ( ! empty ( $ this -> fetchRefs ) ) { $ models = [ ] ; foreach ( $ query -> fetchAll ( ) as $ model ) { $ models [ ] = $ this -> populateModelFromJoin ( $ model ) ; } } else { $ models = $ query -> fetchAllClass ( $ this -> modelClass ) ; } if ( isset ( $ this -> manager ) ) { foreach ( $ models as $ model ) { $ this -> manager -> manageModel ( $ model ) ; } } $ this -> fetchReferences ( false ) ; return $ models ; } | Process multiple query results and return model instances . |
42,149 | private function setupJoin ( $ query , $ select , $ conditions , $ order = null ) { $ model = new $ this -> modelClass ( ) ; $ refs = $ model -> getReferences ( ) ; if ( is_array ( $ this -> fetchRefs ) ) { $ refs = array_intersect_key ( $ refs , array_flip ( $ this -> fetchRefs ) ) ; } ksort ( $ refs ) ; if ( ! is_null ( $ select ) ) { $ select = $ this -> prefixModelAttributes ( $ select , $ model ) ; } else { $ select = $ this -> table . '.*' ; } $ select = [ $ select ] ; $ join = [ ] ; $ idx = 0 ; foreach ( $ refs as $ name => $ ref ) { $ refTable = "REF{$idx}_{$name}" ; $ idx ++ ; foreach ( array_keys ( get_object_vars ( new $ ref [ 'model' ] ( ) ) ) as $ attr ) { $ select [ ] = "{$refTable}.{$attr} AS '{$refTable}__{$attr}'" ; } $ joinCond = $ this -> table . '.' . $ ref [ 'attribute' ] . " = {$refTable}." . $ ref [ 'key' ] ; $ refRepo = $ this -> manager -> getByClass ( $ ref [ 'model' ] ) ; if ( $ this -> softRefs && $ refRepo instanceof SoftDbRepository ) { $ joinCond .= " AND $refTable." . $ refRepo -> getDeletedAttribute ( ) . ' IS NULL' ; } $ join [ ] = [ $ refRepo -> getCollectionName ( ) . " AS $refTable" , $ joinCond ] ; } $ query = $ query -> select ( implode ( ', ' , $ select ) ) -> from ( $ this -> table ) ; foreach ( $ join as $ args ) { $ query = $ query -> leftJoin ( $ args [ 0 ] , $ args [ 1 ] ) ; } if ( ! is_null ( $ conditions ) ) { $ query = $ query -> where ( $ this -> prefixModelAttributes ( $ conditions , $ model ) ) ; } if ( ! is_null ( $ order ) ) { $ query = $ query -> orderBy ( $ this -> prefixModelAttributes ( $ order , $ model ) ) ; } return $ query ; } | Set up join query for reference retrieval . |
42,150 | private function prefixModelAttributes ( $ input , $ model ) { foreach ( array_keys ( get_object_vars ( $ model ) ) as $ attr ) { $ input = preg_replace ( '/\\b' . $ attr . '\\b/' , $ this -> table . ".$attr" , $ input ) ; } return $ input ; } | Prefix model attributes with the associated table name . |
42,151 | private function create ( $ model ) { $ attrs = $ this -> getMutableAttributes ( $ model ) ; $ this -> db -> connect ( ) -> insert ( $ this -> table , array_keys ( $ attrs ) ) -> execute ( array_values ( $ attrs ) ) ; $ model -> { $ this -> key } = $ this -> db -> lastInsertId ( ) ; } | Create new entry . |
42,152 | private function update ( $ model ) { $ attrs = $ this -> getMutableAttributes ( $ model ) ; $ values = array_values ( $ attrs ) ; $ values [ ] = $ model -> { $ this -> key } ; $ this -> db -> connect ( ) -> update ( $ this -> table , array_keys ( $ attrs ) ) -> where ( $ this -> key . ' = ?' ) -> execute ( $ values ) ; } | Update entry . |
42,153 | private function getMutableAttributes ( $ model ) { $ attrs = get_object_vars ( $ model ) ; unset ( $ attrs [ $ this -> key ] ) ; if ( $ model instanceof ManagedModelInterface ) { foreach ( array_keys ( $ model -> getReferences ( ) ) as $ ref ) { unset ( $ attrs [ $ ref ] ) ; } } return $ attrs ; } | Get mutable model attributes . |
42,154 | public function set ( $ property , $ name , $ value = null ) { $ set = ( is_array ( $ name ) ) ? $ name : array ( $ name => $ value ) ; switch ( $ property ) { case 'errors' : $ this -> validator -> errors = array_merge ( $ this -> validator -> errors , $ set ) ; break ; case 'values' : case 'header' : case 'hidden' : $ this -> $ property = array_merge ( $ this -> $ property , $ set ) ; break ; case 'footer' : foreach ( ( array ) $ name as $ value ) { $ this -> footer [ ] = $ value ; } break ; } } | Set public properties . Useful for Twig templates that can t set them directly . |
42,155 | public function close ( ) { $ html = implode ( '' , $ this -> footer ) ; foreach ( $ this -> hidden as $ key => $ value ) { $ html .= "\n\t" . $ this -> input ( 'hidden' , array ( 'name' => $ key , 'value' => htmlspecialchars ( ( string ) $ value ) , ) ) ; } return $ html . "\n</form>" ; } | Closes and cleans up shop . |
42,156 | public function validate ( $ field , array $ attributes = array ( ) ) { foreach ( $ this -> validator -> rules ( $ field ) as $ validate => $ param ) { $ attributes [ "data-rule-{$validate}" ] = htmlspecialchars ( $ param ) ; } foreach ( $ this -> validator -> messages ( $ field ) as $ rule => $ message ) { $ attributes [ "data-msg-{$rule}" ] = htmlspecialchars ( $ message ) ; } return $ attributes ; } | This adds the jQuery Validation rules and messages set earlier to the input field s submitted attributes . This is used internally when creating form fields using this class . |
42,157 | private function flatten ( array $ array ) { $ single = array ( ) ; if ( isset ( $ array [ 'hier' ] ) ) { unset ( $ array [ 'hier' ] ) ; } foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ this -> flatten ( $ value ) as $ key => $ value ) { $ single [ $ key ] = $ value ; } } else { $ single [ $ key ] = $ value ; } } return $ single ; } | This is used with menus for getting to the bottom of multi - dimensional arrays and determining it s root keys and values . |
42,158 | public function encode ( $ d ) { if ( is_array ( $ d ) ) { $ def = 'd' ; $ s = '' ; $ list = false ; if ( is_int ( array_keys ( $ d ) [ 0 ] ) ) { $ list = true ; $ def = 'l' ; } ksort ( $ d , SORT_STRING ) ; foreach ( $ d as $ key => $ value ) { if ( is_string ( $ key ) ) { if ( $ list ) { throw new Exception ( 'Invalid bencode data.' , 1 ) ; } $ s .= strlen ( $ key ) . ':' . $ key ; } if ( is_int ( $ value ) || is_float ( $ value ) ) { $ s .= 'i' . $ value . 'e' ; } elseif ( is_string ( $ value ) ) { $ s .= strlen ( $ value ) . ':' . $ value ; } else { $ s .= $ this -> encode ( $ value ) ; } } return $ def . $ s . 'e' ; } elseif ( is_int ( $ d ) ) { return 'i' . $ d . 'e' ; } elseif ( is_string ( $ d ) ) { return strlen ( $ d ) . ':' . $ d ; } else { throw new Exception ( 'Invalid data provided to Bencode.' , 1 ) ; } } | Encodes data to Bencode data . |
42,159 | public function decode ( $ d , & $ pos = 0 ) { if ( ! is_string ( $ d ) ) { throw new Exception ( 'Tried to decode non-string data.' , 1 ) ; } if ( strlen ( $ d ) <= $ pos ) { return null ; } switch ( $ d [ $ pos ] ) { case 'd' : $ ret = [ ] ; $ pos ++ ; while ( $ d [ $ pos ] != 'e' ) { $ key = $ this -> decode ( $ d , $ pos ) ; $ value = $ this -> decode ( $ d , $ pos ) ; if ( is_null ( $ key ) || is_null ( $ value ) ) { break ; } $ ret [ $ key ] = $ value ; } $ pos ++ ; return $ ret ; case 'l' : $ ret = [ ] ; $ pos ++ ; while ( $ d [ $ pos ] != 'e' ) { $ value = $ this -> decode ( $ d , $ pos ) ; if ( is_null ( $ value ) ) { break ; } $ ret [ ] = $ value ; } $ pos ++ ; return $ ret ; case 'i' : $ pos ++ ; $ length = strpos ( $ d , 'e' , $ pos ) - $ pos ; $ value = intval ( substr ( $ d , $ pos , $ length ) ) ; $ pos += $ length + 1 ; return $ value ; default : $ length = strpos ( $ d , ':' , $ pos ) - $ pos ; if ( ! $ this -> validLength ( $ length ) ) { return null ; } $ valueLength = intval ( substr ( $ d , $ pos , $ length ) ) ; $ pos += $ length + 1 ; $ str = substr ( $ d , $ pos , $ valueLength ) ; $ pos += $ valueLength ; return $ str ; } } | Decodes Bencode data . |
42,160 | protected function getFields ( ) { if ( null === $ this -> cols ) { $ result = $ this -> statement -> result_metadata ( ) ; if ( false === $ result ) { return false ; } $ this -> cols = [ ] ; foreach ( $ result -> fetch_fields ( ) as $ col ) { $ this -> cols [ ] = $ col -> name ; } } return true ; } | Get fields first |
42,161 | public function load ( ) { if ( $ this -> cacheType ( ) === "data" ) { $ ref = new \ ReflectionClass ( $ this ) ; $ cache_name = Str :: snake ( $ ref -> getShortName ( ) ) ; $ cache_data = $ this -> cacheData ( ) ; if ( isset ( $ cache_data [ "id" ] ) ) { $ id = $ cache_data [ "id" ] ; unset ( $ cache_data [ "id" ] ) ; } else { $ id = $ cache_data ; } $ cache = new Cache ( $ id , "plugin/" . $ cache_name , $ cache_data ) ; if ( $ cache -> ready ( ) ) { $ this -> plugin_data = $ cache -> import ( ) ; } else { $ this -> loadPluginData ( ) ; $ cache -> export ( $ this -> plugin_data ) ; } } else { $ this -> loadPluginData ( ) ; } return $ this ; } | Load plugin data |
42,162 | public function hasChildren ( ) { if ( $ this -> resources === null ) { $ this -> initializeResouces ( ) ; } return current ( $ this -> resources ) instanceof \ Arbit \ VCSWrapper \ Directory ; } | Returns if an iterator can be created fot the current entry . |
42,163 | public function addChannel ( ChannelInterface $ channel ) { $ this -> getChannelStore ( ) -> addChannel ( $ channel ) ; $ processor = $ channel -> getProcessor ( ) ; if ( $ processor ) { $ this -> getProcessorStore ( ) -> addProcessor ( $ processor ) ; } } | Add a channel . |
42,164 | public function sendMessage ( MessageInterface $ message , array $ recipients ) { $ messageProcessor = new MessageProcessor ( $ this -> getProcessorStore ( ) ) ; $ message = $ messageProcessor -> preProcessMessage ( $ message ) ; foreach ( $ recipients as $ recipient ) { foreach ( $ this -> getChannels ( $ message , $ recipient ) as $ channel ) { $ processedMessage = $ messageProcessor -> processMessage ( clone ( $ message ) , $ recipient ) ; if ( $ channel -> isHandling ( $ processedMessage , $ recipient ) ) { $ channel -> send ( $ processedMessage , $ recipient ) ; } } } } | Send a message to any number of recipients . |
42,165 | private function getChannels ( MessageInterface $ message , RecipientInterface $ recipient ) { $ channels = $ this -> channelResolver -> getChannels ( $ message -> getType ( ) , $ this -> getChannelStore ( ) ) ; return $ this -> channelResolver -> filterChannels ( $ recipient , $ message -> getType ( ) , $ channels ) ; } | Apply all logic to get the correct channels for the current recipient . |
42,166 | public function reject ( Closure $ callback ) { $ hash = $ this -> create ( ) ; foreach ( $ this as $ key => $ value ) { if ( $ callback ( $ value , $ key ) == false ) { $ hash [ $ key ] = $ value ; } } return $ hash ; } | Rejects elements if the given function evaluates to true |
42,167 | public function map ( Closure $ callback ) { $ hash = $ this -> create ( ) ; $ this -> each ( function ( $ value , $ key ) use ( $ callback , $ hash ) { $ hash [ ] = $ callback ( $ value , $ key ) ; } ) ; return $ hash ; } | Maps elements into a new Hash |
42,168 | public function fetch ( $ key , $ default = null ) { if ( $ this -> hasKey ( $ key ) ) { return $ this [ $ key ] ; } elseif ( $ default !== null ) { if ( is_callable ( $ default ) ) { return $ default ( $ key ) ; } return $ default ; } throw new InvalidArgumentException ( "Invalid key '$key'" ) ; } | Get the value by the key . Throws exception when key is not set |
42,169 | public function valuesAt ( ) { $ args = func_get_args ( ) ; if ( is_array ( $ args [ 0 ] ) ) { $ args = $ args [ 0 ] ; } $ hash = $ this -> create ( ) ; foreach ( $ args as $ key ) { $ hash [ ] = $ this [ $ key ] ; } return $ hash ; } | Get the values at the given indexes . |
42,170 | public function groupBy ( $ criteria ) { $ criteria = $ this -> factoryCallableCriteria ( $ criteria ) ; $ groups = $ this -> create ( ) ; $ this -> each ( function ( $ element , $ key ) use ( $ groups , $ criteria ) { $ groupName = $ criteria ( $ element , $ key ) ; $ elements = $ groups -> offsetGet ( $ groupName , array ( ) ) ; $ elements [ ] = $ element ; $ groups [ $ groupName ] = $ elements ; } ) ; return $ groups ; } | Group elements by the given criteria |
42,171 | public function sortBy ( $ criteria ) { $ criteria = $ this -> factoryCallableCriteria ( $ criteria ) ; $ sorted = $ this -> create ( ) ; $ groups = $ this -> groupBy ( $ criteria ) ; $ criterias = $ this -> map ( function ( $ element , $ key ) use ( $ criteria ) { return $ criteria ( $ element , $ key ) ; } ) -> toArray ( ) ; sort ( $ criterias ) ; $ criterias = array_unique ( $ criterias ) ; foreach ( $ criterias as $ key ) { foreach ( $ groups [ $ key ] as $ element ) { $ sorted [ ] = $ element ; } } return $ sorted ; } | Sort elements by the given criteria |
42,172 | private function factoryCallableCriteria ( $ criteria ) { if ( ! $ this -> isCallable ( $ criteria ) ) { $ criteria = function ( $ element , $ key ) use ( $ criteria ) { return $ element -> fetch ( $ criteria ) ; } ; } return $ criteria ; } | Get a function that returns something based on an element item |
42,173 | public function merge ( Hash $ other , Closure $ closure = null ) { return $ this -> mergeInto ( clone $ this , $ other , $ closure ) ; } | Merges the two hashes and return a new Instance of a hash |
42,174 | public function minimize ( ) { foreach ( get_object_vars ( $ this ) as $ property => $ value ) { if ( $ value instanceof self ) { $ value -> minimize ( ) ; } elseif ( is_array ( $ value ) ) { $ this -> minimizeArray ( $ value ) ; } } return $ this ; } | Recursively remove all properties that don t belong in the minimal representation of this object |
42,175 | public function sort ( array $ defaultOrder , array $ controlsOrder = null , array $ metaOrder = null , array $ errorOrder = null ) { if ( ! in_array ( '{data}' , $ defaultOrder ) ) { throw new \ InvalidArgumentException ( 'Placeholder "{data}" not listed in $defaultOrder' ) ; } elseif ( $ controlsOrder && ! in_array ( '{data}' , $ controlsOrder ) ) { throw new \ InvalidArgumentException ( 'Placeholder "{data}" not listed in $controlsOrder' ) ; } elseif ( $ metaOrder && ! in_array ( '{data}' , $ metaOrder ) ) { throw new \ InvalidArgumentException ( 'Placeholder "{data}" not listed in $metaOrder' ) ; } elseif ( $ errorOrder && ! in_array ( '{data}' , $ errorOrder ) ) { throw new \ InvalidArgumentException ( 'Placeholder "{data}" not listed in $errorOrder' ) ; } $ controlsOrder || $ controlsOrder = $ defaultOrder ; $ metaOrder || $ metaOrder = $ defaultOrder ; $ errorOrder || $ errorOrder = $ defaultOrder ; $ this -> applySort ( '' , $ defaultOrder , $ controlsOrder , $ metaOrder , $ errorOrder ) ; return $ this ; } | This method allows an object s properties to be sorted according to an arbitrary sequence of properties . This is useful for standardizing the sequence of properties across several documents and for keeping the more important properties higher up . |
42,176 | public function handle ( ) { if ( ! $ this -> is_ajax_request ( ) ) { return Handler :: DONE ; } $ response = [ 'success' => false , 'data' => Formatter :: formatExceptionAsDataArray ( $ this -> getInspector ( ) , $ this -> addTraceToOutput ( ) ) , ] ; if ( Misc :: canSendHeaders ( ) ) { \ header ( 'Content-Type: application/json; charset=' . get_option ( 'blog_charset' ) ) ; } echo wp_json_encode ( $ response , JSON_PRETTY_PRINT ) ; return Handler :: QUIT ; } | The error handler . Send the error is the standard WordPress AJAX format . |
42,177 | public function executeQuery ( ) : IResultSet { if ( ! strlen ( $ this -> sql ) > 0 ) { throw new \ Exception ( 'Error sentencia sql no valida' ) ; } $ temp = $ this -> conect -> query ( $ this -> sql ) ; $ this -> sql = "" ; if ( $ temp == null ) { throw new \ Exception ( 'Error no se pudo encontrar nada en la base de datos' ) ; } return new ResultSetMYSQL ( $ temp ) ; } | Permite haser una lectura de los datos . |
42,178 | public function executeDelete ( EntityMetadata $ metadata , Store $ store , array $ criteria ) { $ criteria = $ this -> getFormatter ( ) -> formatQuery ( $ metadata , $ store , $ criteria ) ; return $ this -> createQueryBuilder ( $ metadata ) -> remove ( ) -> setQueryArray ( $ criteria ) -> getQuery ( ) -> execute ( ) ; ; } | Executes a delete for the provided metadata and criteria . |
42,179 | public function executeFind ( EntityMetadata $ metadata , Store $ store , array $ criteria , array $ fields = [ ] , array $ sort = [ ] , $ offset = 0 , $ limit = 0 ) { $ criteria = $ this -> getFormatter ( ) -> formatQuery ( $ metadata , $ store , $ criteria ) ; $ builder = $ this -> createQueryBuilder ( $ metadata ) -> find ( ) -> setQueryArray ( $ criteria ) ; $ this -> appendSearch ( $ builder , $ criteria ) ; $ this -> appendFields ( $ builder , $ fields ) ; $ this -> appendSort ( $ builder , $ sort ) ; $ this -> appendLimitAndOffset ( $ builder , $ limit , $ offset ) ; return $ builder -> getQuery ( ) -> execute ( ) ; } | Finds records from the database based on the provided metadata and criteria . |
42,180 | public function executeInsert ( EntityMetadata $ metadata , array $ toInsert ) { return $ this -> createQueryBuilder ( $ metadata ) -> insert ( ) -> setNewObj ( $ toInsert ) -> getQuery ( ) -> execute ( ) ; } | Executes an insert for the provided metadata . |
42,181 | public function executeUpdate ( EntityMetadata $ metadata , Store $ store , array $ criteria , array $ toUpdate ) { $ criteria = $ this -> getFormatter ( ) -> formatQuery ( $ metadata , $ store , $ criteria ) ; return $ this -> createQueryBuilder ( $ metadata ) -> update ( ) -> setQueryArray ( $ criteria ) -> setNewObj ( $ toUpdate ) -> getQuery ( ) -> execute ( ) ; ; } | Updates a record from the database based on the provided metadata and criteria . |
42,182 | public function getInverseCriteria ( EntityMetadata $ owner , EntityMetadata $ related , $ identifiers , $ inverseField ) { $ criteria = [ $ inverseField => ( array ) $ identifiers , ] ; if ( true === $ related -> isChildEntity ( ) ) { $ criteria [ Persister :: POLYMORPHIC_KEY ] = $ related -> type ; } return $ criteria ; } | Gets standard database retrieval criteria for an inverse relationship . |
42,183 | public function getModelCollection ( EntityMetadata $ metadata ) { if ( ! $ metadata -> persistence instanceof StorageMetadata ) { throw PersisterException :: badRequest ( 'Wrong StorageMetadata type' ) ; } return $ this -> connection -> selectCollection ( $ metadata -> persistence -> db , $ metadata -> persistence -> collection ) ; } | Gets the MongoDB Collection object for a Model . |
42,184 | public function getRetrieveCritiera ( EntityMetadata $ metadata , $ identifiers = null ) { $ criteria = [ ] ; if ( true === $ metadata -> isChildEntity ( ) ) { $ criteria [ Persister :: POLYMORPHIC_KEY ] = $ metadata -> type ; } elseif ( true === $ metadata -> isPolymorphic ( ) && false === $ metadata -> isAbstract ( ) ) { $ criteria [ Persister :: POLYMORPHIC_KEY ] = $ metadata -> type ; } $ identifiers = ( array ) $ identifiers ; if ( empty ( $ identifiers ) ) { return $ criteria ; } $ criteria [ Persister :: IDENTIFIER_KEY ] = ( 1 === count ( $ identifiers ) ) ? reset ( $ identifiers ) : $ identifiers ; return $ criteria ; } | Gets standard database retrieval criteria for an entity and the provided identifiers . |
42,185 | private function appendFields ( QueryBuilder $ builder , array $ fields ) { list ( $ fields , $ include ) = $ this -> prepareFields ( $ fields ) ; if ( ! empty ( $ fields ) ) { $ method = ( true === $ include ) ? 'select' : 'exclude' ; $ builder -> $ method ( array_keys ( $ fields ) ) ; } return $ this ; } | Appends projection fields to a Query Builder . |
42,186 | private function appendLimitAndOffset ( QueryBuilder $ builder , $ limit , $ offset ) { $ limit = ( int ) $ limit ; $ offset = ( int ) $ offset ; if ( $ limit > 0 ) { $ builder -> limit ( $ limit ) ; } if ( $ offset > 0 ) { $ builder -> skip ( $ offset ) ; } return $ this ; } | Appends offset and limit criteria to a Query Builder |
42,187 | private function appendSearch ( QueryBuilder $ builder , array $ criteria ) { if ( false === $ this -> isSearchQuery ( $ criteria ) ) { return $ this ; } $ builder -> selectMeta ( 'searchScore' , 'textScore' ) ; $ builder -> sortMeta ( 'searchScore' , 'textScore' ) ; return $ this ; } | Appends text search score and sorting to a Query Builder . |
42,188 | private function appendSort ( QueryBuilder $ builder , array $ sort ) { if ( ! empty ( $ sort ) ) { $ builder -> sort ( $ sort ) ; } return $ this ; } | Appends sorting criteria to a Query Builder . |
42,189 | private function isSearchQuery ( array $ criteria ) { if ( isset ( $ criteria [ '$text' ] ) ) { return true ; } foreach ( $ criteria as $ key => $ value ) { if ( is_array ( $ value ) && true === $ this -> isSearchQuery ( $ value ) ) { return true ; } } return false ; } | Determines if the provided query criteria contains text search . |
42,190 | private function prepareFields ( array $ fields ) { $ include = null ; foreach ( $ fields as $ key => $ type ) { $ type = ( bool ) $ type ; if ( null === $ include ) { $ include = $ type ; } if ( $ type !== $ include ) { PersisterException :: badRequest ( 'Field projection mismatch. You cannot both exclude and include fields.' ) ; } $ fields [ $ key ] = $ type ; } return [ $ fields , $ include ] ; } | Prepares projection fields for a query and returns as a tuple . |
42,191 | public function getPage ( ) { if ( empty ( $ this -> page ) && ( $ paramName = $ this -> getParamName ( ) ) != '' ) { $ this -> setPage ( \ pwf \ basic \ Application :: $ instance -> getRequest ( ) -> get ( $ paramName ) ) ; } return $ this -> page ; } | Get current page number |
42,192 | public function update ( $ input , $ fields , & $ errCount = 0 ) { $ operation = $ this -> getUpdateOperation ( $ input , $ fields ) ; $ operation -> validate ( $ errCount ) ; return $ operation -> runIfValid ( ) ; } | Update this permanent object from input data array |
42,193 | public function getUpdateOperation ( $ input , $ fields ) { $ operation = new UpdateTransactionOperation ( static :: getClass ( ) , $ input , $ fields , $ this ) ; $ operation -> setSQLAdapter ( static :: getSQLAdapter ( ) ) ; return $ operation ; } | Get the update operation |
42,194 | public static function onValidUpdate ( & $ input , $ newErrors ) { $ found = 0 ; foreach ( $ input as $ fieldname => $ fieldvalue ) { if ( in_array ( $ fieldname , static :: $ fields ) ) { $ found ++ ; } } if ( $ found ) { static :: fillLogEvent ( $ input , 'edit' ) ; static :: fillLogEvent ( $ input , 'update' ) ; } return $ found ? true : false ; } | Callback when validating update |
42,195 | public static function extractUpdateQuery ( & $ input , PermanentObject $ object ) { static :: onEdit ( $ input , $ object ) ; foreach ( $ input as $ fieldName => $ fieldValue ) { if ( ! in_array ( $ fieldName , static :: $ fields ) ) { unset ( $ input [ $ fieldName ] ) ; } } $ options = array ( 'what' => $ input , 'table' => static :: $ table , 'where' => static :: getIDField ( ) . '=' . $ object -> id ( ) , 'number' => 1 , ) ; return $ options ; } | Extract an update query from this object |
42,196 | public function save ( ) { if ( empty ( $ this -> modFields ) || $ this -> isDeleted ( ) ) { return false ; } $ data = array_filterbykeys ( $ this -> data , $ this -> modFields ) ; if ( ! $ data ) { throw new Exception ( 'No updated data found but there is modified fields, unable to update' ) ; } $ operation = $ this -> getUpdateOperation ( $ data , $ this -> modFields ) ; $ r = $ operation -> run ( ) ; $ this -> modFields = array ( ) ; if ( ! $ this -> onSavedInProgress ) { $ this -> onSavedInProgress = true ; static :: onSaved ( $ data , $ this ) ; $ this -> onSavedInProgress = false ; } return $ r ; } | Save this permanent object |
42,197 | public function remove ( ) { if ( $ this -> isDeleted ( ) ) { return 0 ; } $ operation = $ this -> getDeleteOperation ( ) ; $ errors = 0 ; $ operation -> validate ( $ errors ) ; return $ operation -> runIfValid ( ) ; } | What do you think it does ? |
42,198 | public function reload ( $ field = null ) { $ IDFIELD = static :: getIDField ( ) ; $ options = array ( 'where' => $ IDFIELD . '=' . $ this -> $ IDFIELD , 'output' => SQLAdapter :: ARR_FIRST ) ; if ( $ field ) { if ( ! in_array ( $ field , static :: $ fields ) ) { throw new FieldNotFoundException ( $ field , static :: getClass ( ) ) ; } $ i = array_search ( $ this -> modFields , $ field ) ; if ( $ i !== false ) { unset ( $ this -> modFields [ $ i ] ) ; } $ options [ 'what' ] = $ field ; } else { $ this -> modFields = array ( ) ; } try { $ data = static :: get ( $ options ) ; } catch ( SQLException $ e ) { $ data = null ; } if ( empty ( $ data ) ) { $ this -> markAsDeleted ( ) ; return false ; } if ( ! is_null ( $ field ) ) { $ this -> data [ $ field ] = $ data [ $ field ] ; } else { $ this -> data = $ data ; } return true ; } | Reload fields from database |
42,199 | public function getValue ( $ key = null ) { if ( empty ( $ key ) ) { return $ this -> data ; } if ( ! array_key_exists ( $ key , $ this -> data ) ) { throw new FieldNotFoundException ( $ key , static :: getClass ( ) ) ; } return $ this -> data [ $ key ] ; } | Get one value or all values |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.