idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
14,600
public function removeSkillRelatedByCompositeId ( ChildSkill $ skillRelatedByCompositeId ) { if ( $ this -> getSkillsRelatedByCompositeId ( ) -> contains ( $ skillRelatedByCompositeId ) ) { $ skillPart = new ChildSkillPart ( ) ; $ skillPart -> setSkillRelatedByCompositeId ( $ skillRelatedByCompositeId ) ; if ( $ skillRelatedByCompositeId -> isSkillRelatedByPartIdsLoaded ( ) ) { $ skillRelatedByCompositeId -> getSkillRelatedByPartIds ( ) -> removeObject ( $ this ) ; } $ skillPart -> setSkillRelatedByPartId ( $ this ) ; $ this -> removePart ( clone $ skillPart ) ; $ skillPart -> clear ( ) ; $ this -> collSkillsRelatedByCompositeId -> remove ( $ this -> collSkillsRelatedByCompositeId -> search ( $ skillRelatedByCompositeId ) ) ; if ( null === $ this -> skillsRelatedByCompositeIdScheduledForDeletion ) { $ this -> skillsRelatedByCompositeIdScheduledForDeletion = clone $ this -> collSkillsRelatedByCompositeId ; $ this -> skillsRelatedByCompositeIdScheduledForDeletion -> clear ( ) ; } $ this -> skillsRelatedByCompositeIdScheduledForDeletion -> push ( $ skillRelatedByCompositeId ) ; } return $ this ; }
Remove skillRelatedByCompositeId of this object through the kk_trixionary_skill_part cross reference table .
14,601
public function initSkillsRelatedByPartId ( ) { $ this -> collSkillsRelatedByPartId = new ObjectCollection ( ) ; $ this -> collSkillsRelatedByPartIdPartial = true ; $ this -> collSkillsRelatedByPartId -> setModel ( '\gossi\trixionary\model\Skill' ) ; }
Initializes the collSkillsRelatedByPartId crossRef collection .
14,602
public function removeSkillRelatedByPartId ( ChildSkill $ skillRelatedByPartId ) { if ( $ this -> getSkillsRelatedByPartId ( ) -> contains ( $ skillRelatedByPartId ) ) { $ skillPart = new ChildSkillPart ( ) ; $ skillPart -> setSkillRelatedByPartId ( $ skillRelatedByPartId ) ; if ( $ skillRelatedByPartId -> isSkillRelatedByCompositeIdsLoaded ( ) ) { $ skillRelatedByPartId -> getSkillRelatedByCompositeIds ( ) -> removeObject ( $ this ) ; } $ skillPart -> setSkillRelatedByCompositeId ( $ this ) ; $ this -> removeComposite ( clone $ skillPart ) ; $ skillPart -> clear ( ) ; $ this -> collSkillsRelatedByPartId -> remove ( $ this -> collSkillsRelatedByPartId -> search ( $ skillRelatedByPartId ) ) ; if ( null === $ this -> skillsRelatedByPartIdScheduledForDeletion ) { $ this -> skillsRelatedByPartIdScheduledForDeletion = clone $ this -> collSkillsRelatedByPartId ; $ this -> skillsRelatedByPartIdScheduledForDeletion -> clear ( ) ; } $ this -> skillsRelatedByPartIdScheduledForDeletion -> push ( $ skillRelatedByPartId ) ; } return $ this ; }
Remove skillRelatedByPartId of this object through the kk_trixionary_skill_part cross reference table .
14,603
public function initGroups ( ) { $ this -> collGroups = new ObjectCollection ( ) ; $ this -> collGroupsPartial = true ; $ this -> collGroups -> setModel ( '\gossi\trixionary\model\Group' ) ; }
Initializes the collGroups crossRef collection .
14,604
public function getGroups ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) ) { if ( null === $ this -> collGroups ) { $ this -> initGroups ( ) ; } } else { $ query = ChildGroupQuery :: create ( null , $ criteria ) -> filterBySkill ( $ this ) ; $ collGroups = $ query -> find ( $ con ) ; if ( null !== $ criteria ) { return $ collGroups ; } if ( $ partial && $ this -> collGroups ) { foreach ( $ this -> collGroups as $ obj ) { if ( ! $ collGroups -> contains ( $ obj ) ) { $ collGroups [ ] = $ obj ; } } } $ this -> collGroups = $ collGroups ; $ this -> collGroupsPartial = false ; } } return $ this -> collGroups ; }
Gets a collection of ChildGroup objects related by a many - to - many relationship to the current object by way of the kk_trixionary_skill_group cross - reference table .
14,605
public function countGroups ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collGroups ) { return 0 ; } else { if ( $ partial && ! $ criteria ) { return count ( $ this -> getGroups ( ) ) ; } $ query = ChildGroupQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterBySkill ( $ this ) -> count ( $ con ) ; } } else { return count ( $ this -> collGroups ) ; } }
Gets the number of Group objects related by a many - to - many relationship to the current object by way of the kk_trixionary_skill_group cross - reference table .
14,606
public function addGroup ( ChildGroup $ group ) { if ( $ this -> collGroups === null ) { $ this -> initGroups ( ) ; } if ( ! $ this -> getGroups ( ) -> contains ( $ group ) ) { $ this -> collGroups -> push ( $ group ) ; $ this -> doAddGroup ( $ group ) ; } return $ this ; }
Associate a ChildGroup to this object through the kk_trixionary_skill_group cross reference table .
14,607
public function removeGroup ( ChildGroup $ group ) { if ( $ this -> getGroups ( ) -> contains ( $ group ) ) { $ skillGroup = new ChildSkillGroup ( ) ; $ skillGroup -> setGroup ( $ group ) ; if ( $ group -> isSkillsLoaded ( ) ) { $ group -> getSkills ( ) -> removeObject ( $ this ) ; } $ skillGroup -> setSkill ( $ this ) ; $ this -> removeSkillGroup ( clone $ skillGroup ) ; $ skillGroup -> clear ( ) ; $ this -> collGroups -> remove ( $ this -> collGroups -> search ( $ group ) ) ; if ( null === $ this -> groupsScheduledForDeletion ) { $ this -> groupsScheduledForDeletion = clone $ this -> collGroups ; $ this -> groupsScheduledForDeletion -> clear ( ) ; } $ this -> groupsScheduledForDeletion -> push ( $ group ) ; } return $ this ; }
Remove group of this object through the kk_trixionary_skill_group cross reference table .
14,608
public function initReferences ( ) { $ this -> collReferences = new ObjectCollection ( ) ; $ this -> collReferencesPartial = true ; $ this -> collReferences -> setModel ( '\gossi\trixionary\model\Reference' ) ; }
Initializes the collReferences crossRef collection .
14,609
public function getReferences ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collReferencesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collReferences || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) ) { if ( null === $ this -> collReferences ) { $ this -> initReferences ( ) ; } } else { $ query = ChildReferenceQuery :: create ( null , $ criteria ) -> filterBySkill ( $ this ) ; $ collReferences = $ query -> find ( $ con ) ; if ( null !== $ criteria ) { return $ collReferences ; } if ( $ partial && $ this -> collReferences ) { foreach ( $ this -> collReferences as $ obj ) { if ( ! $ collReferences -> contains ( $ obj ) ) { $ collReferences [ ] = $ obj ; } } } $ this -> collReferences = $ collReferences ; $ this -> collReferencesPartial = false ; } } return $ this -> collReferences ; }
Gets a collection of ChildReference objects related by a many - to - many relationship to the current object by way of the kk_trixionary_skill_reference cross - reference table .
14,610
public function countReferences ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collReferencesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collReferences || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collReferences ) { return 0 ; } else { if ( $ partial && ! $ criteria ) { return count ( $ this -> getReferences ( ) ) ; } $ query = ChildReferenceQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterBySkill ( $ this ) -> count ( $ con ) ; } } else { return count ( $ this -> collReferences ) ; } }
Gets the number of Reference objects related by a many - to - many relationship to the current object by way of the kk_trixionary_skill_reference cross - reference table .
14,611
public function addReference ( ChildReference $ reference ) { if ( $ this -> collReferences === null ) { $ this -> initReferences ( ) ; } if ( ! $ this -> getReferences ( ) -> contains ( $ reference ) ) { $ this -> collReferences -> push ( $ reference ) ; $ this -> doAddReference ( $ reference ) ; } return $ this ; }
Associate a ChildReference to this object through the kk_trixionary_skill_reference cross reference table .
14,612
public function removeReference ( ChildReference $ reference ) { if ( $ this -> getReferences ( ) -> contains ( $ reference ) ) { $ skillReference = new ChildSkillReference ( ) ; $ skillReference -> setReference ( $ reference ) ; if ( $ reference -> isSkillsLoaded ( ) ) { $ reference -> getSkills ( ) -> removeObject ( $ this ) ; } $ skillReference -> setSkill ( $ this ) ; $ this -> removeSkillReference ( clone $ skillReference ) ; $ skillReference -> clear ( ) ; $ this -> collReferences -> remove ( $ this -> collReferences -> search ( $ reference ) ) ; if ( null === $ this -> referencesScheduledForDeletion ) { $ this -> referencesScheduledForDeletion = clone $ this -> collReferences ; $ this -> referencesScheduledForDeletion -> clear ( ) ; } $ this -> referencesScheduledForDeletion -> push ( $ reference ) ; } return $ this ; }
Remove reference of this object through the kk_trixionary_skill_reference cross reference table .
14,613
protected function updateRelatedObjectSkillCount ( ConnectionInterface $ con ) { if ( $ object = $ this -> getObject ( ) ) { $ object -> updateSkillCount ( $ con ) ; } if ( $ this -> oldObjectSkillCount ) { $ this -> oldObjectSkillCount -> updateSkillCount ( $ con ) ; $ this -> oldObjectSkillCount = null ; } }
Update the aggregate column in the related Object object
14,614
static function Plink_add ( & $ plpp , PHP_ParserGenerator_Config $ cfp ) { $ new = new PHP_ParserGenerator_PropagationLink ; $ new -> next = $ plpp ; $ plpp = $ new ; $ new -> cfp = $ cfp ; }
Add a propagation link to the current list
14,615
static function Plink_copy ( PHP_ParserGenerator_PropagationLink & $ to , PHP_ParserGenerator_PropagationLink $ from ) { while ( $ from ) { $ nextpl = $ from -> next ; $ from -> next = $ to ; $ to = $ from ; $ from = $ nextpl ; } }
Transfer every propagation link on the list from to the list to
14,616
static function Plink_delete ( $ plp ) { while ( $ plp ) { $ nextpl = $ plp -> next ; $ plp -> next = 0 ; $ plp = $ nextpl ; } }
Delete every propagation link on the list
14,617
public function setCacheStore ( $ store = "Default" ) { if ( $ store == "Default" ) { $ store = self :: $ config [ 'defaultStore' ] ; } if ( $ store == 'none' ) { $ this -> store = new CacheNone ( ) ; } else { $ config = self :: $ config [ 'stores' ] [ $ store ] ; switch ( $ config [ 'driver' ] ) { case 'file' : $ this -> store = new CacheFileSystem ( $ config [ 'folder' ] ) ; break ; case 'database' : $ this -> store = new CacheDataBase ( $ config [ 'connection' ] , $ config [ 'table' ] ) ; break ; case 'apc' : $ this -> store = new CacheApc ( ) ; break ; case 'memcached' : $ persistenceId = isset ( $ config [ 'persistenceId' ] ) ? $ config [ 'persistenceId' ] : NULL ; $ this -> store = new CacheMemCached ( $ config [ "servers" ] , $ persistenceId ) ; break ; case 'redis' : $ this -> store = new CacheRedis ( $ config [ 'schema' ] , $ config [ 'host' ] , $ config [ 'port' ] ) ; break ; default : \ Enola \ Error :: general_error ( "Cache Configuration" , "Driver specified unsupported" ) ; break ; } } }
Setea el driver indicado
14,618
public function start ( $ binary = null , $ conf = null ) { Log :: info ( 'LxMPD->start' , array ( $ binary , $ conf ) ) ; $ result = exec ( $ binary . ' ' . $ conf . ' 2>&1' , $ output , $ code ) ; Log :: info ( 'LxMPD->start - result' , array ( $ result ) ) ; Log :: info ( 'LxMPD->start - output' , array ( $ output ) ) ; Log :: info ( 'LxMPD->start - code' , array ( $ code ) ) ; return $ result ; }
Start up MPD .
14,619
public function authenticate ( ) { if ( ! $ this -> connection -> established ) { throw new MPDException ( 'The connection to MPD has not been established' , self :: MPD_CONNECTION_NOT_ESTABLISHED ) ; } if ( $ this -> connection -> hasPassword ( ) ) { if ( ! $ this -> password ( $ this -> connection -> password ) ) { $ this -> connection -> close ( ) ; throw new MPDException ( 'MPD did not like the provided password' , self :: MPD_BAD_PASSWORD ) ; } } else { $ this -> connection -> close ( ) ; throw new MPDException ( 'Must supply a password to authenticate to MPD' , self :: MPD_NO_PASSWORD ) ; } return true ; }
Authenticate to the MPD server
14,620
private function write ( $ data ) { if ( ! $ this -> connection -> established ) { Log :: info ( 'LxMPD connection is NOT established' , array ( $ data ) ) ; $ this -> connection -> establish ( ) ; } if ( ! fputs ( $ this -> connection -> socket , "$data\n" ) ) { Log :: info ( 'LxMPD write fputs seems to have failed writing to socket' , array ( $ data ) ) ; throw new MPDException ( 'Failed to write to MPD socket' , self :: MPD_WRITE_FAILED ) ; } return true ; }
Writes data to the MPD socket
14,621
private function read ( ) { if ( ! $ this -> connection -> established ) { $ this -> connection -> establish ( ) ; } $ response = array ( ) ; $ ok = false ; $ info = stream_get_meta_data ( $ this -> connection -> socket ) ; while ( ! feof ( $ this -> connection -> socket ) && ! $ info [ 'timed_out' ] ) { try { $ line = trim ( fgets ( $ this -> connection -> socket ) ) ; $ info = stream_get_meta_data ( $ this -> connection -> socket ) ; if ( empty ( $ line ) ) { continue ; } else if ( strcmp ( self :: MPD_OK , $ line ) == 0 ) { $ ok = true ; break ; } else if ( strncmp ( self :: MPD_ERROR , $ line , strlen ( self :: MPD_ERROR ) ) == 0 && preg_match ( '/^ACK \[(.*?)\@(.*?)\] \{(.*?)\} (.*?)$/' , $ line , $ matches ) ) { list ( $ constant , $ index , $ command , $ error ) = $ matches ; Log :: info ( 'LxMPD write constant' , array ( $ constant ) ) ; throw new MPDException ( 'Command failed: ' . $ error , self :: MPD_COMMAND_FAILED ) ; } else { $ response [ ] = $ line ; } } catch ( Exception $ e ) { Log :: info ( 'LxMPD->read : Exception occurred' , $ e ) ; } } if ( $ info [ 'timed_out' ] ) { $ this -> connection -> close ( ) ; throw new MPDException ( 'Command timed out' , self :: MPD_TIMEOUT ) ; } else { if ( ! count ( $ response ) ) { $ response = $ ok ; } return $ response ; } }
Reads data from the MPD socket
14,622
public function runCommand ( $ command , $ args = array ( ) , $ timeout = 86400 ) { if ( ! is_array ( $ args ) ) $ args = array ( $ args ) ; $ timeout = ( isset ( $ timeout ) ? intval ( $ timeout ) : $ this -> connection -> timeout ) ; $ toWrite = strval ( trim ( $ command ) ) ; if ( is_array ( $ args ) && ( count ( $ args ) > 0 ) ) { $ args = array_map ( function ( $ element ) { if ( is_array ( $ element ) ) { return array ( str_replace ( '"' , '\"' , current ( $ element ) ) ) ; } else { return str_replace ( '"' , '\"' , $ element ) ; } } , array_filter ( $ args , function ( $ element ) { return ! is_array ( $ element ) ; } ) ) ; if ( count ( $ args ) > 0 ) { $ toWrite .= ' "' . implode ( '" "' , $ args ) . '"' ; } } $ this -> write ( $ toWrite ) ; $ this -> connection -> setStreamTimeout ( $ timeout ) ; $ response = $ this -> read ( ) ; $ this -> connection -> setStreamTimeout ( $ timeout ) ; return $ this -> parse ( $ response , $ command , $ args ) ; }
Runs a given command with arguments
14,623
private function parse ( $ response , $ command = '' , $ args = array ( ) ) { $ parsed = array ( ) ; if ( is_bool ( $ response ) ) { if ( in_array ( $ command , $ this -> _responseShouldBeBoolean ) ) { return $ response ; } else { $ response = array ( ) ; } } if ( ! count ( $ response ) ) { return $ parsed ; } switch ( $ command ) { case 'list' : case 'listplaylist' : case 'listplaylists' : foreach ( $ response as $ line ) { preg_match ( '/(.*?):\s(.*)/' , $ line , $ matches ) ; if ( count ( $ matches ) != 3 ) { continue ; } list ( $ subject , $ key , $ value ) = $ matches ; if ( $ command == "listplaylists" ) { if ( $ key == "playlist" ) { $ parsed [ ] = $ value ; } } else { $ parsed [ ] = $ value ; } } return $ parsed ; break ; default : $ items = array ( ) ; foreach ( $ response as $ line ) { preg_match ( '/(.*?):\s(.*)/' , $ line , $ matches ) ; list ( $ subject , $ key , $ value ) = $ matches ; if ( array_key_exists ( $ key , $ items ) ) { $ parsed [ ] = $ items ; $ items = array ( $ key => $ value ) ; } else { $ items [ $ key ] = $ value ; } } if ( in_array ( $ command , $ this -> _expectArrayOutput ) ) { $ parsed [ ] = $ items ; } else { $ parsed = $ items ; } if ( in_array ( $ command , $ this -> _outputContainsTracks ) ) { if ( $ this -> _tagFiltering ) { $ parsed = $ this -> filterOutUnwantedTags ( $ parsed ) ; } if ( $ this -> _throwMissingTagExceptions ) { $ this -> reportOnMissingTags ( $ command , $ parsed ) ; } } return $ parsed ; break ; } return false ; }
Parses an array of output lines from MPD into a common array format
14,624
public function reportOnMissingTags ( $ command , $ tracks ) { $ essentialTags = $ this -> getEssentialTags ( ) ; $ incompleteTracks = array_filter ( array_map ( function ( $ track ) use ( $ essentialTags ) { $ missingTags = array_flip ( array_diff_key ( array_flip ( $ essentialTags ) , $ track ) ) ; return ( count ( $ missingTags ) ? ( array ( $ track [ 'Id' ] => $ missingTags ) ) : array ( ) ) ; } , $ tracks ) , function ( $ missing ) { return ( count ( $ missing ) ) ; } ) ; if ( count ( $ incompleteTracks ) ) { $ detailedMessage = "" ; foreach ( $ incompleteTracks as $ incompleteTrack ) { $ id = key ( $ incompleteTrack ) ; $ track = $ this -> playlistid ( $ id ) ; $ artist = $ track [ 'Artist' ] ; $ album = $ track [ 'Album' ] ; $ detailedMessage .= "Track #" . $ id . " from the artist '" . $ artist . ",' specifically, the album '" . $ album . "', is missing tag" . ( ( count ( $ incompleteTrack ) > 1 ) ? "s: " : ": " ) . implode ( ", " , current ( $ incompleteTrack ) ) . ". " ; } throw new MPDException ( 'The command "' . $ command . '" has retrieved some tracks that are missing essential tag elements. Please clean up any deficient id3 tags and try again. The essentials tags are as follows: ' . implode ( ", " , $ essentialID3Tags ) . '. Details: ' . $ detailedMessage , self :: ESSENTIAL_TAGS_MISSING ) ; } }
reportOnMissingTags will find any tracks that are missing essentials tags and throws an exception that contains enough information to track down the missing tags so the user can fill them in with the id3 editor of their choice
14,625
public function handleAttempt ( $ executeNow , $ username , $ password , $ toRoute ) { if ( $ executeNow ) { try { if ( $ this -> attempt ( $ username , $ password ) ) { Base :: instance ( ) -> reroute ( $ toRoute ) ; } } catch ( Exception $ e ) { return $ e -> getMessage ( ) ; } } return null ; }
Handle authentication attempt
14,626
public static function safeCreateDateTimeZone ( $ timezone ) { if ( $ timezone === null ) { return new DateTimeZone ( date_default_timezone_get ( ) ) ; } if ( $ timezone instanceof DateTimeZone ) { return $ timezone ; } $ tz = @ timezone_open ( ( string ) $ timezone ) ; if ( $ tz === false ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Unknown or bad timezone (%s)' , is_scalar ( $ timezone ) ? $ timezone : gettype ( $ timezone ) ) ) ; } return $ tz ; }
Creates a DateTimeZone from a string or a DateTimeZone .
14,627
public function hug ( Huggable $ huggable ) { if ( ! in_array ( $ huggable , $ this -> hugged ) ) { $ this -> hugged [ ] = $ huggable ; $ huggable -> hug ( $ this ) ; } }
Hugs this object .
14,628
protected function readVersionFromLocation ( string $ location , string $ package ) : ? string { $ installed = $ this -> getInstalledPackages ( $ location ) ; if ( empty ( $ installed ) ) { return null ; } foreach ( $ installed as $ installedPackage ) { $ version = $ this -> readFromSource ( $ installedPackage , $ package ) ; if ( isset ( $ version ) ) { return $ version ; } } return null ; }
Attempts to read the version from the given location
14,629
protected function readFromSource ( array $ source , string $ package ) : ? string { if ( ! isset ( $ source [ 'name' ] ) ) { return null ; } if ( $ source [ 'name' ] != $ package ) { return null ; } if ( isset ( $ source [ 'version' ] ) ) { return $ source [ 'version' ] ; } if ( isset ( $ source [ 'extra' ] [ 'branch-alias' ] [ 'dev-master' ] ) ) { return $ source [ 'extra' ] [ 'branch-alias' ] [ 'dev-master' ] ; } return self :: DEFAULT_VERSION ; }
Attempts to read a version property on the source and return it .
14,630
protected function getInstalledPackages ( string $ location ) : array { if ( isset ( $ this -> installedPackages [ $ location ] ) ) { return $ this -> installedPackages [ $ location ] ; } $ installedFile = $ location . 'installed.json' ; if ( ! file_exists ( $ installedFile ) ) { return [ ] ; } return $ this -> installedPackages [ $ location ] = $ this -> loadJsonFile ( $ installedFile ) ; }
Returns the installed packages found at the given location
14,631
public function setImageWidth ( $ width ) { $ this -> imageWidth = empty ( $ width ) ? null : ( int ) $ width ; return $ this ; }
Set image width attribute
14,632
public function setImageHeight ( $ height ) { $ this -> imageHeight = empty ( $ height ) ? null : ( int ) $ height ; return $ this ; }
Set image height attribute
14,633
public function setRootImage ( $ value ) { $ content = $ this -> getDependentContent ( ) ; if ( $ content ) { $ content -> leadImage = $ value ; } return $ this ; }
Set root s lead - image
14,634
public function setRootText ( $ value ) { $ content = $ this -> getDependentContent ( ) ; if ( $ content ) { $ content -> leadText = $ value ; } return $ this ; }
Set root s lead - text
14,635
public function addDriver ( DriverInterface $ driver , $ namespace ) { if ( ! isset ( $ this -> drivers [ $ namespace ] ) ) $ this -> drivers [ $ namespace ] = array ( ) ; $ this -> drivers [ $ namespace ] [ ] = $ driver ; return $ this ; }
Add new driver to the chain
14,636
protected static function getPageRange ( ) { $ currentPage = static :: $ pagination -> getPage ( ) ; $ pageCount = static :: $ pagination -> getPageCount ( ) ; $ beginPage = max ( 0 , $ currentPage - ( int ) ( static :: $ params [ 'maxButtonCount' ] / 2 ) ) ; if ( ( $ endPage = $ beginPage + static :: $ params [ 'maxButtonCount' ] - 1 ) >= $ pageCount ) { $ endPage = $ pageCount - 1 ; $ beginPage = max ( 0 , $ endPage - static :: $ params [ 'maxButtonCount' ] + 1 ) ; } return [ $ beginPage , $ endPage ] ; }
Get a pagination range
14,637
protected static function buildPageItem ( $ label , $ page , $ class , $ disabled , $ active ) { $ classes = [ $ class ] ; if ( $ active ) { $ classes [ ] = static :: $ params [ 'activePageCssClass' ] ; } if ( $ disabled ) { $ classes [ ] = static :: $ params [ 'disabledPageCssClass' ] ; } return [ 'label' => $ label , 'url' => static :: $ pagination -> createUrl ( $ page ) , 'class' => implode ( ' ' , $ classes ) , ] ; }
Build a page link array
14,638
public static function register ( LoggerInterface $ logger = null , $ cfg = null ) { self :: $ registered = true ; $ class = get_called_class ( ) ; $ handler = new $ class ( $ logger , $ cfg ) ; register_shutdown_function ( [ $ handler , 'handle' ] ) ; self :: $ lastRegisteredHandler = & $ handler ; return $ handler ; }
Registers the shutdown handler
14,639
public function handle ( ) { if ( ErrorHandler :: isRegistered ( ) ) { $ e = new Error ( error_get_last ( ) ) ; if ( Error :: shouldBeReported ( $ e -> getType ( ) ) ) { $ r = ErrorHandler :: getLastReportedError ( ) ; $ h = ErrorHandler :: getLastRegisteredHandler ( ) ; if ( ! $ e -> isEmpty ( ) && $ h && ( $ r ? ! $ r -> isEmpty ( ) && ! $ r -> equals ( $ e ) : true ) ) { $ h -> handle ( $ e -> getType ( ) , Alo :: ifnull ( $ e -> getMessage ( ) , '<<unknown error>>' ) , Alo :: ifnull ( $ e -> getFile ( ) , '<<unknown file>>' ) , Alo :: ifnull ( $ e -> getLine ( ) , '<<unknown line>>' ) ) ; } } } }
The shutdown handler
14,640
public function match ( Expression $ expr ) { return $ expr -> evaluate ( array ( self :: NAME => $ this -> name , self :: INSTALLER_NAME => $ this -> installerName , self :: LOCATION => $ this -> location , self :: URL_FORMAT => $ this -> urlFormat , self :: PARAMETER_VALUES => $ this -> parameterValues , ) ) ; }
Returns whether the target matches the given expression .
14,641
public function save ( $ data = null ) { if ( ! is_null ( $ data ) ) { if ( ! $ this -> bindData ( $ data ) ) { return false ; } } $ primary = $ this -> keys ( ) ; if ( isset ( $ primary -> Value ) && ! empty ( $ primary -> Value ) ) { return $ this -> update ( $ primary -> Value ) ; } else { return $ this -> insert ( ) ; } return false ; }
Saves changes to the database
14,642
public function keys ( $ type = 'primary' , $ limit = 1 ) { $ valid = array ( "primary" => 'PRI' , "unique" => 'UNI' , "multiple" => 'MUL' ) ; if ( empty ( $ this -> schema ) || ! array_key_exists ( $ type , $ valid ) ) { return array ( ) ; } $ keys = array ( ) ; $ i = 0 ; foreach ( $ this -> schema as $ field => $ schema ) { if ( $ limit > 0 && $ i >= $ limit ) break ; if ( strval ( $ schema -> Key ) == $ valid [ $ type ] ) { $ keys [ $ field ] = $ schema ; } $ i ++ ; } $ return = ( array ) $ keys ; if ( $ limit === 1 && ! empty ( $ return ) ) { $ fieldname = array_keys ( $ return ) ; $ return = $ return [ $ fieldname [ 0 ] ] ; } return $ return ; }
Returns all fields corresponding to the key type
14,643
public function update ( $ key , $ data = null ) { if ( ! is_null ( $ data ) ) { if ( ! $ this -> bindData ( $ data ) ) { return false ; } } }
Updates the database table field value
14,644
public function insert ( $ data = null , $ updateIfExists = FALSE ) { if ( ! is_null ( $ data ) ) { if ( ! $ this -> bindData ( $ data ) ) { return false ; } } $ primary = $ this -> keys ( "primary" ) ; $ set = array ( ) ; foreach ( $ this -> schema as $ field => $ fieldObject ) { if ( $ field === $ primary -> Field ) continue ; $ set [ $ field ] = isset ( $ fieldObject -> Value ) ? $ fieldObject -> Value : $ fieldObject -> Default ; if ( empty ( $ set [ $ field ] ) || ( isset ( $ fieldObject -> Validate ) && $ fieldObject -> Validate == 'string' ) ) { $ set [ $ field ] = $ this -> dbo -> Quote ( $ set [ $ field ] ) ; } } if ( $ updateIfExists ) : $ unique = $ primary -> Field ; if ( empty ( $ unique ) ) { $ updateIfExists = FALSE ; } endif ; return $ this -> dbo -> insert ( $ this -> getTableName ( ) , $ set , $ updateIfExists , $ unique ) ; }
Inserts a new record to the database
14,645
public function describe ( ) { $ sql = 'DESCRIBE ' . $ this -> name ; $ schema = $ this -> dbo -> prepare ( $ sql ) -> execute ( ) ; while ( $ row = $ schema -> fetchObject ( ) ) { if ( preg_match ( '/unsigned/' , $ row -> Type ) ) { $ row -> Unsigned = true ; } if ( preg_match ( '/^((?:var)?char)\((\d+)\)/' , $ row -> Type , $ matches ) ) { $ row -> Validate = 'string' ; $ row -> Length = $ matches [ 2 ] ; } else if ( preg_match ( '/^decimal\((\d+),(\d+)\)/' , $ row -> Type , $ matches ) ) { $ row -> Validate = 'decimal' ; $ row -> Precission = $ matches [ 1 ] ; $ row -> Scale = $ matches [ 2 ] ; } else if ( preg_match ( '/^float\((\d+),(\d+)\)/' , $ row -> Type , $ matches ) ) { $ row -> Validate = 'float' ; $ row -> Precission = $ matches [ 1 ] ; $ row -> Scale = $ matches [ 2 ] ; } else if ( preg_match ( '/^((?:big|medium|small|tiny)?int)\((\d+)\)/' , $ row -> Type , $ matches ) ) { $ row -> Validate = 'interger' ; $ row -> Length = $ matches [ 2 ] ; } if ( strtoupper ( $ row -> Key ) == 'PRI' ) { $ row -> Primary = true ; if ( $ row -> Extra == 'auto_increment' ) { $ row -> Identity = true ; } else { $ row -> Identity = false ; } } if ( strtoupper ( $ row -> Null ) == 'NO' ) { $ row -> Null = 0 ; } else { $ row -> Null = 1 ; } $ this -> schema [ $ row -> Field ] = $ row ; } return true ; }
Describes a table on load
14,646
public static function add ( $ name , array $ options ) { if ( array_key_exists ( $ name , self :: $ _auths ) ) { throw new \ Exception ( "There is already a Auth defined for '$name'." , 1 ) ; } $ auth = new Auth ( $ name , $ options ) ; self :: $ _auths [ $ name ] = $ auth ; return $ auth ; }
Add a new authentication to the framework
14,647
public static function get ( $ name ) { if ( array_key_exists ( $ name , self :: $ _auths ) ) { return self :: $ _auths [ $ name ] ; } else { throw new \ Exception ( "There is no Auth defined for '$name'." , 1 ) ; } }
Retrieve a previously defined Auth by its name
14,648
public function login ( $ username , $ password ) { $ result = $ this -> validate ( $ username , $ password ) ; $ this -> _result = $ result ; if ( $ result -> success ) { $ storeObject = array ( 'username' => $ username , 'password' => $ result -> user -> readAttribute ( $ this -> _passwordField ) ) ; $ _SESSION [ self :: $ _sessionPrefix . $ this -> name ] = $ storeObject ; $ this -> _authenticated = true ; $ this -> _user = $ result -> user ; $ llField = $ this -> _lastloginField ; $ this -> user -> $ llField = new \ ActiveRecord \ DateTime ( ) ; $ this -> user -> save ( ) ; } return $ result ; }
Validate the given username and password and store the session is authentication is successful .
14,649
public function logout ( ) { if ( $ this -> isAuthenticated ( ) == false ) { return false ; } $ this -> _authenticated = false ; unset ( $ _SESSION [ self :: $ _sessionPrefix . $ this -> name ] ) ; $ this -> _user = null ; return true ; }
Log out current user
14,650
public function validate ( $ username , $ password ) { $ originalPassword = $ password ; $ this -> _initModel ( ) ; $ modelName = $ this -> _model ; $ user = $ modelName :: find ( "first" , array ( $ this -> _usernameField => $ username ) ) ; if ( is_null ( $ user ) ) { return new AuthResult ( AuthResult :: USER_NOT_FOUND ) ; } if ( $ this -> _useSalt ) { $ password = $ user -> readAttribute ( $ this -> _saltField ) . $ password ; } $ loginSuccess = false ; $ serverPassword = $ user -> readAttribute ( $ this -> _passwordField ) ; switch ( $ this -> _type ) { case self :: MD5 : $ loginSuccess = md5 ( $ password ) == $ serverPassword ; break ; case self :: BLOWFISH : $ hasher = new PasswordHash ( 8 , false ) ; $ loginSuccess = $ hasher -> CheckPassword ( $ password , $ serverPassword ) ; break ; default : throw new \ Exception ( "Unknown encryption: " . $ this -> _type , 1 ) ; break ; } if ( ! $ loginSuccess ) { return new AuthResult ( AuthResult :: INCORRECT_PASSWORD ) ; } else { if ( $ this -> _rotateSalt ) { $ user -> resaltPassword ( $ originalPassword ) ; $ user -> Save ( ) ; } return new AuthResult ( AuthResult :: SUCCESS , $ user ) ; } }
Validate the given username and password .
14,651
public function createLoginForm ( $ options = array ( ) ) { $ options = array_merge ( array ( "action" => $ this -> loginUri , "method" => "post" ) , $ options ) ; $ form = new Form ( $ options ) ; return $ form ; }
Create a Form object with preset options for this Auth
14,652
public function isAuthenticated ( ) { if ( $ this -> _authenticated ) return true ; if ( array_key_exists ( self :: $ _sessionPrefix . $ this -> _name , $ _SESSION ) ) { $ cred = $ _SESSION [ self :: $ _sessionPrefix . $ this -> _name ] ; $ this -> _initModel ( ) ; $ modelName = $ this -> _model ; $ user = $ modelName :: find ( "first" , array ( $ this -> _usernameField => $ cred [ 'username' ] , $ this -> _passwordField => $ cred [ 'password' ] ) ) ; if ( is_null ( $ user ) ) { return false ; } $ this -> _result = new AuthResult ( AuthResult :: SUCCESS , $ user ) ; $ this -> _authenticated = true ; $ this -> _user = $ user ; return true ; } return false ; }
Check if the current session is authenticated for this Auth instance
14,653
public function registerScheme ( AuthenticationScheme $ scheme , $ name = null ) { $ this -> schemes [ $ name ? : $ scheme -> getName ( ) ] = $ scheme ; }
Add authentication scheme
14,654
public function setDefaultScheme ( $ scheme = null ) { if ( $ scheme === null ) { $ this -> defaultScheme = null ; } else { $ this -> checkScheme ( $ scheme ) ; $ this -> defaultScheme = $ scheme ; } }
Set default scheme
14,655
public function createCredentialsHeader ( HttpRequest $ request , $ scheme , $ username , $ secretKey ) { $ value = $ this -> getScheme ( $ scheme ) -> createRequestHeaderValue ( $ request , $ username , $ secretKey ) ; return new HttpHeader ( $ this -> credentialsHeader , $ scheme . ' ' . $ value ) ; }
Create auth credentials header for client request
14,656
public function parseRequest ( HttpRequest $ request ) { foreach ( $ request -> getHeaders ( ) as $ name => $ value ) { if ( $ name === $ this -> credentialsHeader ) { if ( ! preg_match ( self :: HEADER_REGEX , $ value , $ matches ) ) { throw new WrongSchemeHeaderException ( $ this -> credentialsHeader , sprintf ( 'Value does not match "%s"' , self :: HEADER_REGEX ) ) ; } try { $ token = $ this -> getScheme ( $ matches [ 1 ] ) -> parseHeaderValue ( $ matches [ 2 ] ) ; } catch ( WrongHeaderValueException $ e ) { throw new WrongSchemeHeaderException ( $ this -> credentialsHeader , 'Wrong scheme header value' , $ matches [ 1 ] , $ e ) ; } return new AuthenticationData ( $ matches [ 1 ] , $ token ) ; } } throw new HeaderNotFoundException ( $ this -> credentialsHeader ) ; }
Parse request authentication data
14,657
public function isRequestValid ( HttpRequest $ request , AuthenticationData $ data , $ secretKey ) { return $ this -> getScheme ( $ data -> getScheme ( ) ) -> isRequestValid ( $ request , $ data -> getToken ( ) , $ secretKey ) ; }
Check if request is valid for user
14,658
public function createSchemeHeader ( $ scheme ) { $ schemeObj = $ this -> getScheme ( $ scheme ) ; $ value = $ schemeObj -> createResponseHeaderValue ( ) ; return new HttpHeader ( $ this -> schemeHeader , trim ( $ scheme . ' ' . $ value ) ) ; }
Create header for client notification about scheme
14,659
public function createMultiSchemeHeader ( ) { $ headers = [ ] ; foreach ( $ this -> schemes as $ name => $ scheme ) { $ headers [ $ name ] = $ scheme -> createResponseHeaderValue ( ) ; } return new HttpHeader ( $ this -> schemeHeader , sprintf ( '%s %s' , implode ( '|' , array_keys ( $ headers ) ) , implode ( '|' , array_values ( $ headers ) ) ) ) ; }
Create header for client notification about all supported schemes
14,660
static function getMethodAnnotations ( $ method , $ class = NULL ) { $ method instanceof ReflectionMethod or $ method = new ReflectionMethod ( $ class , $ method ) ; return static :: instance ( ) -> getMethodAnnotations ( $ method ) ; }
Get method annotations
14,661
static function getMethodAnnotation ( $ method , $ annotationName , $ class = NULL ) { $ method instanceof ReflectionMethod or $ method = new ReflectionMethod ( $ class , $ method ) ; return static :: instance ( ) -> getMethodAnnotation ( $ method , $ annotationName ) ; }
Get method annotation
14,662
static function annotationClass ( $ name ) { if ( ! AnnotationRegistry :: loadAnnotationClass ( $ name ) ) { throw new \ Doctrine \ Common \ Annotations \ AnnotationException ( 'Annotation ' . $ name . ' - not exists' ) ; } return new $ name ; }
Get annotation object
14,663
public function decode ( array $ options = [ ] ) { $ options = array_merge ( [ 'exceptionOnInvalidType' => false , 'objectSupport' => false , 'objectForMap' => false ] , $ options ) ; return SymfonyYaml :: parse ( $ this -> getContents ( ) , $ options [ 'exceptionOnInvalidType' ] , $ options [ 'objectSupport' ] , $ options [ 'objectForMap' ] ) ; }
Decodes Yaml data .
14,664
public function encode ( array $ options = [ ] ) { $ options = array_merge ( [ 'inline' => 2 , 'indent' => 4 , 'exceptionOnInvalidType' => false , 'objectSupport' => false ] , $ options ) ; return SymfonyYaml :: dump ( $ this -> getContents ( ) , $ options [ 'inline' ] , $ options [ 'indent' ] , $ options [ 'exceptionOnInvalidType' ] , $ options [ 'objectSupport' ] ) ; }
Encodes data in Yaml format .
14,665
public function pathInBase ( $ filename ) { $ filename = str_replace ( '\\' , '/' , $ filename ) ; $ path_root = str_replace ( '\\' , '/' , base_path ( ) . '/' ) ; return str_replace ( $ path_root , '' , $ filename ) ; }
Remove path base of filename
14,666
public function combine ( $ path1 , $ path2 , $ div = '/' ) { $ path1 .= ( ( $ path1 [ strlen ( $ path1 ) - 1 ] != $ div ) ? $ div : '' ) ; return $ path1 . $ path2 ; }
Combine two paths
14,667
public function rename ( $ filename , $ newname , $ try_another_name = false ) { if ( $ try_another_name ) { $ file_mask = preg_replace ( '/(.[a-zA-Z0-9]+)$/' , '_%s\1' , $ filename ) ; $ contador = 1 ; while ( $ this -> exists ( $ newname ) ) { $ newname = sprintf ( $ file_mask , $ contador ) ; $ contador += 1 ; } } $ this -> copy ( $ filename , $ newname ) ; $ this -> delete ( $ filename ) ; return $ newname ; }
Rename file with option of make new filename
14,668
public function synchronize ( $ fromPath , $ toPath , $ renames = array ( ) ) { if ( ! $ this -> isDirectory ( $ fromPath ) ) return false ; if ( ! $ this -> isDirectory ( $ toPath ) ) $ this -> makeDirectory ( $ toPath , 0777 , true ) ; $ items = new \ FilesystemIterator ( $ fromPath , \ FilesystemIterator :: SKIP_DOTS ) ; foreach ( $ items as $ item ) { $ target = $ toPath . '/' . $ item -> getBasename ( ) ; if ( $ item -> isDir ( ) ) { $ path = $ item -> getPathname ( ) ; if ( ! $ this -> synchronize ( $ path , $ target , $ renames ) ) return false ; } else { foreach ( $ renames as $ old => $ new ) $ target = str_replace ( $ old , $ new , $ target ) ; if ( $ this -> exists ( $ target ) ) { $ hash_file = md5_file ( $ item -> getPathname ( ) ) ; $ hash_dest = md5_file ( $ target ) ; if ( $ hash_file != $ hash_dest ) { if ( ! $ this -> copy ( $ item -> getPathname ( ) , $ target ) ) return false ; } } else { if ( ! $ this -> copy ( $ item -> getPathname ( ) , $ target ) ) return false ; } } } return true ; }
Synchronize from path with to path
14,669
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ snippetHelper = new SnippetHelper ( ) ; $ serviceManager = $ serviceLocator ; if ( $ serviceManager instanceof HelperPluginManager ) { $ serviceManager = $ serviceManager -> getServiceLocator ( ) ; } if ( ! $ serviceManager -> has ( 'Config' ) ) { return $ snippetHelper ; } $ config = $ serviceManager -> get ( 'Config' ) ; $ snippetsConfig = isset ( $ config [ $ this -> configKey ] ) ? $ config [ $ this -> configKey ] : [ ] ; if ( ! isset ( $ snippetsConfig [ 'snippets' ] ) ) { return $ snippetHelper ; } $ snippets = $ snippetsConfig [ 'snippets' ] ; if ( ! is_array ( $ snippets ) ) { return $ snippetHelper ; } return $ this -> configureSnippetHelper ( $ snippetHelper , $ config , $ snippetsConfig ) ; }
Create an appender helper service
14,670
protected function configureSnippetHelper ( SnippetHelper $ snippetHelper , array $ config , array $ snippetsConfig ) { $ enableAll = isset ( $ snippetsConfig [ 'enable_all' ] ) ? ( bool ) $ snippetsConfig [ 'enable_all' ] : true ; foreach ( $ snippetsConfig [ 'snippets' ] as $ name => $ snippetsConfig ) { $ values = [ ] ; if ( isset ( $ snippetsConfig [ 'config_key' ] ) && isset ( $ config [ $ snippetsConfig [ 'config_key' ] ] ) ) { $ values = $ config [ $ snippetsConfig [ 'config_key' ] ] ; } if ( isset ( $ snippetsConfig [ 'values' ] ) ) { $ values = array_merge_recursive ( $ values , $ snippetsConfig [ 'values' ] ) ; } $ snippetHelper -> appendSnippet ( $ name , isset ( $ snippetsConfig [ 'template' ] ) ? $ snippetsConfig [ 'template' ] : 'hanger-snippet/' . $ name , $ values , isset ( $ snippetsConfig [ 'placement' ] ) ? $ snippetsConfig [ 'placement' ] : null , isset ( $ snippetsConfig [ 'enabled' ] ) ? $ snippetsConfig [ 'enabled' ] : $ enableAll ) ; } return $ snippetHelper ; }
Configure Snippet Helper
14,671
protected function getProcessedForm ( Request $ request , $ action = 'POST' , $ resource = array ( ) , $ options = array ( ) ) { $ formType = $ this -> getResourceFormType ( $ action , $ resource , $ options ) ; $ formBuilder = $ this -> createFormBuilder ( $ resource , $ options ) ; $ formType -> configureFormBuilder ( $ formBuilder , $ options ) ; $ form = $ formBuilder -> getForm ( ) ; $ form -> handleRequest ( $ request ) ; $ formType -> validateForm ( $ form ) ; return $ form ; }
Get a processed and validated form
14,672
protected function processPost ( Request $ request ) { $ resource = $ this -> getResourceManager ( ) -> createNewInstance ( ) ; return $ this -> processAction ( $ request , 'POST' , $ resource ) ; }
Create a new Resource .
14,673
public function listAction ( Request $ request ) { $ this -> checkAccess ( 'LIST' , null ) ; $ resources = $ this -> getResourceManager ( ) -> findAll ( ) ; $ view = $ this -> view ( $ resources , \ FOS \ RestBundle \ Util \ Codes :: HTTP_OK ) ; return $ this -> handleView ( $ view ) ; }
List all resources .
14,674
public function getAction ( Request $ request , $ id ) { $ this -> checkAccess ( 'GET' , $ id ) ; $ resource = $ this -> getResourceManager ( ) -> find ( $ id ) ; $ view = $ this -> view ( $ resource , \ FOS \ RestBundle \ Util \ Codes :: HTTP_OK ) ; return $ this -> handleView ( $ view ) ; }
Gets a resource for a given id .
14,675
public function putAction ( Request $ request , $ id ) { $ this -> checkAccess ( 'PUT' , $ id ) ; $ resource = $ this -> getResourceManager ( ) -> find ( $ id ) ; return $ this -> processPut ( $ request , $ resource ) ; }
Update a Resource from the submitted data .
14,676
public function patchAction ( Request $ request , $ id ) { $ this -> checkAccess ( 'PATCH' , $ id ) ; $ resource = $ this -> getResourceManager ( ) -> find ( $ id ) ; return $ this -> processPatch ( $ request , $ resource ) ; }
Update partially a Resource from the submitted data .
14,677
public function validate ( $ subject ) : bool { if ( \ is_array ( $ this -> schema [ 'properties' ] ) ) { foreach ( $ this -> schema [ 'properties' ] as $ propertyName => $ propertySchema ) { if ( isset ( $ subject [ $ propertyName ] ) ) { $ nodeValidator = new NodeValidator ( $ propertySchema , $ this -> rootSchema ) ; if ( ! $ nodeValidator -> validate ( $ subject [ $ propertyName ] ) ) { return false ; } } } } return true ; }
Validates subject against properties
14,678
public function getResolver ( ) { if ( $ this -> resolver === null ) { $ this -> resolver = new $ this -> resolverClass ( UrlRedirect :: resolve ( $ this -> buildUrl ( ) ) , $ this -> resolverConfig ) ; $ this -> parseUrl ( $ this -> resolver -> getUrl ( ) ) ; } return $ this -> resolver ; }
Returns the current resolver It also create a new resolver if it s not exists
14,679
public function getHtmlContent ( ) { if ( $ this -> htmlContent === null ) { try { if ( ( $ content = $ this -> getContent ( ) ) === '' ) { return $ this -> htmlContent = false ; } $ errors = libxml_use_internal_errors ( true ) ; $ this -> htmlContent = new \ DOMDocument ( ) ; if ( ( mb_detect_encoding ( $ content ) === 'UTF-8' ) && mb_check_encoding ( $ content , 'UTF-8' ) ) { $ content = mb_convert_encoding ( $ content , 'HTML-ENTITIES' , 'UTF-8' ) ; $ content = preg_replace ( '/<head[^>]*>/' , '<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">' , $ content ) ; } $ this -> htmlContent -> loadHTML ( $ content ) ; libxml_use_internal_errors ( $ errors ) ; } catch ( \ Exception $ E ) { return $ this -> htmlContent = false ; } } return $ this -> htmlContent ; }
Get the content of the url as a DOMDocument object
14,680
public function getJsonContent ( ) { if ( $ this -> jsonContent === null ) { try { if ( ( $ content = $ this -> getContent ( ) ) === '' ) { return $ this -> jsonContent = false ; } $ this -> jsonContent = json_decode ( $ content , true ) ; } catch ( \ Exception $ E ) { return $ this -> jsonContent = false ; } } return $ this -> jsonContent ; }
Get the content of the url as an array from json
14,681
public function getXMLContent ( ) { if ( $ this -> xmlContent === null ) { try { if ( ( $ content = $ this -> getContent ( ) ) === '' ) { return $ this -> xmlContent = false ; } $ errors = libxml_use_internal_errors ( true ) ; $ this -> xmlContent = new \ SimpleXMLElement ( $ content ) ; libxml_use_internal_errors ( $ errors ) ; } catch ( \ Exception $ E ) { return $ this -> xmlContent = false ; } } return $ this -> xmlContent ; }
Get the content of the url as an XML element
14,682
public function isValid ( array $ validCodes = null ) { if ( $ validCodes === null ) { return $ this -> getHttpCode ( ) === 200 ; } return in_array ( $ this -> getHttpCode ( ) , $ validCodes , true ) ; }
Check if the response is valid or not
14,683
public function get ( $ alias ) { if ( false === $ this -> has ( $ alias ) ) { throw new DataSetTransformerNotFoundException ( $ alias ) ; } return $ this -> items [ $ alias ] ; }
Returns a dataset s transformer by its alias
14,684
private function expired ( $ cacheId ) { $ item = $ this -> cachedItems [ $ cacheId ] ; return ( ! $ this -> storage -> exists ( $ cacheId ) ) || $ this -> timeUtil -> expired ( $ item -> expiry ) ; }
test if cache is expired
14,685
private function getFromCacheable ( $ cacheId ) { $ cacheable = $ this -> cachedItems [ $ cacheId ] -> cacheable ; $ data = $ cacheable -> data ( ) ; $ ttl = $ cacheable -> ttl ( ) ; $ this -> storage -> write ( $ cacheId , $ data , $ ttl ) ; return $ data ; }
read content from Cacheable instance and write it to cache storage when cache is missed
14,686
public function get ( $ cacheId ) { $ this -> throwExceptionIfNotExists ( $ cacheId ) ; if ( $ this -> expired ( $ cacheId ) ) { return $ this -> getFromCacheable ( $ cacheId ) ; } return $ this -> getCachedItem ( $ cacheId ) ; }
retrieve cached item by id
14,687
public function add ( $ cacheId , Cacheable $ cacheable ) { $ this -> cachedItems [ $ cacheId ] = ( object ) [ 'cacheable' => $ cacheable , 'expiry' => $ this -> timeUtil -> expiry ( $ cacheable -> ttl ( ) ) ] ; return $ this ; }
add cacheable item and associate it with cache identifier
14,688
public function remove ( $ cacheId ) { $ this -> throwExceptionIfNotExists ( $ cacheId ) ; unset ( $ this -> cachedItems [ $ cacheId ] ) ; $ this -> storage -> remove ( $ cacheId ) ; return $ this ; }
remove cached item by id
14,689
public function logout ( ) { $ allConfiguration = $ this -> configurationManager -> getConfiguration ( \ TYPO3 \ Flow \ Configuration \ ConfigurationManager :: CONFIGURATION_TYPE_SETTINGS , 'TYPO3.Flow' ) ; $ tokens = $ this -> securityContext -> getAuthenticationTokensOfType ( 'Flowpack\SingleSignOn\Client\Security\SingleSignOnToken' ) ; foreach ( $ tokens as $ token ) { $ providerName = $ token -> getAuthenticationProviderName ( ) ; $ serverIdentifier = \ TYPO3 \ Flow \ Utility \ Arrays :: getValueByPath ( $ allConfiguration , 'security.authentication.providers.' . $ providerName . '.providerOptions.server' ) ; if ( $ serverIdentifier !== NULL ) { $ ssoClient = $ this -> ssoClientFactory -> create ( ) ; $ ssoServer = $ this -> ssoServerFactory -> create ( $ serverIdentifier ) ; $ ssoServer -> destroySession ( $ ssoClient , $ token -> getGlobalSessionId ( ) ) ; } } }
Notify SSO servers about the logged out client
14,690
public function generateScripts ( array $ params = null ) { $ cball = <<<CBALL(function(window,$){ $('body').on('click', '#%s', function () { $('div.test-results').remove(); var form=$(this).parents('form:first'); $.ajax({ url:"%s", data:form.serialize(), type:"POST", beforeSend:function(){ form.find('input,button,select,textarea').addClass('btn-disabled').attr('disabled','disabled'); }, success:function(response){ $('<div/>').attr('class','test-results').html(response).insertAfter(form); form.find('input,button,select,textarea').removeClass('btn-disabled').removeAttr('disabled'); }, error:function(response){ form.find('input,button,select,textarea').removeClass('btn-disabled').removeAttr('disabled'); } }); return false; }); })(window,jQuery);CBALL ; $ inlineScript = sprintf ( $ cball , $ params [ 'id' ] , handles ( 'antares::tools/tester/run' , [ 'csrf' => true ] ) ) ; app ( 'antares.asset' ) -> container ( app ( 'config' ) -> get ( 'antares/tester::container' ) ) -> inlineScript ( $ params [ 'id' ] , $ inlineScript ) ; }
generates inline scripts to handle button click event
14,691
public function extractForm ( $ className = null ) { $ traced = $ this -> findTraced ( $ className ) ; $ form = $ traced [ 'args' ] [ 1 ] [ 'form' ] ; $ controls = [ ] ; foreach ( $ form -> fieldsets as $ fieldset ) { foreach ( $ fieldset -> controls as $ control ) { $ controls [ $ control -> name ] = $ this -> resolveFieldValue ( $ control -> name , $ form -> row , $ control ) ; } } $ this -> extractHiddens ( $ controls , $ form -> hiddens ) ; $ name = $ this -> extractModuleName ( $ traced ) ; $ name = str_replace ( '_' , '-' , $ name ) ; $ name = str_replace ( 'components/' , 'antaresproject/component-' , $ name ) ; $ memory = app ( 'antares.memory' ) -> get ( "extensions.active.{$name}" ) ; if ( is_null ( $ memory ) ) { $ memory = [ 'fullname' => 'core' ] ; } $ component = Component :: findOneByName ( $ memory [ 'fullname' ] ) ; $ attributes = [ 'component_id' => $ component -> id , 'component' => $ name , 'controls' => $ controls ] ; return $ attributes ; }
extracting form properties
14,692
private function findTraced ( $ className = null ) { $ traces = debug_backtrace ( ) ; $ reflection = new ReflectionClass ( $ className ) ; $ filename = $ reflection -> getFileName ( ) ; $ traced = null ; foreach ( $ traces as $ trace ) { if ( isset ( $ trace [ 'file' ] ) and $ filename == $ trace [ 'file' ] ) { $ traced = $ trace ; break ; } } return $ traced ; }
find traced form
14,693
private function extractHiddens ( & $ controls , array $ hiddens = null ) { if ( ! empty ( $ hiddens ) ) { $ dom = new \ DOMDocument ( '1.0' ) ; $ nodes = [ ] ; foreach ( $ hiddens as $ hidden ) { $ dom -> loadHTML ( $ hidden ) ; $ nodes = $ dom -> getElementsByTagName ( 'input' ) ; } foreach ( $ nodes as $ node ) { $ controls [ $ node -> getAttribute ( 'name' ) ] = $ node -> getAttribute ( 'value' ) ; } } }
extract hidden elements from form
14,694
protected function extractModuleName ( array $ traced ) { $ executor = str_replace ( realpath ( app_path ( ) . '/../src' ) , '' , $ traced [ 'file' ] ) ; $ extractedPath = explode ( DIRECTORY_SEPARATOR , $ executor ) ; $ names = [ ] ; foreach ( $ extractedPath as $ index => $ directory ) { if ( $ directory == 'src' ) { break ; } if ( $ directory !== '' && $ directory !== 'modules' ) { $ names [ ] = $ directory ; } } return implode ( '/' , $ names ) ; }
extracting module path from debug_backtrace
14,695
protected function resolveFieldValue ( $ name , $ row , Fluent $ control ) { $ value = null ; $ model = data_get ( $ row , $ name ) ; if ( ! is_null ( $ model ) ) { $ value = $ model ; } if ( is_null ( $ control -> get ( 'value' ) ) ) { return $ value ; } $ value = $ control -> get ( 'value' ) ; if ( $ value instanceof Closure ) { $ value = $ value ( $ row , $ control ) ; } return $ value ; }
resolve field value
14,696
private function intervalToSeconds ( DateInterval $ interval ) : int { $ seconds = ( int ) $ interval -> format ( '%s' ) ; $ multiplier = 60 ; $ seconds += ( int ) $ interval -> format ( '%i' ) * $ multiplier ; $ multiplier *= 60 ; $ seconds += ( int ) $ interval -> format ( '%h' ) * $ multiplier ; $ multiplier *= 24 ; $ seconds += ( int ) $ interval -> format ( '%d' ) * $ multiplier ; $ multiplier *= 30 ; $ seconds += ( int ) $ interval -> format ( '%m' ) * $ multiplier ; $ multiplier *= 12 ; $ seconds += ( int ) $ interval -> format ( '%y' ) * $ multiplier ; return $ seconds ; }
Calculate seconds from interval
14,697
public function setValue ( $ value ) { if ( $ value instanceof \ ArrayObject ) $ this -> value = $ value -> getArrayCopy ( ) ; elseif ( is_object ( $ value ) ) $ this -> value = get_object_vars ( $ value ) ; elseif ( is_array ( $ value ) ) $ this -> value = $ value ; else throw new \ InvalidArgumentException ( "Method 'setValue' expected an object or array value" ) ; return $ this ; }
Sets the value to update as an array|object
14,698
public function setExpr ( $ expression ) { $ this -> valueList = func_get_args ( ) ; $ this -> expression = array_shift ( $ this -> valueList ) ; return $ this ; }
Sets the value list expression
14,699
protected function buildSetClause ( ) { if ( isset ( $ this -> expression ) ) return $ this -> expression ; $ set = [ ] ; foreach ( array_keys ( $ this -> value ) as $ k ) $ set [ ] = $ k . '=#{' . $ k . '}' ; return implode ( ',' , $ set ) ; }
Returns the set expression as a string