idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
47,200 | public function getPath ( array $ parameters ) { foreach ( $ parameters as $ parameterName => $ parameterValue ) { $ parameterMethod = 'set' . ucfirst ( $ parameterName ) ; $ this -> $ parameterMethod ( $ parameterValue ) ; } return $ this -> buildPath ( ) ; } | returns the resource path which is usable by a client |
47,201 | protected function buildPath ( ) { $ urlParameters = array ( ) ; $ parameters = get_object_vars ( $ this ) ; foreach ( $ parameters as $ parameterName => $ parameterValue ) { if ( true === is_null ( $ parameterValue ) ) { continue ; } if ( $ parameterName === 'apiKey' ) { $ parameterName = 'api_key' ; } $ urlParameters... | builds a API query string path |
47,202 | protected function getArrayPathParameter ( $ parameterName , array $ parameterValue ) { $ urlParameter = array ( ) ; foreach ( $ parameterValue as $ parameterValueValue ) { $ urlParameter [ ] = $ this -> getPathParameter ( $ parameterName , $ parameterValueValue ) ; } return implode ( '&' , $ urlParameter ) ; } | iterates over an array parameter value |
47,203 | protected function prepareAllAttributes ( ) { static :: $ all_attributes = static :: $ my_attributes ; $ parent = get_class ( $ this ) ; while ( ( $ parent = get_parent_class ( $ parent ) ) != 'Palmabit\Library\Models\SingleTableInheritance' ) { static :: $ all_attributes = array_merge ( static :: $ all_attributes , $ ... | Fill the array containing all the attributes that belongs to the class |
47,204 | public function newQuery ( $ excludeDeleted = true ) { $ builder = parent :: newQuery ( $ excludeDeleted ) ; $ builder -> where ( static :: $ table_type_field , '=' , $ this -> table_type ) ; return $ builder ; } | Update newQuery to fetch data of the right type |
47,205 | public function delete ( Resource \ ResourceId $ resourceId ) { $ this -> crudRepositoryAdapter -> deleteResource ( $ this -> resourceType , $ resourceId ) ; } | Delete Resource by it s resource id |
47,206 | public function update ( Resource \ ResourceData $ resourceData ) { return $ this -> crudRepositoryAdapter -> updateResource ( $ this -> resourceType , $ resourceData ) ; } | Update resource data |
47,207 | public function read ( Resource \ ResourceId $ resourceId ) { return $ this -> crudRepositoryAdapter -> getResource ( $ this -> resourceType , $ resourceId ) ; } | Read data for a single resource |
47,208 | public function bindColumn ( $ column , & $ variable , $ type = null ) : bool { try { return $ this -> pdoStatement -> bindColumn ( $ column , $ variable , $ type , null , null ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | bind a result column to a variable |
47,209 | public function fetch ( int $ fetchMode = null , array $ driverOptions = [ ] ) { if ( null === $ fetchMode ) { $ fetchMode = PDO :: FETCH_ASSOC ; } try { return $ this -> pdoStatement -> fetch ( $ fetchMode , $ driverOptions [ 'cursorOrientation' ] ?? null , $ driverOptions [ 'cursorOffset' ] ?? null ) ; } catch ( PDOE... | fetch a result |
47,210 | public function fetchOne ( int $ columnNumber = 0 ) { try { return $ this -> pdoStatement -> fetchColumn ( $ columnNumber ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | fetch single column from the next row from a result set |
47,211 | public function fetchAll ( int $ fetchMode = null , array $ driverOptions = [ ] ) : array { try { if ( null === $ fetchMode ) { return $ this -> pdoStatement -> fetchAll ( ) ; } if ( PDO :: FETCH_COLUMN == $ fetchMode ) { return $ this -> pdoStatement -> fetchAll ( PDO :: FETCH_COLUMN , $ driverOptions [ 'columnIndex' ... | returns an array containing all of the result set rows |
47,212 | public function next ( ) : bool { try { return $ this -> pdoStatement -> nextRowset ( ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | moves the internal result pointer to the next result row |
47,213 | public function count ( ) : int { try { return $ this -> pdoStatement -> rowCount ( ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | returns the number of rows affected by the last SQL statement |
47,214 | public function free ( ) : bool { try { return $ this -> pdoStatement -> closeCursor ( ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | releases resources allocated of the result set |
47,215 | protected function parseClassEvent ( $ class , $ prefix ) { if ( Str :: contains ( $ class , '@' ) ) return explode ( '@' , $ class ) ; $ method = Str :: contains ( $ prefix , 'composing' ) ? 'compose' : 'create' ; return [ $ class , $ method ] ; } | Parse a class based composer name . |
47,216 | protected function _render ( $ context = null ) { if ( is_null ( $ context ) ) { $ context = [ ] ; } return $ this -> _replaceTokens ( $ this -> _getPlaceholderTemplate ( ) , $ context , $ this -> _getTokenStart ( ) , $ this -> _getTokenEnd ( ) , $ this -> _getDefaultPlaceholderValue ( ) ) ; } | Renders this template with context . |
47,217 | protected function setProp ( string $ property , $ value ) { if ( \ property_exists ( $ this , $ property ) ) { $ this -> { $ property } = $ value ; } } | Set a property on the ZenodorusArguments object . |
47,218 | public function get ( string $ property , $ callback = false ) { if ( isset ( $ this -> processed [ $ property ] ) ) { if ( $ callback ) { return \ call_user_func ( $ callback , $ this -> processed [ $ property ] ) ; } return $ this -> processed [ $ property ] ; } return false ; } | Get a specific value . |
47,219 | protected function connectToMySql ( $ mySQLconfig ) { if ( is_null ( $ this -> mySQLconnection ) ) { extract ( $ mySQLconfig ) ; $ this -> mySQLconnection = new \ mysqli ( $ host , $ username , $ password , $ database , $ port ) ; if ( $ this -> mySQLconnection -> connect_error ) { $ this -> mySQLconnection = null ; $ ... | Initiates connection to MySQL |
47,220 | protected function getFieldOutputDate ( $ value ) { $ defaultValue = $ this -> getFieldValue ( $ value ) ; if ( $ defaultValue == 'NULL' ) { $ defaultValue = date ( 'Y-m-d' ) ; } $ inA = [ 'type' => 'text' , 'name' => $ value [ 'COLUMN_NAME' ] , 'id' => $ value [ 'COLUMN_NAME' ] , 'value' => $ defaultValue , 'size' => ... | Returns a Date field 2 use in a form |
47,221 | protected function getMySQLqueryWithParameterIdentifier ( $ sQuery , $ paramIdentifier ) { $ sReturn = true ; if ( strpos ( $ sQuery , $ paramIdentifier ) === false ) { $ sReturn = false ; } return $ sReturn ; } | Provides a detection if given Query does contain a Parameter that may require statement processing later on |
47,222 | protected function setMySQLquery2Server ( $ sQuery , $ sReturnType = null , $ ftrs = null ) { if ( is_null ( $ sReturnType ) ) { $ this -> mySQLconnection -> query ( html_entity_decode ( $ sQuery ) ) ; return '' ; } elseif ( is_null ( $ this -> mySQLconnection ) ) { return [ 'customError' => $ this -> lclMsgCmn ( 'i18n... | Transmit Query to MySQL server and get results back |
47,223 | public function addParameter ( $ key , $ data ) { if ( ! is_string ( $ key ) ) { throw new \ RuntimeException ( 'Only strings can be given as parameter keys. Got "' . gettype ( $ key ) . '".' ) ; } if ( ! is_string ( $ data ) && ! is_callable ( $ data ) ) { throw new \ RuntimeException ( 'The "data" parameter must eith... | Adds a parameter that can occur in Fact texts . |
47,224 | public function getCatalogItem ( $ name ) { if ( ! ( $ this -> getFiller ( ) instanceof FillerInterface ) ) { return ; } try { $ list = $ this -> search ( [ 'name' => $ name ] ) ; if ( count ( $ list ) == 1 ) { return $ this -> getFiller ( ) -> fillFromSearchResult ( array_pop ( $ list ) ) ; } } catch ( \ Exception $ e... | Try search item by name and fill it if can . |
47,225 | public static function user ( ) { if ( Session :: has ( 'user' ) ) { $ userModel = Config :: get ( 'user' ) ; $ model = new $ userModel ( ) ; return $ model -> find ( Session :: get ( 'user' ) ) ; } return false ; } | Returns the logged in user s data as an object . |
47,226 | public static function attempt ( $ input ) { $ userModel = Config :: get ( 'user' ) ; $ model = new $ userModel ( ) ; $ count = 0 ; foreach ( $ input as $ field => $ value ) { if ( $ field == '_' ) { unset ( $ input [ $ field ] ) ; } else { $ count ++ ; } if ( $ count == 1 ) { $ primary = $ field ; } } if ( ! empty ( $... | Attempt to login the user . If succeeds create a user session . |
47,227 | protected function sanitizeUsername ( ) { $ username = $ this -> has ( 'username' ) ? $ this -> get ( 'username' ) : $ this -> get ( 'first_name' ) . ' ' . $ this -> get ( 'last_name' ) ; return Str :: slug ( $ username , config ( 'arcanesoft.auth.slug-separator' , '.' ) ) ; } | Sanitize the username . |
47,228 | protected function configureDataProperties ( ) { if ( isset ( $ this -> properties [ self :: PROPERTY_DATA ] ) ) { $ this -> data -> setProperties ( $ this -> properties [ 'data' ] ) ; } return $ this ; } | Passes Data properties to Endpoint Data object |
47,229 | private function clear ( $ directory , OutputInterface $ output ) { $ handle = opendir ( $ directory ) ; $ ignore = [ '.' , '..' , '.gitkeep' ] ; while ( $ file = readdir ( $ handle ) ) { if ( ! in_array ( $ file , $ ignore ) ) { $ output -> writeln ( "Clearing file {$file} from the cache" ) ; unlink ( $ directory . $ ... | Handles clearning out files from given location . |
47,230 | public function BeforeDelete ( $ item ) { $ navPages = NavigationPage :: Schema ( ) -> FetchByPage ( false , $ item ) ; foreach ( $ navPages as $ navPage ) { $ item = $ navPage -> GetItem ( ) ; $ tree = new TreeBuilder ( new NavigationTreeProvider ( $ item -> GetNavigation ( ) ) ) ; $ tree -> Remove ( $ item ) ; } } | Deletes the navi items related to the page |
47,231 | public function onInsert ( EventInterface $ event ) { $ values = $ event -> getParam ( 'values' ) ; $ now = new DateTime ( ) ; $ now = $ now -> format ( 'Y-m-d h:i:s' ) ; $ values [ 'created_at' ] = $ now ; $ values [ 'last_updated_at' ] = $ now ; $ event -> setParam ( 'values' , $ values ) ; } | Add current DateTime value for fields created_at and last_updated_at |
47,232 | public function onUpdate ( EventInterface $ event ) { $ values = $ event -> getParam ( 'values' ) ; $ now = new DateTime ( ) ; $ values [ 'last_updated_at' ] = $ now -> format ( 'Y-m-d h:i:s' ) ; $ event -> setParam ( 'values' , $ values ) ; } | Add current DateTime value for field last_updated_at |
47,233 | public function rewind ( ) { if ( $ this -> datespan instanceof Day ) { $ this -> current = $ this -> datespan ; } else { $ this -> current = new Day ( $ this -> datespan -> start ( ) ) ; } } | returns iteration back to first day of datespan |
47,234 | public function contains ( $ key , $ value ) { return in_array ( $ value , $ this -> get ( $ key , NULL , FALSE ) ) ; } | Returns TRUE if the given HTTP header contains the given value . |
47,235 | public static function fromString ( $ query , $ urlEncoding = true ) { static $ qp ; if ( ! $ qp ) { $ qp = new QueryParser ( ) ; } $ q = new static ( ) ; if ( $ urlEncoding !== true ) { $ q -> setEncodingType ( $ urlEncoding ) ; } $ qp -> parseInto ( $ q , $ query , $ urlEncoding ) ; return $ q ; } | Parse a query string into a Query object |
47,236 | public static function duplicateAggregator ( ) { return function ( array $ data ) { return self :: walkQuery ( $ data , '' , function ( $ key , $ prefix ) { return is_int ( $ key ) ? $ prefix : "{$prefix}[{$key}]" ; } ) ; } ; } | Query string aggregator that does not aggregate nested query string values and allows duplicates in the resulting array . |
47,237 | public static function walkQuery ( array $ query , $ keyPrefix , callable $ prefixer ) { $ result = [ ] ; foreach ( $ query as $ key => $ value ) { if ( $ keyPrefix ) { $ key = $ prefixer ( $ key , $ keyPrefix ) ; } if ( is_array ( $ value ) ) { $ result += self :: walkQuery ( $ value , $ key , $ prefixer ) ; } elseif ... | Easily create query aggregation functions by providing a key prefix function to this query string array walker . |
47,238 | public function getInteger ( $ key ) { $ resolved = false ; $ value = $ this -> getByKey ( $ key , $ this -> data , $ resolved ) ; if ( $ resolved ) { return ( int ) $ value ; } if ( func_num_args ( ) > 1 ) { return func_get_arg ( 1 ) ; } throw new \ OutOfBoundsException ( 'Configuration setting not found: "' . $ key .... | Get an integer value by key . |
47,239 | public function getFloat ( $ key ) { $ resolved = false ; $ value = $ this -> getByKey ( $ key , $ this -> data , $ resolved ) ; if ( $ resolved ) { return floatval ( $ value ) ; } if ( func_num_args ( ) > 1 ) { return func_get_arg ( 1 ) ; } throw new \ OutOfBoundsException ( 'Configuration setting not found: "' . $ ke... | Get a floating point value by key . |
47,240 | public function leave ( ) : void { if ( $ this -> canTrack ( ) ) { $ track = $ this -> orm -> tracking -> getLatest ( $ this -> user -> getUid ( ) ) ; if ( $ track ) { $ timeOnPage = time ( ) - $ track -> inserted -> getTimestamp ( ) ; if ( $ timeOnPage < ( $ this -> minTimeBetweenVisits * 60 ) ) { $ track -> timeOnPag... | Zaznam odchodu ze stranky |
47,241 | public function track ( ) : void { if ( $ this -> canTrack ( ) ) { $ track = new TrackingEntity ; $ track -> uid = $ this -> user -> getUid ( ) ; $ track -> inserted = new DateTime ; $ track -> url = $ this -> getParam ( 'url' ) ; $ track -> referer = $ this -> getParam ( 'referer' ) ; $ track -> ip = $ this -> getIp (... | Zaznam prichodu na stranku |
47,242 | private function checkVisits ( Range $ interval ) : void { foreach ( $ this -> orm -> trackingVisits -> findCalculateDate ( $ interval ) as $ date ) { if ( $ date !== null ) { $ date = $ date -> setTime ( 0 , 0 , 0 ) ; $ to = $ date -> modify ( '+23 hour' ) ; $ to = $ to -> modify ( '+59 minute' ) ; $ to = $ to -> modi... | Ulozeni zaznamu pokud jeste nejsou prepocitane |
47,243 | public function findClicksValue ( int $ groupId , Range $ interval ) : ? Result { return $ this -> orm -> clickTracking -> findClicksByValue ( $ groupId , $ interval ) ; } | Pocet kliku podle hondoty |
47,244 | private function getAdapterNode ( ) { $ node = $ this -> createRootNode ( 'adapter' ) ; return $ node -> isRequired ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> enumNode ( 'type' ) -> values ( [ 'jsonapiorg' , null ] ) -> end ( ) -> scalarNode ( 'service' ) -> cannotBeEmpty ( ) -> end ( ) -> end ( ) -> validate ( ... | Gets the api adapter configuration node . |
47,245 | private function getMetadataNode ( ) { $ node = $ this -> createRootNode ( 'metadata' ) ; return $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'drivers' ) -> defaultValue ( [ 'default' => [ 'type' => 'yml' ] ] ) -> useAttributeAsKey ( 'name' ) -> prototype ( 'array' ) -> performNoDeepMerging ( ) -> c... | Gets the metadata configuration node . |
47,246 | private function getPersistersNode ( ) { $ node = $ this -> createRootNode ( 'persisters' ) ; return $ node -> isRequired ( ) -> useAttributeAsKey ( 'name' ) -> prototype ( 'array' ) -> children ( ) -> enumNode ( 'type' ) -> values ( [ 'mongodb' , null ] ) -> end ( ) -> scalarNode ( 'service' ) -> cannotBeEmpty ( ) -> ... | Gets the persisters configuration node . |
47,247 | private function getRestNode ( ) { $ node = $ this -> createRootNode ( 'rest' ) ; return $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'root_endpoint' ) -> isRequired ( ) -> cannotBeEmpty ( ) -> defaultValue ( 'modlr/api' ) -> validate ( ) -> always ( function ( $ v ) { $ v = $ this -> formatRestEnd... | Gets the rest configuration node . |
47,248 | private function validateLibClassExists ( $ subClass , $ path ) { $ class = Utility :: getLibraryClass ( $ subClass ) ; if ( false === class_exists ( $ class ) ) { throw new InvalidConfigurationException ( sprintf ( 'The library class "%s" was not found for "%s" - was the library installed?' , $ class , $ path ) ) ; } ... | Validates that a library class name exists . |
47,249 | private function validateMetadataCache ( array $ config ) { if ( false === $ config [ 'enabled' ] ) { return $ this ; } $ this -> validateTypeAndService ( $ config , 'as3_modlr.metadata.cache' ) ; switch ( $ config [ 'type' ] ) { case 'redis' : $ this -> validateMetadataCacheRedis ( $ config ) ; break ; default : break... | Validates the metadata cache config . |
47,250 | private function validateMetadataDrivers ( array $ drivers ) { foreach ( $ drivers as $ name => $ config ) { $ this -> validateTypeAndService ( $ config , sprintf ( 'as3_modlr.metadata.drivers.%s' , $ name ) ) ; } return $ this ; } | Validates the metadata drivers config . |
47,251 | private function validatePersisters ( array $ persisters ) { foreach ( $ persisters as $ name => $ config ) { $ this -> validateTypeAndService ( $ config , sprintf ( 'as3_modlr.persisters.%s' , $ name ) ) ; switch ( $ config [ 'type' ] ) { case 'mongodb' : $ this -> validateLibClassExists ( 'Persister\MongoDb\Persister... | Validates the persisters config . |
47,252 | private function validateSearchClients ( array $ clients ) { foreach ( $ clients as $ name => $ config ) { $ this -> validateTypeAndService ( $ config , sprintf ( 'as3_modlr.search_clients.%s' , $ name ) ) ; switch ( $ config [ 'type' ] ) { case 'elastic' : $ this -> validateLibClassExists ( 'Search\Elastic\Client' , s... | Validates the search clients config . |
47,253 | private function validateTypeAndService ( array $ config , $ path ) { if ( ! isset ( $ config [ 'type' ] ) && ! isset ( $ config [ 'service' ] ) ) { throw new InvalidConfigurationException ( sprintf ( 'You must set one of "type" or "service" for "%s"' , $ path ) ) ; } if ( isset ( $ config [ 'type' ] ) && isset ( $ con... | Validates a configuration that uses type and service as options . |
47,254 | protected function setCurrentEndpoint ( EndpointInterface $ Endpoint ) { if ( isset ( $ this -> currentEndPoint ) ) { unset ( $ this -> lastEndPoint ) ; $ this -> lastEndPoint = $ this -> currentEndPoint ; unset ( $ this -> currentEndPoint ) ; } $ this -> currentEndPoint = $ Endpoint ; return $ this ; } | Rotates current Endpoint to Last Endpoint and sets Current Endpoint with passed in Endpoint |
47,255 | public static function reserve ( $ queue ) { $ payload = Resque :: pop ( $ queue ) ; if ( ! is_array ( $ payload ) ) { return false ; } return new Job ( $ queue , $ payload ) ; } | Find the next available job from the specified queue and return an instance of Job for it . |
47,256 | protected function generatePath ( SplFileInfo $ fileinfo , $ skeletonPath , $ targetPath , Inflector $ inflector ) { return $ inflector -> translate ( sprintf ( '%s%s' , $ targetPath , str_replace ( $ skeletonPath , '' , $ fileinfo -> getRealPath ( ) ) ) ) ; } | generate targer file path from source path . |
47,257 | protected function getMetadata ( $ templateFileContent ) { $ regex = '/\@MajoraGenerator\((.+)\)/' ; $ templateFileMetadata = array ( 'force_generation' => false ) ; if ( ! preg_match_all ( $ regex , $ templateFileContent , $ matches , PREG_SET_ORDER ) ) { return $ templateFileMetadata ; } foreach ( $ matches as $ matc... | parse metadata from given template content . |
47,258 | protected function generateDir ( $ destDirPath ) { if ( $ this -> filesystem -> exists ( $ destDirPath ) ) { return ; } $ this -> filesystem -> mkdir ( $ destDirPath ) ; $ this -> logger -> info ( sprintf ( 'dir created: %s' , $ destDirPath ) ) ; } | generate dest dir . |
47,259 | public function modify ( SplFileInfo $ generatedFile , SplFileInfo $ templateFile , array $ modifiers , Inflector $ inflector ) { foreach ( $ modifiers as $ modifierAlias => $ modifierData ) { if ( $ modifier = $ this -> contentModifiers -> get ( $ modifierAlias ) ) { $ this -> filesystem -> dumpFile ( $ generatedFile ... | run content modifiers on given file content . |
47,260 | public function createLog ( $ handler , $ name , $ ident , $ conf = null , $ level = null ) { $ this -> log = \ Log :: singleton ( $ handler , $ name , $ ident , $ conf , $ level ) ; } | This creates a specific type of log instance |
47,261 | public function fromXPath2Exception ( $ ex ) { if ( ! $ this -> log ) return ; return $ this -> log -> warning ( $ ex -> ErrorCode . " " . $ ex -> getMessage ( ) ) ; } | A convenience function for logging a event about an XPath conformance issue . It will log a message at the PEAR_LOG_DEBUG log level . |
47,262 | public function setDebugLog ( ) { $ logConsole = \ Log :: singleton ( 'console' , '' , 'console' , array ( 'lineFormat' => '%{timestamp} [%{priority}] %{message}' , 'timeFormat' => '%Y-%m-%d %H:%M:%S' , ) ) ; $ logError = \ Log :: singleton ( 'error_log' , PEAR_LOG_TYPE_SYSTEM , 'error_log' , array ( 'lineFormat' => '[... | Set log output for console and error_log |
47,263 | public function hookDashboardHandlers ( array & $ handlers ) { $ weight = count ( $ handlers ) ; $ model = $ this -> getModel ( ) ; $ settings = $ this -> module -> getSettings ( 'ga_report' ) ; foreach ( $ model -> getHandlers ( ) as $ id => $ handler ) { if ( ! in_array ( $ id , $ settings [ 'dashboard' ] ) ) { conti... | Implements hook dashboard . handlers |
47,264 | public function hookConstructControllerBackend ( $ controller ) { if ( $ controller -> isQuery ( 'ga.update' ) ) { $ store_id = $ controller -> getQuery ( 'ga.update.store_id' , '' ) ; $ handler_id = $ controller -> getQuery ( 'ga.update.handler_id' , '' ) ; $ this -> getModel ( ) -> clearCache ( $ handler_id , $ store... | Implements hook construct . controller . backend |
47,265 | public function getReport ( $ handler , $ settings = null ) { if ( ! is_array ( $ handler ) ) { $ handler = $ this -> getHandler ( $ handler ) ; } if ( ! isset ( $ settings ) ) { $ settings = $ this -> module -> getSettings ( 'ga_report' ) ; } return $ this -> getModel ( ) -> get ( $ handler , $ settings ) ; } | Returns an array of Google Anylytics report |
47,266 | public function setPPN ( $ ppn ) { $ ppnField = $ this -> getFirstMatchingField ( '003@/00' ) ; if ( $ ppnField ) { $ ppnSubfield = $ ppnField -> getNthSubfield ( '0' , 0 ) ; if ( $ ppnSubfield ) { $ ppnSubfield -> setValue ( $ ppn ) ; } else { $ ppnField -> append ( new Subfield ( '0' , $ ppn ) ) ; } } else { $ this -... | Set the Pica production number . |
47,267 | public function getMatcherConfiguration ( $ matcherClass ) { if ( ! array_key_exists ( $ matcherClass , $ this -> configuration [ "matcher_settings" ] ) ) { return null ; } $ configuration = $ this -> configuration [ "matcher_settings" ] [ $ matcherClass ] ; unset ( $ this -> configuration [ "matcher_settings" ] [ $ ma... | Returns the configuration for the given matcher or null . |
47,268 | public function configure ( Closure $ callback ) { if ( ! is_array ( $ configuration = $ callback ( $ this -> configuration ) ) ) { throw new Exceptions \ InvalidConfigurationException ( $ configuration ) ; } $ this -> configuration = array_merge ( $ this -> defaultConfiguration , $ configuration ) ; } | Configures Essence via the given Closure . |
47,269 | public function setBuilder ( AssertionBuilder $ builder ) { if ( ! is_null ( $ this -> builder ) and $ this -> configuration [ "implicit_validation" ] ) { $ this -> go ( ) ; } $ this -> builders [ ] = $ builder ; $ this -> builder = $ builder ; } | Replaces the stored AssertionBuilder instance with the given one . |
47,270 | public function go ( $ verbose = false ) { $ this -> builder -> setLinks ( $ this -> configuration [ "links" ] ) ; $ this -> builder -> setMatchers ( $ this -> configuration [ "matchers" ] ) ; if ( ! $ this -> builder -> validate ( ) ) { if ( $ verbose ) { $ this -> dumpValueAndArguments ( $ this -> builder -> getLastM... | Explicitly performs the validation . |
47,271 | protected function dumpValueAndArguments ( Matchers \ AbstractMatcher $ matcher ) { printf ( "Value: %s" . PHP_EOL , $ matcher -> getDumper ( ) -> dump ( $ matcher -> getValue ( ) ) ) ; print ( "Arguments:" . PHP_EOL ) ; foreach ( $ matcher -> getArguments ( ) as $ key => $ argument ) { printf ( " #%s: %s" . PHP_EOL ,... | Dumps given matcher s value and its arguments . |
47,272 | protected function initialize ( array $ fields ) { $ this -> content = new Content ; $ this -> revision = new Revision ; foreach ( $ fields as $ field => $ settings ) { $ this -> data [ $ field ] = $ this -> initializeField ( $ field , $ settings ) ; } } | Creates the Content Revision and FieldCollections |
47,273 | protected function initializeField ( $ field , $ settings ) { if ( $ this -> isContentField ( $ field ) || $ this -> isRevisionField ( $ field ) ) { throw new ReservedFieldNameException ( "The field '$field' cannot be used in '" . get_class ( $ this ) . "' as it is a reserved name" ) ; } $ type = $ settings [ 'type' ] ... | Validate configuration and prepare a FieldCollection |
47,274 | public function newRevision ( $ language_id = null ) { $ created = new static ( $ language_id ? : $ this -> language_id ) ; $ created -> content = $ this -> content ; return $ created ; } | Create a new revision based on the same content ID but without the content . Very useful if you want to add a new language |
47,275 | protected function setOnField ( FieldCollection $ field , $ value ) { if ( ! is_array ( $ value ) ) { if ( $ field -> getMaxItems ( ) != 1 ) { throw new MultipleFieldAssignmentException ( 'You cannot assign a value to replace a multiple field' ) ; } $ field -> offsetSet ( static :: $ SINGLE_ITEM_KEY , $ value ) ; retur... | Set values on a field |
47,276 | protected function getFieldTypes ( ) { return ( new Collection ( $ this -> getFields ( ) ) ) -> map ( function ( $ options ) { return $ options [ 'type' ] ; } ) -> values ( ) -> unique ( ) -> map ( function ( $ type ) { return self :: $ types [ $ type ] ; } ) ; } | Get all field types in this Entity . |
47,277 | protected static function findRevision ( $ id , $ language_id , $ revision_id = null ) { try { if ( is_numeric ( $ revision_id ) && $ revision_id != 0 ) { $ revision = Revision :: findOrFail ( $ revision_id ) ; if ( $ revision -> content_id != $ id ) { throw new RevisionEntityMismatchException ( "This revision doesn't ... | Find the requested Revision . |
47,278 | public static function find ( $ id , $ language_id , $ revision_id = null ) { $ instance = new static ( $ language_id ) ; try { $ instance -> content = Content :: findOrFail ( $ id ) ; } catch ( ModelNotFoundException $ e ) { throw new EntityNotFoundException ( "The entity with id '$id' doesn't exist" , 0 , $ e ) ; } $... | Find the latest valid revision for this entity |
47,279 | public function save ( $ newRevision = false , $ publishRevision = true ) { if ( $ newRevision ) { $ revision = new Revision ; $ revision -> language_id = $ this -> revision -> language_id ; $ this -> revision = $ revision ; } DB :: transaction ( function ( ) use ( $ newRevision , $ publishRevision ) { $ this -> saveCo... | Save a revision |
47,280 | protected function saveRevision ( $ publishRevision ) { if ( ! $ this -> revision -> exists && ! $ publishRevision ) { $ this -> revision -> published = $ publishRevision ; } $ this -> revision -> content_id = $ this -> content -> id ; $ this -> revision -> save ( ) ; if ( $ publishRevision ) { $ this -> unpublishOther... | Save the revision |
47,281 | protected function unpublishOtherRevisions ( ) { if ( $ this -> content -> wasRecentlyCreated ) { return ; } Revision :: where ( 'content_id' , $ this -> content -> id ) -> where ( 'language_id' , $ this -> revision -> language_id ) -> where ( 'id' , '!=' , $ this -> revision -> id ) -> update ( [ 'published' => false ... | Unpublish the revisions other than this one . Only for the same content_id and language_id |
47,282 | protected function saveField ( Field $ field , $ newRevision ) { if ( $ newRevision ) { $ field -> id = null ; $ field -> exists = false ; } $ field -> revision_id = $ this -> revision -> id ; $ field -> save ( ) ; } | Save a single field instance |
47,283 | public function toArray ( ) { $ content = [ 'id' => $ this -> content -> id , '_content' => $ this -> content -> toArray ( ) , '_revision' => $ this -> revision -> toArray ( ) , ] ; foreach ( $ this -> data as $ field => $ data ) { $ content [ $ field ] = $ data -> toArray ( ) ; } return $ content ; } | Convert the Entity to an array . |
47,284 | public function delete ( $ clear = true ) { $ revisions = Revision :: where ( 'content_id' , $ this -> content -> id ) -> get ( ) ; $ ids = $ revisions -> pluck ( 'id' ) ; $ this -> getFieldTypes ( ) -> each ( function ( $ type ) use ( $ ids ) { $ type :: whereIn ( 'revision_id' , $ ids ) -> delete ( ) ; } ) ; Revision... | Delete this entity and all the underlying Revisions . |
47,285 | public function deleteRevision ( $ clear = true ) { $ this -> getFieldTypes ( ) -> each ( function ( $ type ) { $ type :: where ( 'revision_id' , $ this -> revision -> id ) -> delete ( ) ; } ) ; if ( $ this -> revision -> published && $ this -> revision -> exists ) { Revision :: where ( 'content_id' , $ this -> content... | Delete the current revision . |
47,286 | protected function clearFields ( ) { foreach ( array_keys ( $ this -> data ) as $ fieldName ) { $ field = $ this -> data [ $ fieldName ] ; $ field -> clear ( ) ; $ field -> syncOriginal ( ) ; } } | Clear all the fields from their content |
47,287 | public function publishRevision ( ) { $ this -> revision -> published = true ; $ this -> revision -> save ( ) ; $ this -> unpublishOtherRevisions ( ) ; } | Publish the current revision and unpublish the other revisions of the same language . |
47,288 | public function dbtable ( $ dbtable = null ) { if ( true === isset ( $ this -> dbtable ) && null === $ dbtable ) { $ dbtable = $ this -> dbtable ; } if ( $ dbtable !== null && false === is_string ( $ dbtable ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __ME... | Loads and stores a new DBTable and returns it |
47,289 | protected function setDBTable ( $ dbtable ) { if ( false === is_string ( $ dbtable ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ dbtable ) ) , E_USER_ERROR ) ; } $ this -> dbtable = $ dbtable ; } | Set the dbtable |
47,290 | public function status ( ) { $ status = $ this -> getStatus ( ) ; if ( ! $ status ) { $ this -> writeln ( 'No migrations found.' ) ; return ; } $ this -> writeln ( ' Ran? Name ' ) ; $ this -> writeln ( '--------------' ) ; foreach ( $ status as $ row ) { if ( $ row [ 'migrated' ] ) { $ mark = $ this -> cli -> succes... | Output the migration status table |
47,291 | public function delete ( ) { if ( ! userHasPermission ( 'admin:blog:post:' . $ this -> blog -> id . ':delete' ) ) { unauthorised ( ) ; } $ iPostId = ( int ) $ this -> uri -> segment ( 6 ) ; $ oPost = $ this -> blog_post_model -> getById ( $ iPostId ) ; if ( ! $ oPost || $ oPost -> blog -> id != $ this -> blog -> id ) {... | Delete a blog post |
47,292 | public function restore ( ) { if ( ! userHasPermission ( 'admin:blog:post:' . $ this -> blog -> id . ':restore' ) ) { unauthorised ( ) ; } $ iPostId = ( int ) $ this -> uri -> segment ( 6 ) ; if ( $ this -> blog_post_model -> restore ( $ iPostId ) ) { $ oPost = $ this -> blog_post_model -> getById ( $ iPostId ) ; $ thi... | Restore a blog post |
47,293 | public function callbackValidAudioUrl ( $ sUrl ) { $ sId = $ this -> blog_post_model -> extractSpotifyId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ oFormValidation = Factory :: service ( 'FormValidation' ) ; $ oFormValidation -> set_message ( 'callbackValidAudioUrl' , 'Not a valid Spotify Track UR... | Form Validation callback checks that a Spotify ID can be extracted from the string |
47,294 | public function callbackValidVideoUrl ( $ sUrl ) { $ sId = $ this -> blog_post_model -> extractYoutubeId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ sId = $ this -> blog_post_model -> extractVimeoId ( $ sUrl ) ; if ( ! empty ( $ sId ) ) { return true ; } else { $ oFormValidation = Factory :: servic... | Form Validation callback checks that a YouTube or Vimeo ID can be extracted from the string |
47,295 | protected function validateType ( $ value ) { if ( ! is_array ( $ value ) && ( ! $ this -> allowFalse || false !== $ value ) ) { $ ex = new InvalidTypeException ( sprintf ( 'Invalid type for path "%s". Expected array, but got %s' , $ this -> getPath ( ) , gettype ( $ value ) ) ) ; if ( $ hint = $ this -> getInfo ( ) ) ... | Validates the type of the value . |
47,296 | public function getResourceEventName ( ResourceInterface $ resource , $ suffix ) { if ( null !== $ configuration = $ this -> registry -> findConfiguration ( $ resource , false ) ) { return sprintf ( '%s.%s' , $ configuration -> getResourceId ( ) , $ suffix ) ; } return null ; } | Returns the resource event name . |
47,297 | public function getDatabaseMetadata ( string $ databaseName ) : DatabaseMetadata { if ( ! array_key_exists ( $ databaseName , $ this -> databaseMetadataList ) ) { throw new \ RuntimeException ( 'Server "' . $ this -> host . '" doesn\'t contain database "' . $ databaseName . '"' ) ; } return $ this -> databaseMetadataLi... | Returns database metadata for the specified database . |
47,298 | public function configure ( ) { $ this -> setName ( $ this -> command ) ; $ this -> setDescription ( $ this -> description ) ; $ this -> arguments ( ) ; } | command interface configure |
47,299 | public function toMySQLDate ( $ withTime = true ) { if ( $ this -> isHollow ( ) ) { return $ withTime ? '0000-00-00 00:00:00' : '0000-00-00' ; } $ format = $ withTime ? 'Y-m-d H:i:s' : 'Y-m-d' ; return $ this -> format ( $ format ) ; } | Returns date in MySQL format . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.