idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
58,800
public function delete ( $ file_name ) { if ( ! \ Entrust :: can ( 'delete-backups' ) ) { abort ( 403 , 'Unauthorized access - you do not have the necessary permission to delete backups.' ) ; } $ disk = Storage :: disk ( config ( 'dick.backupmanager.disk' ) ) ; if ( $ disk -> exists ( 'backups/' . $ file_name ) ) { $ disk -> delete ( 'backups/' . $ file_name ) ; return 'success' ; } else { abort ( 404 , "The backup file doesn't exist." ) ; } }
Deletes a backup file .
58,801
protected function _validateEnumValue ( $ arg ) { parent :: _validateEnumValue ( $ arg ) ; $ enum = strtoupper ( trim ( $ arg ) ) ; if ( $ enum !== 'ASC' && $ enum !== 'DESC' ) { throw new \ InvalidArgumentException ( 'argument has to be a string of asc or desc!' ) ; } $ this -> enum = $ enum ; }
Validate the enum value and set the enum property to the validated value .
58,802
public function set ( $ params1 , $ params2 = null ) { if ( is_string ( $ params1 ) ) { $ this -> variables [ $ params1 ] = $ params2 ; } elseif ( is_array ( $ params1 ) ) { $ this -> variables = $ params1 + $ this -> variables ; } }
Set a value to be substituted later into either the template or the layout . Variables assigned are accessible to both the layout and the template .
58,803
public static function getSafe ( string $ fileName = '' , bool $ allowMixedCase = true ) : string { $ fileName = \ iconv ( 'UTF-8' , 'ASCII//TRANSLIT' , \ trim ( $ fileName ) ) ; if ( ! $ allowMixedCase ) { $ fileName = \ strtolower ( $ fileName ) ; } $ fileName = \ preg_replace ( '/[^a-z0-9\-\ \.]/i' , '' , $ fileName ) ; $ fileName = \ preg_replace ( '/[\s\-]+/' , '-' , $ fileName ) ; return $ fileName ; }
Returns filesystem - safe file names .
58,804
public function orderByField ( $ column , array $ params = [ ] ) { if ( count ( $ params ) <= 0 ) return $ this ; $ this -> order -> addByField ( $ column , $ params ) ; return $ this ; }
order by field .
58,805
public function page ( $ page ) { if ( ! $ this -> limit ) return ; $ offset = $ this -> limit * ( $ page - 1 ) ; $ this -> offset ( $ offset ) ; return $ this ; }
Set page .
58,806
public function import ( $ criteria ) { if ( $ criteria instanceof WhereCondition ) { $ criteria = $ criteria -> parent ; } if ( $ criteria instanceof Criteria ) { if ( $ criteria -> where -> has ( ) ) { foreach ( $ criteria -> where -> conditions as $ condition ) { $ condition -> parent = $ this -> where ; $ this -> where -> conditions [ ] = $ condition ; } } if ( $ criteria -> order -> has ( ) ) { $ this -> order -> conditions = $ criteria -> order -> conditions ; $ this -> order -> params = $ criteria -> order -> params ; } if ( $ criteria -> limit !== null ) $ this -> limit ( $ criteria -> limit ) ; if ( $ criteria -> offset !== null ) $ this -> offset ( $ criteria -> offset ) ; } }
import from other criteria .
58,807
public function getOne ( ) { $ sql = $ this -> toSQL ( ) ; return $ this -> table -> getOne ( $ sql , $ this -> getParams ( ) ) ; }
bridge to getOne .
58,808
public function getRow ( ) { $ sql = $ this -> toSQL ( ) ; return $ this -> table -> getRow ( $ sql , $ this -> getParams ( ) ) ; }
bridge to getRow .
58,809
public function getCol ( $ column = 0 ) { $ sql = $ this -> toSQL ( ) ; return $ this -> table -> getCol ( $ sql , $ this -> getParams ( ) , $ column ) ; }
bridge to getCol .
58,810
public function toUpdateSQL ( $ attributes = array ( ) ) { $ sql = [ ] ; $ this -> params = [ ] ; $ sql [ ] = sprintf ( 'UPDATE %s SET' , $ this -> table -> getTableName ( ) ) ; $ setts = [ ] ; foreach ( $ attributes as $ key => $ value ) { $ setts [ ] = sprintf ( '%s = ?' , $ key ) ; $ this -> addParam ( $ value ) ; } $ sql [ ] = join ( ', ' , $ setts ) ; $ sql [ ] = $ this -> where -> toSQL ( ) ; $ this -> bind ( $ this -> where -> getParams ( ) ) ; return join ( ' ' , $ sql ) ; }
convert to update SQL .
58,811
public function toInsertSQL ( $ attributes = array ( ) ) { $ sql = [ ] ; $ this -> params = [ ] ; $ sql [ ] = sprintf ( 'INSERT INTO %s' , $ this -> table -> getTableName ( ) ) ; $ keys = [ ] ; $ values = [ ] ; foreach ( $ attributes as $ key => $ value ) { $ keys [ ] = $ key ; $ values [ ] = '?' ; $ this -> addParam ( $ value ) ; } $ sql [ ] = '(' . join ( ', ' , $ keys ) . ')' ; $ sql [ ] = 'VALUES (' . join ( ', ' , $ values ) . ')' ; return join ( ' ' , $ sql ) ; }
convert to insert SQL .
58,812
public function toDeleteSQL ( ) { $ sql = [ ] ; $ this -> params = [ ] ; $ sql [ ] = sprintf ( 'DELETE FROM %s' , $ this -> table -> getTableName ( ) ) ; $ sql [ ] = $ this -> where -> toSQL ( ) ; $ this -> bind ( $ this -> where -> getParams ( ) ) ; return join ( ' ' , $ sql ) ; }
convert to delete SQL .
58,813
public function set ( string $ name , string $ value ) : void { $ this -> parameters [ $ name ] = $ value ; }
Sets a parameter value by parameter name .
58,814
protected function _containerGet ( $ container , $ key ) { $ origKey = $ key ; $ key = $ this -> _normalizeKey ( $ key ) ; $ origKey = is_string ( $ origKey ) || $ origKey instanceof Stringable ? $ origKey : $ key ; if ( $ container instanceof BaseContainerInterface ) { try { return $ container -> get ( $ key ) ; } catch ( NotFoundExceptionInterface $ e ) { throw $ this -> _createNotFoundException ( $ this -> __ ( 'Key "%1$s" not found' , [ $ key ] ) , null , $ e , null , $ origKey ) ; } } if ( $ container instanceof ArrayAccess ) { try { $ hasKey = $ container -> offsetExists ( $ key ) ; } catch ( RootException $ e ) { throw $ this -> _createContainerException ( $ this -> __ ( 'Could not check for key "%1$s"' , [ $ key ] ) , null , $ e , null ) ; } if ( ! $ hasKey ) { throw $ this -> _createNotFoundException ( $ this -> __ ( 'Key "%1$s" not found' , [ $ key ] ) , null , null , null , $ origKey ) ; } try { return $ container -> offsetGet ( $ key ) ; } catch ( RootException $ e ) { throw $ this -> _createContainerException ( $ this -> __ ( 'Could not retrieve value for key "%1$s"' , [ $ key ] ) , null , $ e , null ) ; } } if ( is_array ( $ container ) ) { if ( ! array_key_exists ( $ key , $ container ) ) { throw $ this -> _createNotFoundException ( $ this -> __ ( 'Key "%1$s" not found' , [ $ key ] ) , null , null , null , $ origKey ) ; } return $ container [ $ key ] ; } if ( $ container instanceof stdClass ) { if ( ! property_exists ( $ container , $ key ) ) { throw $ this -> _createNotFoundException ( $ this -> __ ( 'Key "%1$s" not found' , [ $ key ] ) , null , null , null , $ origKey ) ; } return $ container -> { $ key } ; } throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Not a valid container' ) , null , null , $ container ) ; }
Retrieves a value from a container or data set .
58,815
protected function parse ( ) { $ this -> media = array ( ) ; $ this -> extras = array ( ) ; $ this -> sheet -> resetContents ( ) ; $ this -> acceptBom ( ) ; while ( ! empty ( $ this -> buffer ) ) { $ this -> acceptEntry ( ) ; } $ extraContent = '' ; foreach ( $ this -> extras as $ media => $ extra ) { if ( empty ( $ media ) ) { $ extraContent .= $ extra ; } else { $ extraContent .= "@media $media\n{\n$extra\n}\n" ; } $ extraContent .= "\n" ; } $ this -> sheet -> setExtraContent ( $ extraContent ) ; }
Parse css content
58,816
protected function appendExtra ( $ data ) { $ media = end ( $ this -> media ) ; if ( ! isset ( $ this -> extras [ $ media ] ) ) { $ this -> extras [ $ media ] = '' ; } $ this -> extras [ $ media ] .= $ data ; }
Append extra data
58,817
protected function acceptSafeValue ( $ until = '};' ) { $ result = '' ; while ( ! empty ( $ this -> buffer ) && false === strpos ( $ until , $ first = $ this -> buffer [ 0 ] ) ) { $ matches = array ( ) ; if ( '"' == $ first ) { $ result .= '"' ; $ this -> buffer = substr ( $ this -> buffer , 1 ) ; if ( $ this -> buffer && '"' == $ this -> buffer [ 0 ] ) { $ result .= '"' ; $ this -> buffer = substr ( $ this -> buffer , 1 ) ; } else if ( preg_match ( '/^.*?[^\\\\]"/' , $ this -> buffer , $ matches ) ) { $ result .= $ matches [ 0 ] ; $ this -> buffer = substr ( $ this -> buffer , strlen ( $ matches [ 0 ] ) ) ; } else { $ result .= $ this -> buffer ; $ this -> buffer = '' ; break ; } } else { if ( preg_match ( '/^[^' . preg_quote ( $ until ) . '"]+/' , $ this -> buffer , $ matches ) ) { $ result .= preg_replace ( '/\s+/' , ' ' , $ matches [ 0 ] ) ; $ this -> buffer = substr ( $ this -> buffer , strlen ( $ matches [ 0 ] ) ) ; } else { break ; } } } return $ result ; }
Accept safe value
58,818
protected function assertValidCode ( $ code ) { if ( $ code instanceof Money ) { $ code = $ code -> getCurrency ( ) ; } if ( $ code instanceof Currency ) { return ( string ) $ code ; } if ( ! is_string ( $ code ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Currency code should be a string; %s given' , gettype ( $ code ) ) ) ; } $ code = trim ( strtoupper ( $ code ) ) ; if ( ! Currencies :: exists ( $ code ) ) { throw new Exception \ UnknownCurrencyException ( sprintf ( '%s is not a valid ISO 4217 Currency code' , $ code ) ) ; } return $ code ; }
Ensure the given code is a known valid code
58,819
public function setLogger ( $ logger , $ checkifexists = false ) { if ( $ checkifexists && is_object ( $ this -> logger ) ) { return false ; } $ this -> logger = $ logger ; return true ; }
Set logger instance of \ Psr \ Log \ AbstractLogger
58,820
public function getLogger ( ) { if ( is_object ( $ this -> logger ) ) { return $ this -> logger ; } if ( property_exists ( $ this , 'application' ) && is_object ( $ this -> application ) ) { return $ this -> application -> getLogger ( ) ; } return null ; }
Returns logger used in a class
58,821
public function getSourceFiles ( ) { $ sourceFiles = array ( ) ; $ ignore = $ this -> configuration -> get ( 'ignore' ) ; if ( is_dir ( $ this -> get ( 'source' ) ) ) { $ recursiveIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> get ( 'source' ) ) ) ; foreach ( $ recursiveIterator as $ file ) { if ( ! $ ignore || ! preg_match ( $ ignore , $ file -> getPathname ( ) ) ) { $ sourceFiles [ $ file -> getFilename ( ) ] = $ file -> getPathname ( ) ; } } } return $ sourceFiles ; }
Get the source files as an associative array .
58,822
public function getSources ( ) { if ( null === $ this -> sources ) { $ sources = array ( ) ; foreach ( $ this -> getSourceFiles ( ) as $ sourcePath ) { $ sources [ ] = new Pinocchio ( $ sourcePath ) ; } $ this -> sources = $ sources ; } return $ this -> sources ; }
Get the set of source Pinocchios that represent the source files for the current instance .
58,823
protected function initialize ( ) { $ this -> configuration = new ValueHolder ( $ this -> loadConfiguration ( ) ) ; $ this -> defaults = new ValueHolder ( $ this -> getDefaults ( ) ) ; return $ this ; }
Initialize the non - customizable part of the configuration .
58,824
protected function loadConfiguration ( ) { $ configuration = null ; if ( file_exists ( self :: CONFIGURATION_FILENAME ) ) { $ configuration = json_decode ( file_get_contents ( self :: CONFIGURATION_FILENAME ) , true ) ; } return $ configuration ? : array ( ) ; }
Load the configuration from the file - if any - and return it .
58,825
public function getMenu ( $ menuTypeId , $ language = null ) { if ( is_null ( $ language ) ) { $ language = app ( ) -> getLocale ( ) ; } if ( $ this -> cacheEnabled ) { $ cacheName = self :: getCacheName ( $ menuTypeId , $ language ) ; if ( Cache :: has ( $ cacheName ) ) { return Cache :: get ( $ cacheName ) ; } } return $ this -> getMenuItems ( $ menuTypeId , $ language ) ; }
Get cached menu or cache it
58,826
protected function formatMenuItems ( & $ items ) { foreach ( $ items as $ key => $ item ) { $ itemData = array_only ( $ item -> toArray ( ) , $ this -> selectFields ) ; if ( ! $ item -> children -> isEmpty ( ) ) { $ itemData [ 'children' ] = $ this -> sortByField ( $ this -> formatMenuItems ( $ item -> children ) ) ; } $ items [ $ key ] = $ itemData ; } return $ items ; }
Format menu items
58,827
public function getMenuByGroup ( $ language = null ) { if ( is_null ( $ language ) ) $ language = app ( ) -> getLocale ( ) ; $ this -> menuClass :: $ customAppends = [ 'item_url' , 'item_label' ] ; $ this -> pagesClass :: $ customAppends = [ 'page_url' ] ; $ items = $ this -> menuGroupsClass :: select ( 'id' , 'name' , 'sequence' ) -> with ( [ 'menu' => function ( $ query ) use ( $ language ) { $ query -> with ( [ 'children' , 'page' => function ( $ query ) { $ query -> with ( 'translations' ) ; } , ] ) -> where ( 'language_code' , $ language ) -> orderBy ( 'sequence' ) ; } ] ) -> where ( 'language_code' , $ language ) -> orderBy ( 'sequence' , 'ASC' ) -> get ( ) ; foreach ( $ items as $ key => $ item ) { $ items [ $ key ] [ 'menu' ] = $ this -> formatMenuItems ( $ item -> menu ) ; } return $ items ; }
Get menu by groups
58,828
public static function clearCache ( $ menuTypeId , $ lang ) { $ name = self :: getCacheName ( $ menuTypeId , $ lang ) ; Cache :: forget ( $ name ) ; }
Clear menu item cache
58,829
public function register ( string $ name , ServiceManager $ service_manager ) { $ this -> service_managers [ $ name ] = $ service_manager ; if ( Core :: i ( ) -> log ) { Core :: i ( ) -> log -> debug ( 'Registered service manager: ' . $ name ) ; } }
Add a service manager
58,830
public function get ( $ name ) { if ( isset ( $ this -> service_managers [ $ name ] ) ) { return $ this -> service_managers [ $ name ] ; } else { throw new ServiceManagerNotFoundException ( 'No service manager has been registered as ' . $ name ) ; } }
Returns the specified service manager
58,831
public function build ( ) { $ this -> _checkConditionArray ( ) ; $ this -> _processConditionArray ( ) ; $ this -> conditionString = trim ( $ this -> conditionString ) ; return $ this -> conditionString . ' ' ; }
Build the condition expression string . Processing the passed condition expression and return it in form of a string .
58,832
private function _processConditionArray ( ) { foreach ( $ this -> conditionArray as $ conditions ) { foreach ( $ conditions as $ operator => $ condition ) { if ( ! is_string ( $ operator ) ) { $ this -> conditionString .= $ condition . ' ' ; } else { $ this -> conditionString .= strtoupper ( $ operator ) . ' ' . $ condition . ' ' ; } } } }
Processing the condition array and build the condition string .
58,833
public function hydrate ( array $ objects , array $ fields = array ( ) ) { return $ this -> modelBuilder -> buildAll ( $ objects , $ this -> class -> getManagerIdentifier ( ) , $ fields ) ; }
Multiple hydration model .
58,834
protected function getQueryBuilderResult ( $ qb , $ count = null , $ hydrate = true , array $ fields = array ( ) , $ except = false ) { $ result = $ qb -> execute ( ) ; if ( $ except ) { foreach ( $ result as $ key => $ value ) { foreach ( $ value as $ field => $ data ) { if ( is_int ( $ field ) ) { $ result [ $ key ] = $ data ; continue 2 ; } } } } if ( $ hydrate ) { $ result = $ this -> hydrate ( ( array ) $ result , $ fields ) ; } if ( $ count === 1 ) { $ result = is_array ( $ result ) ? reset ( $ result ) : $ result ; } return $ result ; }
Return the result for given query builder object .
58,835
public function findByUid ( $ id , $ columns = [ '*' ] ) { $ this -> applyCriteria ( ) ; $ this -> applyScope ( ) ; $ model = $ this -> model -> where ( 'uid' , '=' , $ id ) -> firstOrFail ( $ columns ) ; $ this -> resetModel ( ) ; return $ this -> parserResult ( $ model ) ; }
Find data by id .
58,836
public static function buildFromJSON ( $ json ) { $ jsonObject = json_decode ( $ json ) ; if ( ! property_exists ( $ jsonObject , 'platformGID' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property platformGID missing!' ) ; if ( ! property_exists ( $ jsonObject , 'globalID' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property globalID missing!' ) ; if ( ! property_exists ( $ jsonObject , 'type' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property type missing!' ) ; if ( ! property_exists ( $ jsonObject , 'displayName' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property displayName missing!' ) ; if ( ! property_exists ( $ jsonObject , 'profileLocation' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property profileLocation missing!' ) ; if ( ! property_exists ( $ jsonObject , 'personalPublicKey' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property personalPublicKey missing!' ) ; if ( ! property_exists ( $ jsonObject , 'accountPublicKey' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property accountPublicKey missing!' ) ; if ( ! property_exists ( $ jsonObject , 'salt' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property salt missing!' ) ; if ( ! property_exists ( $ jsonObject , 'datetime' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property datetime missing!' ) ; if ( ! property_exists ( $ jsonObject , 'active' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property active missing!' ) ; if ( ! property_exists ( $ jsonObject , 'keyRevocationList' ) ) throw new SocialRecordFormatException ( 'SocialRecord: Property keyRevocationList missing!' ) ; $ krl = array ( ) ; foreach ( $ jsonObject -> keyRevocationList as $ krc ) { $ krl [ ] = KeyRevocationCertificateBuilder :: buildFromJSON ( $ krc ) ; } return ( new SocialRecordBuilder ( ) ) -> type ( $ jsonObject -> type ) -> globalID ( $ jsonObject -> globalID ) -> platformGID ( $ jsonObject -> platformGID ) -> displayName ( $ jsonObject -> displayName ) -> profileLocation ( $ jsonObject -> profileLocation ) -> personalPublicKey ( PublicKey :: formatPEM ( $ jsonObject -> personalPublicKey ) ) -> accountPublicKey ( PublicKey :: formatPEM ( $ jsonObject -> accountPublicKey ) ) -> salt ( $ jsonObject -> salt ) -> datetime ( $ jsonObject -> datetime ) -> active ( $ jsonObject -> active ) -> keyRevocationList ( $ krl ) -> build ( ) ; }
Creates a SocialRecord object from a JSON String
58,837
public function keyRevocationList ( $ krl = NULL ) { if ( $ krl == NULL ) $ this -> keyRevocationList = array ( ) ; else $ this -> keyRevocationList = $ krl ; return $ this ; }
Set the key revocation list
58,838
public function build ( ) { if ( $ this -> displayName == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: displayName must be specified for instantiation' ) ; if ( $ this -> profileLocation == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: profileLocation must be specified for instantiation' ) ; if ( $ this -> personalPublicKey == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: personalPublicKey must be specified for instantiation' ) ; if ( $ this -> accountPublicKey == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: accountPublicKey must be specified for instantiation' ) ; if ( $ this -> type == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: type must be specified for instantiation' ) ; if ( $ this -> type != SocialRecord :: TYPE_PLATFORM && $ this -> type != SocialRecord :: TYPE_USER && $ this -> type != SocialRecord :: TYPE_PAGE ) throw new SocialRecordFormatException ( 'SocialRecord: Invalid type value [' . $ this -> type . ']' ) ; if ( $ this -> salt == NULL ) $ this -> salt = Random :: getRandom ( SocialRecord :: SALT_CHARS / 2 ) ; if ( $ this -> datetime == NULL ) $ this -> datetime = XSDDateTime :: getXSDDateTime ( ) ; if ( $ this -> globalID == NULL ) $ this -> globalID = GID :: createGID ( $ this -> personalPublicKey , $ this -> salt ) ; if ( ! GID :: isValid ( $ this -> globalID ) ) throw new SocialRecordFormatException ( 'SocialRecord: Invalid globalID value [' . $ this -> globalID . ']' ) ; if ( $ this -> platformGID == NULL && $ this -> type == SocialRecord :: TYPE_PLATFORM ) $ this -> platformGID = $ this -> globalID ; if ( $ this -> platformGID == NULL ) throw new SocialRecordFormatException ( 'SocialRecord: platformGID must be specified for instantiation' ) ; if ( ! GID :: isValid ( $ this -> platformGID ) ) throw new SocialRecordFormatException ( 'SocialRecord: Invalid platformGID value [' . $ this -> platformGID . ']' ) ; if ( $ this -> keyRevocationList == NULL ) $ this -> keyRevocationList = array ( ) ; if ( $ this -> active == NULL ) $ this -> active = 1 ; return new SocialRecord ( $ this ) ; }
Builder method that creates the actual SocialRecord object
58,839
public static function Ttut1 ( $ tt1 , $ tt2 , $ dt , & $ ut11 , & $ ut12 ) { $ dtd ; $ dtd = $ dt / DAYSEC ; if ( $ tt1 > $ tt2 ) { $ ut11 = $ tt1 ; $ ut12 = $ tt2 - $ dtd ; } else { $ ut11 = $ tt1 - $ dtd ; $ ut12 = $ tt2 ; } return 0 ; }
- - - - - - - - - i a u T t u t 1 - - - - - - - - -
58,840
public function get ( int $ row , int $ column ) { $ this -> assertIndexesAreValid ( $ row , $ column ) ; return $ this -> cells [ $ row ] [ $ column ] ; }
Get the value at a given row and column .
58,841
public function isEmpty ( int $ row , int $ column ) { $ this -> assertIndexesAreValid ( $ row , $ column ) ; return $ this -> get ( $ row , $ column ) === null ; }
Determine whether a cell is empty .
58,842
public function set ( int $ row , int $ column , Tile $ tile ) { $ this -> assertEmptyTileSlot ( $ row , $ column , $ tile ) ; switch ( $ tile -> getValue ( ) ) { case Tile :: SMALL : $ this -> cells [ $ row ] [ $ column ] = Cell :: SMALL ( ) ; $ this -> small += 1 ; break ; case Tile :: TALL : $ this -> cells [ $ row ] [ $ column ] = Cell :: TALL_TOP ( ) ; $ this -> cells [ $ row + 1 ] [ $ column ] = Cell :: TALL_BOTTOM ( ) ; $ this -> tall += 1 ; break ; case Tile :: WIDE : $ this -> cells [ $ row ] [ $ column ] = Cell :: WIDE_LEFT ( ) ; $ this -> cells [ $ row ] [ $ column + 1 ] = Cell :: WIDE_RIGHT ( ) ; $ this -> wide += 1 ; break ; } }
Set a cell values at a given row and column for a given tile .
58,843
public function getData ( bool $ flatten = false , callable $ cellToValue = null ) { $ copy = array ( ) ; for ( $ row = 0 ; $ row < $ this -> rows ; $ row ++ ) { if ( ! $ flatten ) { $ copy [ $ row ] = array ( ) ; } foreach ( $ this -> cells [ $ row ] as $ cell ) { $ value = $ cellToValue ? $ cellToValue ( $ cell ) : $ cell ; if ( $ flatten && $ value === false ) { } elseif ( $ flatten ) { $ copy [ ] = $ value ; } else { $ copy [ $ row ] [ ] = $ value ; } } } return $ copy ; }
Get a copy of the cells array .
58,844
public function getCells ( bool $ flatten = false , bool $ raw = false ) { return $ this -> getData ( $ flatten , $ raw ? null : function ( $ cell ) { return Cell :: toValue ( $ cell ) ; } ) ; }
Get a copy of the grid cells .
58,845
public function getTiles ( bool $ flatten = false , bool $ raw = false ) { return $ this -> getData ( $ flatten , $ raw ? function ( $ cell ) { return Tile :: fromCell ( $ cell ) ; } : function ( $ cell ) { return Cell :: toValue ( Tile :: fromCell ( $ cell ) ) ; } ) ; }
Get a copy of the grid cells as an array of tiles .
58,846
public static function factory ( $ key , $ secret , $ from ) { $ sms = new Sms ( new GuzzleHttp \ Client ( ) ) ; $ sms -> setKey ( $ key ) -> setSecret ( $ secret ) -> setFrom ( $ from ) ; return $ sms ; }
Creates and returns a new Sms instance
58,847
public function text ( $ to , $ message , $ client_ref = null ) { return $ this -> send ( [ "to" => $ to , "type" => "text" , "text" => $ this -> mbstring ( $ message ) , "client-ref" => $ this -> mbstring ( $ client_ref ) ] ) ; }
Sends a text message
58,848
protected function send ( array $ query ) { if ( ! $ this -> key || ! $ this -> secret || ! $ this -> from ) { throw new Exception \ ConfigurationException ( "Invalid configuration. Missing key, secret, or from." ) ; } $ query [ "api_key" ] = $ this -> key ; $ query [ "api_secret" ] = $ this -> secret ; $ query [ "from" ] = $ this -> from ; $ query [ "status-report-req" ] = $ this -> status_report_req ; if ( $ this -> ttl ) { $ query [ "ttl" ] = $ this -> ttl ; } $ response = $ this -> guzzle -> get ( self :: API_URI , [ "query" => $ query ] ) -> json ( ) ; $ messages = [ ] ; $ exceptions = [ ] ; foreach ( $ response [ "messages" ] as $ message ) { if ( $ message [ "status" ] != 0 ) { $ exceptions [ ] = Exception \ Factory :: factory ( $ message [ "error-text" ] , $ message [ "status" ] ) ; } else { $ messages [ ] = new Message ( $ message ) ; } } $ response = new Response ( $ messages , $ exceptions ) ; if ( $ exceptions ) { $ exceptions [ 0 ] -> setResponse ( $ response ) ; throw $ exceptions [ 0 ] ; } return $ response ; }
Sends a request to the Nexmo API
58,849
protected function hasContentForKey ( $ key , $ content ) : bool { foreach ( $ content as $ item ) { foreach ( $ this -> getMatchingKeys ( $ key , $ item ) as $ matchedKey ) { if ( parent :: hasContentForKey ( $ matchedKey , $ item ) ) { return true ; } } } return false ; }
Overrides the parent method . When checking to see if valid content exists this will scan all of the current content to see if any have content located with the key .
58,850
protected function getMatchingKeys ( $ key , $ content ) : array { if ( ! is_string ( $ key ) || ! self :: isStringRegex ( $ key ) ) { return [ $ key ] ; } if ( $ content instanceof Treadable ) { $ allKeys = $ content -> getChildKeys ( ) ; } if ( is_object ( $ content ) && ! ( $ content instanceof Treadable ) ) { $ content = get_object_vars ( $ content ) ; } if ( is_array ( $ content ) ) { $ allKeys = array_keys ( $ content ) ; } if ( ! isset ( $ allKeys ) ) { return [ ] ; } return preg_grep ( $ key , $ allKeys ) ; }
Given a key and a piece of content check to see if that content has any child content located based off of that provided key . This will also check for regex strings as well .
58,851
public function get ( $ id ) { if ( $ this -> parent === null && ! array_key_exists ( $ id , $ this -> instances ) ) { try { return $ this -> instantiate ( $ id ) ; } catch ( \ Exception $ e ) { throw new RefNotFound ( $ id ) ; } } return array_key_exists ( $ id , $ this -> instances ) ? $ this -> instances [ $ id ] : $ this -> parent -> get ( $ id ) ; }
Retrieve an instance from the injector .
58,852
public function has ( $ id ) { if ( array_key_exists ( $ id , $ this -> instances ) ) { return true ; } return $ this -> parent !== null ? $ this -> parent -> has ( $ id ) : false ; }
Check for the existence of an instance from the injector .
58,853
public function annotate ( callable $ callable ) { $ fn = null ; $ invoke = function ( ) { } ; if ( is_array ( $ callable ) ) { $ cls = new ReflectionClass ( $ callable [ 0 ] ) ; $ fn = $ cls -> getMethod ( $ callable [ 1 ] ) ; $ invoke = function ( $ args ) use ( $ fn , $ callable ) { return function ( ) use ( $ fn , $ callable , $ args ) { return $ fn -> invokeArgs ( $ callable [ 0 ] , $ args ) ; } ; } ; } else if ( ! ( $ callable instanceof \ Closure ) ) { $ cls = new ReflectionClass ( $ callable ) ; $ fn = $ cls -> getMethod ( '__invoke' ) ; $ invoke = function ( $ args ) use ( $ fn , $ callable ) { return function ( ) use ( $ fn , $ callable , $ args ) { return $ fn -> invokeArgs ( $ callable , $ args ) ; } ; } ; } else { $ fn = new ReflectionFunction ( $ callable ) ; $ invoke = function ( $ args ) use ( $ fn ) { return function ( ) use ( $ fn , $ args ) { return $ fn -> invokeArgs ( $ args ) ; } ; } ; } $ cacheId = sha1 ( $ fn -> __toString ( ) ) ; if ( array_key_exists ( $ cacheId , $ this -> fnCache ) ) { return $ this -> fnCache [ $ cacheId ] ; } $ args = $ this -> getArgs ( $ fn ) ; $ annotated = $ invoke ( $ args ) ; $ this -> fnCache [ $ cacheId ] = $ annotated ; return $ annotated ; }
Annotate a function so that it is dependency injected .
58,854
protected function addColumnElementToForm ( Form $ form , Property $ property ) { $ annotationType = $ property -> getAnnotation ( ) -> type ; $ label = $ property -> getName ( ) ; switch ( $ annotationType ) { case 'datetime' : $ element = new DateTime ( $ property -> getName ( ) ) ; break ; case 'date' : $ element = new Date ( $ property -> getName ( ) ) ; break ; case 'time' : $ element = new Time ( $ property -> getName ( ) ) ; break ; case 'text' : $ element = new Textarea ( $ property -> getName ( ) ) ; break ; case 'boolean' : $ element = new Checkbox ( $ property -> getName ( ) ) ; break ; default : if ( in_array ( $ property -> getName ( ) , $ this -> emailProperties ) ) { $ element = new Email ( $ property -> getName ( ) ) ; } elseif ( in_array ( $ property -> getName ( ) , $ this -> passwordProperties ) ) { $ element = new Password ( $ property -> getName ( ) ) ; $ element -> setLabel ( $ property -> getName ( ) ) ; $ form -> add ( $ element ) ; $ element = new Password ( $ property -> getName ( ) . '2' ) ; $ label = $ property -> getName ( ) . ' (repeat)' ; } else { $ element = new Text ( $ property -> getName ( ) ) ; } break ; } $ element -> setLabel ( $ label ) ; $ form -> add ( $ element ) ; }
Adds a property depending column - element to the form
58,855
protected function addSingleSelecterElementToForm ( Form $ form , Property $ property ) { if ( $ this -> toOneElement == $ this :: REF_ONE_ELEMENT_SELECT ) { $ element = new Select ( $ property -> getName ( ) ) ; } else { $ element = new Radio ( $ property -> getName ( ) ) ; } $ options = [ 0 => '-none-' ] + $ this -> getValueOptionsFromEntity ( $ property -> getTargetEntity ( ) ) ; $ element -> setValueOptions ( $ options ) ; $ element -> setLabel ( $ property -> getName ( ) ) ; $ form -> add ( $ element ) ; }
Adds a property depending single - selecter - element to the form
58,856
protected function addMultiSelecterElementToForm ( Form $ form , Property $ property ) { if ( $ this -> toManyElement == $ this :: REF_MANY_ELEMENT_MULTISELECT ) { $ element = new Select ( $ property -> getName ( ) ) ; $ element -> setAttribute ( 'multiple' , true ) ; } else { $ element = new MultiCheckbox ( $ property -> getName ( ) ) ; } $ options = $ this -> getValueOptionsFromEntity ( $ property -> getTargetEntity ( ) ) ; if ( empty ( $ options ) ) { return false ; } $ element -> setValueOptions ( $ options ) ; $ element -> setLabel ( $ property -> getName ( ) ) ; $ form -> add ( $ element ) ; }
Adds a property depending multi - selecter - element to the form
58,857
protected function getValueOptionsFromEntity ( $ entityNamespace ) { $ targets = $ this -> objectManager -> getRepository ( $ entityNamespace ) -> findBy ( [ ] , [ 'id' => 'ASC' ] ) ; $ displayNameGetter = 'get' . ucfirst ( $ entityNamespace :: DISPLAY_NAME_PROPERTY ) ; $ options = [ ] ; foreach ( $ targets as $ target ) { $ options [ $ target -> getId ( ) ] = $ target -> $ displayNameGetter ( ) ; } return $ options ; }
Get ValueOptions for Form - Elements by entity
58,858
public function getCategoriesUsed ( array $ titles ) { $ path = '?action=query&generator=categories&prop=info' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get information about all categories used .
58,859
public function getCategoriesInfo ( array $ titles , $ clcontinue = false ) { $ path = '?action=query&prop=categoryinfo' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( $ clcontinue ) { $ path .= '&clcontinue=' ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get information about the given categories .
58,860
public function getCategoryMembers ( $ cmtitle = null , $ cmpageid = null , $ cmlimit = null , array $ cmprop = null , array $ cmnamespace = null , array $ cmtype = null , $ cmstart = null , $ cmend = null , $ cmstartsortkey = null , $ cmendsortkey = null , $ cmstartsortkeyprefix = null , $ cmendsortkeyprefix = null , $ cmsort = null , $ cmdir = null , $ cmcontinue = null ) { $ path = '?action=query&list=categorymembers' ; if ( isset ( $ cmtitle , $ cmpageid ) ) { throw new \ RuntimeException ( 'Both the $cmtitle and $cmpageid parameters cannot be set, please only use one of the two.' ) ; } if ( isset ( $ cmtitle ) ) { if ( strpos ( $ cmtitle , 'Category:' ) !== 0 ) { throw new \ RuntimeException ( 'The $cmtitle parameter must include the Category: prefix.' ) ; } $ path .= '&cmtitle=' . $ cmtitle ; } if ( isset ( $ cmpageid ) ) { $ path .= '&cmpageid=' . $ cmpageid ; } if ( isset ( $ cmlimit ) ) { $ path .= '&cmlimit=' . $ cmlimit ; } if ( isset ( $ cmprop ) ) { $ path .= '&cmprop=' . $ this -> buildParameter ( $ cmprop ) ; } if ( isset ( $ cmnamespace ) ) { $ path .= '&cmnamespace=' . $ this -> buildParameter ( $ cmnamespace ) ; } if ( isset ( $ cmtype ) ) { $ path .= '&cmtype=' . $ this -> buildParameter ( $ cmtype ) ; } if ( isset ( $ cmstart ) ) { $ path .= '&cmstart=' . $ cmstart ; } if ( isset ( $ cmend ) ) { $ path .= '&cmend=' . $ cmend ; } if ( isset ( $ cmstartsortkey ) ) { $ path .= '&cmstartsortkey=' . $ cmstartsortkey ; } if ( isset ( $ cmendsortkey ) ) { $ path .= '&cmendsortkey=' . $ cmendsortkey ; } if ( isset ( $ cmstartsortkeyprefix ) ) { $ path .= '&cmstartsortkeyprefix=' . $ cmstartsortkeyprefix ; } if ( isset ( $ cmendsortkeyprefix ) ) { $ path .= '&cmendsortkeyprefix=' . $ cmendsortkeyprefix ; } if ( isset ( $ cmsort ) ) { $ path .= '&cmsort=' . $ cmsort ; } if ( isset ( $ cmdir ) ) { $ path .= '&cmdir=' . $ cmdir ; } if ( isset ( $ cmcontinue ) ) { $ path .= '&cmcontinue=' . $ cmcontinue ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to get information about the pages within a category
58,861
public function enumerateCategories ( $ acfrom = null , $ acto = null , $ acprefix = null , $ acdir = null , $ acmin = null , $ acmax = null , $ aclimit = null , array $ acprop = null ) { $ path = '?action=query&list=allcategories' ; if ( isset ( $ acfrom ) ) { $ path .= '&acfrom=' . $ acfrom ; } if ( isset ( $ acto ) ) { $ path .= '&acto=' . $ acto ; } if ( isset ( $ acprefix ) ) { $ path .= '&acprefix=' . $ acprefix ; } if ( isset ( $ acdir ) ) { $ path .= '&acdir=' . $ acdir ; } if ( isset ( $ acfrom ) ) { $ path .= '&acfrom=' . $ acfrom ; } if ( isset ( $ acmin ) ) { $ path .= '&acmin=' . $ acmin ; } if ( isset ( $ acmax ) ) { $ path .= '&acmax=' . $ acmax ; } if ( isset ( $ aclimit ) ) { $ path .= '&aclimit=' . $ aclimit ; } if ( isset ( $ acprop ) ) { $ path .= '&acprop=' . $ this -> buildParameter ( $ acprop ) ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to enumerate all categories .
58,862
public function getChangeTags ( array $ tgprop = null , $ tglimit = null ) { $ path = '?action=query&list=tags' ; if ( isset ( $ tgprop ) ) { $ path .= '&tgprop=' . $ this -> buildParameter ( $ tgprop ) ; } if ( isset ( $ tglimit ) ) { $ path .= '&tglimit=' . $ tglimit ; } $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; return $ this -> validateResponse ( $ response ) ; }
Method to list change tags .
58,863
public function create ( Pubsub_Subscription $ postBody , $ optParams = array ( ) ) { $ params = array ( 'postBody' => $ postBody ) ; $ params = array_merge ( $ params , $ optParams ) ; return $ this -> call ( 'create' , array ( $ params ) , "Pubsub_Subscription" ) ; }
Creates a subscription on a given topic for a given subscriber . If the subscription already exists returns ALREADY_EXISTS . If the corresponding topic doesn t exist returns NOT_FOUND .
58,864
public function make ( ) { $ menuClasses = [ 'dropdown-menu' ] ; if ( $ this -> right ) { $ menuClasses [ ] = 'dropdown-menu-right' ; } return new Div ( [ 'class' => 'dropdown' ] , [ new Anchor ( [ 'id' => $ this -> hash , 'data-toggle' => 'dropdown' , 'aria-haspopup' => 'true' , 'aria-expanded' => 'false' , ] , new Italic ( [ 'class' => 'fa fa-ellipsis-h' ] ) ) , new Div ( [ 'class' => $ menuClasses , 'aria-labelledby' => $ this -> hash , ] , $ this -> options ) , ] ) ; }
Build the dropdown element .
58,865
protected function getComposePsrNamespaceList ( ) : array { $ jsonFilePath = $ this -> annotationConfig -> getConfig ( ) [ 'composerFilePath' ] ; if ( ! file_exists ( $ jsonFilePath ) ) throw new AnnotationException ( 'Build Annotation error , composer.json file not found ' . $ jsonFilePath ) ; return json_decode ( file_get_contents ( $ jsonFilePath ) , true ) ; }
load composer . json file return composer . json psr - 4 setting
58,866
protected function namespaceCreateAllDir ( string $ namespace ) { if ( is_dir ( $ namespace ) ) return ; $ dirList = explode ( '\\' , str_replace ( '/' , '\\' , $ namespace ) ) ; $ path = $ this -> annotationConfig -> getConfig ( ) [ 'buildPath' ] ; foreach ( $ dirList as $ k => $ dir ) { $ path .= '/' . $ dir ; if ( ! is_dir ( $ path ) ) mkdir ( $ path ) ; } }
create namespace of needed all dir
58,867
protected function fileToBuildPath ( $ path ) { $ configService = ServiceFactory :: getInstance ( AnnotationConfigServiceImpl :: class ) ; $ list = $ configService -> getConfig ( ) [ 'scanNamespace' ] ; foreach ( $ list as $ namespace => $ filePath ) { if ( strpos ( $ path , $ filePath ) !== false ) { return str_replace ( $ configService -> getConfig ( ) [ 'appPath' ] . '/' . $ filePath , $ configService -> getConfig ( ) [ 'buildPath' ] . str_replace ( '\\' , '/' , $ namespace ) , $ path ) ; } ; } return '' ; }
file path to build path
58,868
public static function getService ( ArrayObject $ config , Loops $ loops ) { $ logger = parent :: getService ( $ config , $ loops ) ; $ plugin = $ config -> offsetExists ( "plugin" ) ? $ config -> offsetGet ( "plugin" ) : "stderr" ; foreach ( array_filter ( is_array ( $ plugin ) ? $ plugin : explode ( "," , $ plugin ) ) as $ plugin ) { $ classname = "Loops\Logger\\" . Misc :: camelize ( $ plugin ) . "Logger" ; $ logger -> attach ( Misc :: reflectionInstance ( $ classname , $ config ) ) ; } return $ logger ; }
Creates the logging service .
58,869
public static function php_error_handler ( $ errno , $ errstr , $ errfile , $ errline , $ errcontext ) { if ( $ errno & error_reporting ( ) ) { foreach ( self :: $ error_handling_instances as list ( $ logger , $ level , $ with_line , $ with_trace ) ) { if ( ! ( $ errno & $ level ) ) { continue ; } switch ( $ errno ) { case E_PARSE : $ severity = Message :: ALERT ; break ; case E_CORE_ERROR : case E_COMPILE_ERROR : $ severity = Message :: CRITICAL ; break ; case E_ERROR : case E_USER_ERROR : case E_RECOVERABLE_ERROR : $ severity = Message :: ERROR ; break ; case E_WARNING : case E_CORE_WARNING : case E_COMPILE_WARNING : case E_USER_WARNING : $ severity = Message :: WARNING ; break ; case E_NOTICE : case E_USER_NOTICE : $ severity = Message :: NOTICE ; break ; case E_DEPRECATED : case E_USER_DEPRECATED : $ severity = Message :: INFO ; break ; case E_STRICT : default : $ severity = Message :: DEBUG ; break ; } $ message = self :: errnoToString ( $ errno ) . ": $errstr" ; if ( $ with_line ) { $ message = "$message in $errfile on line: $errline" ; } if ( $ with_trace ) { throw new Exception ( "Not implemented yet." ) ; } $ logger -> logMessage ( new Message ( $ message , $ severity ) ) ; } } return TRUE ; }
Converts PHP errors to a Loops \ Messages \ Message and passes it to all Loops \ Service \ Logger instances .
58,870
public function logMessage ( Message $ message ) { foreach ( $ this -> logger as $ logger ) { $ logger -> logMessage ( $ message ) ; } }
Forwards the log message to all attached logger interfaces
58,871
public function detach ( LoggerInterface $ logger ) { $ key = array_search ( $ logger , $ this -> logger , TRUE ) ; if ( $ key === FALSE ) { return FALSE ; } unset ( $ this -> logger [ $ key ] ) ; return TRUE ; }
Removes an attached logger instance
58,872
public function createTelerivetDriver ( ) { $ config = $ this -> app [ 'config' ] -> get ( 'sms.telerivet' , [ ] ) ; $ driver = new Telerivet ( $ config [ 'api_key' ] , $ config [ 'project_id' ] ) ; return $ driver ; }
Create an instance of the telerivet driver
58,873
public function createSmartDriver ( ) { $ config = $ this -> app [ 'config' ] -> get ( 'sms.smart' , [ ] ) ; $ driver = new Smart ( $ config [ 'token' ] , $ config [ 'wsdl' ] , $ config [ 'service' ] ) ; return $ driver ; }
Create an instance of the smart driver
58,874
public function createSunDriver ( ) { $ config = $ this -> app [ 'config' ] -> get ( 'sms.sun' , [ ] ) ; $ driver = new Sun ( $ config [ 'user' ] , $ config [ 'pass' ] , $ config [ 'mask' ] , $ config [ 'login_url' ] ) ; return $ driver ; }
Create an instance of the sun driver
58,875
public static function createFromServer ( $ serv ) { $ scheme = isset ( $ serv [ 'HTTPS' ] ) ? 'https://' : 'http://' ; $ host = ! empty ( $ serv [ 'HTTP_HOST' ] ) ? $ serv [ 'HTTP_HOST' ] : $ serv [ 'SERVER_NAME' ] ; $ port = empty ( $ serv [ 'SERVER_PORT' ] ) ? $ serv [ 'SERVER_PORT' ] : null ; $ path = ( string ) parse_url ( 'http://www.example.com/' . $ serv [ 'REQUEST_URI' ] , PHP_URL_PATH ) ; $ query = empty ( $ serv [ 'QUERY_STRING' ] ) ? parse_url ( 'http://example.com' . $ serv [ 'REQUEST_URI' ] , PHP_URL_QUERY ) : $ serv [ 'QUERY_STRING' ] ; $ fragment = '' ; $ user = ! empty ( $ serv [ 'PHP_AUTH_USER' ] ) ? $ serv [ 'PHP_AUTH_USER' ] : '' ; $ password = ! empty ( $ serv [ 'PHP_AUTH_PW' ] ) ? $ serv [ 'PHP_AUTH_PW' ] : '' ; if ( empty ( $ user ) && empty ( $ password ) && ! empty ( $ serv [ 'HTTP_AUTHORIZATION' ] ) ) { list ( $ user , $ password ) = explode ( ':' , base64_decode ( substr ( $ serv [ 'HTTP_AUTHORIZATION' ] , 6 ) ) ) ; } $ uri = new \ Resilient \ Http \ Uri ( $ scheme , $ host , $ port , $ path , $ query , $ fragment , $ user , $ password ) ; return $ uri ; }
Create uri Instance from header .
58,876
private function parseDocument ( ) { $ doc = $ this -> getDocument ( ) ; if ( $ doc === null ) { $ this -> isParsed = true ; return ; } $ errors = new ErrorCollection ( ) ; if ( ( $ data = $ doc -> getData ( ) ) === false ) { $ errors -> addDataError ( "Invalid element" ) ; throw new JsonApiException ( $ errors ) ; } $ schema = $ this -> getSchema ( ) ; $ type = $ data -> getType ( ) ; $ idx = $ data -> getIdentifier ( ) ; $ attributes = array_intersect_key ( $ data -> getAttributes ( ) , $ schema -> getAttributesMap ( ) ) ; if ( $ errors -> count ( ) > 0 ) { throw new JsonApiException ( $ errors ) ; } $ this -> type = $ type ; $ this -> idx = $ idx ; $ this -> resourceAttr = $ attributes ; $ this -> validateParsed ( ) ; $ this -> isParsed = true ; }
Parse JSON API document
58,877
public function spracuj ( $ config , $ text , $ time ) { $ text = '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>' . $ text ; $ from_enc = "ISO-8859-2" ; if ( $ config [ "from_encoding" ] ) $ from_enc = $ config [ "from_encoding" ] ; $ text = str_replace ( $ from_enc , "utf-8" , $ text ) ; $ this -> text = iconv ( $ from_enc , "utf-8" , $ text ) ; $ this -> config = $ config ; $ this -> time = Time :: get ( $ time ) ; $ this -> doc = @ \ DOMDocument :: loadHtml ( $ this -> text ) ; if ( ! $ this -> doc ) { file_put_contents ( "test002.html" , $ text ) ; exit ; } $ this -> xpath = new \ DOMXPath ( $ this -> doc ) ; return $ data = $ this -> createData ( ) ; }
Config by mal obsahovat xpath upmiestnenie tabulky a pocet tr ktore preskocit
58,878
public function doRender ( $ rawContent , array $ attributes = [ ] ) { $ renderer = $ this -> renderer ; if ( $ renderer === null ) { $ rendered = $ rawContent ; } elseif ( $ renderer instanceof Renderer ) { $ rendered = $ renderer -> render ( $ rawContent , $ attributes ) ; } elseif ( $ renderer instanceof \ Closure ) { $ rendered = call_user_func ( $ renderer , $ rawContent , $ attributes ) ; } else { throw new \ Exception ( 'Invalid renderer given. Expecting null, instance of Gen\Renderer\Renderer or valid callback.' ) ; } return $ this -> renderedContent = $ rendered ; }
Render the page using the provided Renderer .
58,879
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ configuration = $ serviceLocator -> get ( 'ApplicationConfig' ) ; if ( $ serviceLocator -> has ( 'ServiceListenerInterface' ) ) { $ serviceListener = $ serviceLocator -> get ( 'ServiceListenerInterface' ) ; if ( ! $ serviceListener instanceof ServiceListenerInterface ) { throw new RuntimeException ( 'The service named ServiceListenerInterface must implement ' . 'Zend\ModuleManager\Listener\ServiceListenerInterface' ) ; } $ serviceListener -> setDefaultServiceConfig ( $ this -> defaultServiceConfig ) ; } else { $ serviceListener = new ServiceListener ( $ serviceLocator , $ this -> defaultServiceConfig ) ; } if ( isset ( $ configuration [ 'service_listener_options' ] ) ) { if ( ! is_array ( $ configuration [ 'service_listener_options' ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The value of service_listener_options must be an array, %s given.' , gettype ( $ configuration [ 'service_listener_options' ] ) ) ) ; } foreach ( $ configuration [ 'service_listener_options' ] as $ key => $ newServiceManager ) { if ( ! isset ( $ newServiceManager [ 'service_manager' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: MISSING_KEY_ERROR , $ key , 'service_manager' ) ) ; } elseif ( ! is_string ( $ newServiceManager [ 'service_manager' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: VALUE_TYPE_ERROR , 'service_manager' , gettype ( $ newServiceManager [ 'service_manager' ] ) ) ) ; } if ( ! isset ( $ newServiceManager [ 'config_key' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: MISSING_KEY_ERROR , $ key , 'config_key' ) ) ; } elseif ( ! is_string ( $ newServiceManager [ 'config_key' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: VALUE_TYPE_ERROR , 'config_key' , gettype ( $ newServiceManager [ 'config_key' ] ) ) ) ; } if ( ! isset ( $ newServiceManager [ 'interface' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: MISSING_KEY_ERROR , $ key , 'interface' ) ) ; } elseif ( ! is_string ( $ newServiceManager [ 'interface' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: VALUE_TYPE_ERROR , 'interface' , gettype ( $ newServiceManager [ 'interface' ] ) ) ) ; } if ( ! isset ( $ newServiceManager [ 'method' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: MISSING_KEY_ERROR , $ key , 'method' ) ) ; } elseif ( ! is_string ( $ newServiceManager [ 'method' ] ) ) { throw new InvalidArgumentException ( sprintf ( self :: VALUE_TYPE_ERROR , 'method' , gettype ( $ newServiceManager [ 'method' ] ) ) ) ; } $ serviceListener -> addServiceManager ( $ newServiceManager [ 'service_manager' ] , $ newServiceManager [ 'config_key' ] , $ newServiceManager [ 'interface' ] , $ newServiceManager [ 'method' ] ) ; } } return $ serviceListener ; }
Create the service listener service
58,880
public function setLogLevel ( $ level ) { $ this -> logLevelSet = true ; if ( $ level != $ this -> getLogLevel ( ) ) { $ this -> logLevel = $ level ; $ this -> info ( "Setting loglevel to $level" ) ; } }
Setter for loglevel .
58,881
private function log ( $ priority , $ msg , $ fileHandle = null ) { if ( $ priority [ 0 ] < $ this -> logLevel && $ fileHandle === null ) { return ; } $ logTime = time ( ) ; $ this -> logQueue [ ] = new Logger \ Message ( $ priority [ 1 ] , $ logTime , $ msg ) ; $ prioritystr = '[' . $ priority [ 1 ] . ']' ; $ timestr = '[' . date ( 'Y-m-d H:i:s - T' , $ logTime ) . ']' ; while ( strlen ( $ prioritystr ) < 7 ) { $ prioritystr .= ' ' ; } $ message = $ prioritystr . ' ' . $ timestr . ' ' . $ msg . "\n" ; $ message = getmypid ( ) . ': ' . $ message ; if ( defined ( 'STDERR' ) ) { fputs ( STDERR , getmypid ( ) . ': ' . $ prioritystr . ' ' . $ msg . "\n" ) ; } else { echo '<!-- LogMessage: ' . $ message . " ; } if ( $ this -> file != null ) { if ( $ fileHandle !== null ) { fputs ( $ fileHandle , $ message ) ; } else { error_log ( $ message , 3 , $ this -> file ) ; } } elseif ( $ fileHandle !== null ) { fputs ( $ fileHandle , $ message ) ; } if ( count ( $ this -> logQueue ) > $ this -> max ) { $ this -> flush ( ) ; } }
Add a new log message to the logger queue .
58,882
public function error ( $ msg , $ fileHandle = null ) { $ this -> log ( self :: $ logLevelError , $ msg , $ fileHandle ) ; }
Log a message with priority error .
58,883
public function warn ( $ msg , $ fileHandle = null ) { $ this -> log ( self :: $ logLevelWarn , $ msg , $ fileHandle = null ) ; }
Log a message with priority warn .
58,884
public function info ( $ msg , $ fileHandle = null ) { $ this -> log ( self :: $ logLevelInfo , $ msg , $ fileHandle = null ) ; }
Log a message with priority info .
58,885
public function debug ( $ msg , $ fileHandle = null ) { $ this -> log ( self :: $ logLevelDebug , $ msg , $ fileHandle ) ; }
Log a message with priority debug .
58,886
public function verbose ( $ msg , $ fileHandle = null ) { $ this -> log ( self :: $ logLevelVerbose , $ msg , $ fileHandle = null ) ; }
Log a message with priority verbose .
58,887
public function flush ( ) { if ( null == $ this -> buildLogFile ) { $ this -> resetLogQueue ( ) ; return ; } $ messageElements = array ( ) ; for ( $ i = count ( $ this -> logQueue ) - 1 ; $ i >= 0 ; -- $ i ) { $ message = $ this -> logQueue [ $ i ] ; $ messageString = '<message priority="' . $ message -> priority . '" ' ; $ messageString .= 'timestamp="' . $ message -> timestamp . '" ' ; $ messageString .= 'time="' . date ( 'Y-m-d H:i:s - T' , $ message -> timestamp ) . '"><![CDATA[' ; $ messageString .= base64_encode ( $ message -> message ) ; $ messageString .= ']]></message>' ; $ messageElements [ ] = $ messageString ; } $ previousLogMessages = '' ; $ dirName = dirname ( $ this -> buildLogFile ) ; if ( ! file_exists ( $ dirName ) ) { mkdir ( $ dirName , 0755 , true ) ; } if ( file_exists ( $ this -> buildLogFile ) ) { copy ( $ this -> buildLogFile , $ this -> buildLogFile . '.temp' ) ; } $ fh = fopen ( $ this -> buildLogFile , 'w+' ) ; if ( is_resource ( $ fh ) ) { fputs ( $ fh , '<?xml version="1.0"?>' ) ; fputs ( $ fh , "\n" ) ; fputs ( $ fh , '<build>' ) ; fputs ( $ fh , "\n" ) ; fputs ( $ fh , implode ( "\n" , $ messageElements ) ) ; fputs ( $ fh , "\n" ) ; if ( file_exists ( $ this -> buildLogFile . '.temp' ) ) { $ fht = fopen ( $ this -> buildLogFile . '.temp' , 'r' ) ; if ( is_resource ( $ fht ) ) { $ lineCounter = 0 ; while ( $ line = fgets ( $ fht ) ) { if ( $ lineCounter > 2 ) { fputs ( $ fh , $ line ) ; } ++ $ lineCounter ; } fclose ( $ fht ) ; unlink ( $ this -> buildLogFile . '.temp' ) ; } else { self :: error ( 'Cannot include previous log messages' ) ; } } else { fputs ( $ fh , '</build>' ) ; } fclose ( $ fh ) ; } else { self :: error ( 'Cannot open: ' . $ this -> buildLogFile . ' for writing.' ) ; } $ this -> resetLogQueue ( ) ; }
Flush the log queue to the log file .
58,888
public function save ( IEvent $ event ) { if ( null !== $ event -> getId ( ) ) { return $ event ; } $ event -> setId ( ( string ) Uuid :: uuid4 ( ) ) ; $ this -> events [ ] = $ event ; return $ event ; }
Save event .
58,889
private function CheckPublished ( ) { return PublishDateUtil :: IsPublishedNow ( $ this -> article -> GetPublish ( ) , $ this -> article -> GetPublishFrom ( ) , $ this -> article -> GetPublishTo ( ) ) ; }
Checks if current article is published at this moment
58,890
protected function triggerBeforeSave ( $ query , EntityInterface $ entity , array $ data ) { $ save = $ query instanceof Insert ? ( new Save ( $ entity , $ data ) ) -> setAction ( Save :: ACTION_BEFORE_INSERT ) : ( new Save ( $ entity , $ data ) ) -> setAction ( Save :: ACTION_BEFORE_UPDATE ) ; return Orm :: getEmitter ( $ this -> getEntityClassName ( ) ) -> emit ( $ save ) ; }
Triggers the before save event
58,891
protected function triggerAfterSave ( Save $ saveEvent , EntityInterface $ entity ) { $ afterSave = clone $ saveEvent ; $ action = $ afterSave -> getName ( ) == Save :: ACTION_BEFORE_INSERT ? Save :: ACTION_AFTER_INSERT : Save :: ACTION_AFTER_UPDATE ; $ afterSave -> setEntity ( $ entity ) -> setAction ( $ action ) ; return Orm :: getEmitter ( $ this -> getEntityClassName ( ) ) -> emit ( $ afterSave ) ; }
Triggers the after save event
58,892
protected function triggerDelete ( EntityInterface $ entity , $ action = Delete :: ACTION_BEFORE_DELETE ) { $ event = new Delete ( $ entity ) ; $ event -> setAction ( $ action ) ; return Orm :: getEmitter ( $ this -> getEntityClassName ( ) ) -> emit ( $ event ) ; }
Triggers the delete event with provided action
58,893
public function actionIndex ( ) { $ languageForm = Yii :: createObject ( [ 'class' => Language :: className ( ) , 'scenario' => 'create' ] ) ; $ filterModel = Yii :: createObject ( [ 'class' => Language :: className ( ) , 'scenario' => 'search' ] ) ; Yii :: $ app -> view -> title = Yii :: t ( 'multilang' , 'Languages' ) ; return $ this -> render ( 'index' , [ 'filterModel' => $ filterModel , 'dataProvider' => $ filterModel -> search ( Yii :: $ app -> request -> get ( ) ) , 'languageForm' => $ languageForm ] ) ; }
Show list of blacklisted words
58,894
public function actionCreate ( ) { $ languageForm = Yii :: createObject ( [ 'class' => Language :: className ( ) , 'scenario' => 'create' ] ) ; if ( $ languageForm -> load ( Yii :: $ app -> request -> post ( ) ) && $ languageForm -> save ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'multilang' , 'Language was created.' ) ) ; } else { Yii :: $ app -> getSession ( ) -> setFlash ( 'danger' , Yii :: t ( 'multilang' , 'Language creation failed.' ) ) ; } return $ this -> redirect ( Url :: toRoute ( [ 'index' ] ) ) ; }
Add new language
58,895
protected function findLanguage ( $ code ) { $ language = Language :: findOne ( $ code ) ; if ( $ language === null ) { throw new \ yii \ web \ NotFoundHttpException ( 'The requested language does not exist' ) ; } return $ language ; }
Finds the Language model based on its code value . If the model is not found a 404 HTTP exception will be thrown .
58,896
public function persist ( object $ entity ) : self { $ identity = $ this -> extractIdentity ( $ entity ) ; if ( ! $ this -> container -> contains ( $ identity ) ) { $ meta = ( $ this -> metadata ) ( get_class ( $ entity ) ) ; $ this -> container -> push ( $ identity , $ entity , State :: new ( ) ) ; $ this -> generators -> get ( $ meta -> identity ( ) -> type ( ) ) -> add ( $ identity ) ; } return $ this ; }
Add the given entity to the ones to be persisted
58,897
public function get ( string $ class , Identity $ identity ) : object { $ meta = ( $ this -> metadata ) ( $ class ) ; $ generator = $ this -> generators -> get ( $ meta -> identity ( ) -> type ( ) ) ; if ( $ generator -> knows ( $ identity -> value ( ) ) ) { $ identity = $ generator -> for ( $ identity -> value ( ) ) ; } else { $ generator -> add ( $ identity ) ; } if ( $ this -> container -> contains ( $ identity ) ) { return $ this -> container -> get ( $ identity ) ; } $ match = ( $ this -> match ) ( $ meta , $ identity ) ; $ entities = $ this -> execute ( $ match -> query ( ) , $ match -> variables ( ) ) ; if ( $ entities -> size ( ) !== 1 ) { throw new EntityNotFound ; } return $ entities -> current ( ) ; }
Return the entity with the given identifier
58,898
public function remove ( object $ entity ) : self { $ identity = $ this -> extractIdentity ( $ entity ) ; try { $ state = $ this -> container -> stateFor ( $ identity ) ; switch ( $ state ) { case State :: new ( ) : $ this -> container -> push ( $ identity , $ entity , State :: removed ( ) ) ; break ; case State :: managed ( ) : $ this -> container -> push ( $ identity , $ entity , State :: toBeRemoved ( ) ) ; break ; } } catch ( IdentityNotManaged $ e ) { } return $ this ; }
Plan the given entity to be removed
58,899
public function detach ( object $ entity ) : self { $ this -> container -> detach ( $ this -> extractIdentity ( $ entity ) ) ; return $ this ; }
Detach the given entity from the unit of work