idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
44,000
public function getFldTypeForPhp ( ) { $ type = 'mixed' ; switch ( $ this -> getFldType ( ) ) { case FFCST :: TYPE_INTEGER : case FFCST :: TYPE_BIGINT : $ type = 'int' ; break ; case FFCST :: TYPE_DATETIME : case FFCST :: TYPE_MD5 : case FFCST :: TYPE_STRING : $ type = 'string' ; break ; case FFCST :: TYPE_BOOLEAN : $ type = 'bool' ; break ; } return $ type ; }
Convert local type to php
44,001
public function getFldTypeForClass ( ) { $ type = 'TYPE_STRING' ; switch ( $ this -> getFldType ( ) ) { case FFCST :: TYPE_INTEGER : $ type = 'TYPE_INTEGER' ; break ; case FFCST :: TYPE_BIGINT : $ type = 'TYPE_BIGINT' ; break ; case FFCST :: TYPE_DATETIME : $ type = 'TYPE_DATETIME' ; break ; case FFCST :: TYPE_MD5 : $ type = 'TYPE_MD5' ; break ; case FFCST :: TYPE_STRING : $ type = 'TYPE_STRING' ; break ; case FFCST :: TYPE_BOOLEAN : $ type = 'TYPE_BOOLEAN' ; break ; case FFCST :: TYPE_BLOB : $ type = 'TYPE_BLOB' ; break ; } return $ type ; }
Convert local type to class
44,002
public static function getFromPDO ( array $ p_pdo_description ) { $ me = self :: getNew ( ) ; if ( is_array ( $ p_pdo_description ) ) { if ( array_key_exists ( 'name' , $ p_pdo_description ) ) { $ me -> setFldName ( $ p_pdo_description [ 'name' ] ) ; } if ( array_key_exists ( 'len' , $ p_pdo_description ) ) { $ me -> setFldLength ( $ p_pdo_description [ 'len' ] ) ; } if ( array_key_exists ( 'precision' , $ p_pdo_description ) ) { $ me -> setFldComplement ( $ p_pdo_description [ 'precision' ] ) ; } $ me -> setFldType ( FFCST :: TYPE_STRING ) ; if ( array_key_exists ( 'native_type' , $ p_pdo_description ) ) { switch ( strtoupper ( $ p_pdo_description [ 'native_type' ] ) ) { case 'LONGLONG' : $ me -> setFldType ( FFCST :: TYPE_BIGINT ) ; break ; case 'TINY' : $ me -> setFldType ( FFCST :: TYPE_INTEGER ) ; break ; case 'BLOB' : $ me -> setFldType ( FFCST :: TYPE_BLOB ) ; break ; case 'TIMESTAMP' : $ me -> setFldType ( FFCST :: TYPE_DATETIME ) ; break ; } } if ( array_key_exists ( 'flags' , $ p_pdo_description ) ) { if ( is_array ( $ p_pdo_description [ 'flags' ] ) ) { foreach ( $ p_pdo_description [ 'flags' ] as $ idx => $ flag ) { if ( $ flag == 'primary_key' ) { $ me -> setFldPrimary ( true ) ; } if ( $ flag == 'not_null' ) { $ me -> setFldRequired ( true ) ; } } } } } return $ me ; }
Get new from pdo metadatas
44,003
public function getBody ( ) { $ body = json_decode ( $ this -> response -> getBody ( ) , true ) ; if ( ! $ body ) { throw new ResponseWithoutBody ( 'Response without body' ) ; } if ( ! $ this -> transformer ) { return $ body ; } return $ this -> transformer -> transformData ( $ body ) ; }
Return a transformed response .
44,004
public function move ( $ player , $ move ) { $ this -> checkPlayer ( $ player ) ; $ this -> checkMove ( $ move ) ; $ hand = $ this -> grid [ $ player ] [ 'seeds' ] [ $ move ] ; $ this -> grid [ $ player ] [ 'seeds' ] [ $ move ] = 0 ; $ row = $ player ; $ box = $ move ; while ( $ hand > 0 ) { if ( 0 === $ row ) { if ( 0 === $ box ) { $ row = 1 ; } else { $ box -- ; } } else { if ( 5 === $ box ) { $ row = 0 ; } else { $ box ++ ; } } if ( ( $ row !== $ player ) || ( $ box !== $ move ) ) { $ hand -- ; $ this -> grid [ $ row ] [ 'seeds' ] [ $ box ] ++ ; } } if ( ( 0 === $ row && 0 === $ box ) || ( 1 === $ row && 5 === $ box ) ) { if ( ( $ row !== $ player ) && self :: allSeedsVulnerable ( $ this -> grid [ $ row ] [ 'seeds' ] ) ) { return $ this ; } } while ( ( $ row !== $ player ) && in_array ( $ this -> grid [ $ row ] [ 'seeds' ] [ $ box ] , array ( 2 , 3 ) ) ) { $ this -> grid [ $ player ] [ 'attic' ] += $ this -> grid [ $ row ] [ 'seeds' ] [ $ box ] ; $ this -> grid [ $ row ] [ 'seeds' ] [ $ box ] = 0 ; if ( 0 === $ row ) { if ( 5 === $ box ) { $ row = 1 ; } else { $ box ++ ; } } else { if ( 0 === $ box ) { $ row = 0 ; } else { $ box -- ; } } } return $ this ; }
Play a move naively . Do not check player turn .
44,005
public function play ( $ player , $ move ) { if ( ! $ this -> isPlayerTurn ( $ player ) ) { throw new AwaleException ( 'Not your turn.' ) ; } if ( 0 === $ this -> grid [ $ player ] [ 'seeds' ] [ $ move ] ) { throw new AwaleException ( 'This container is empty.' ) ; } $ this -> checkMustFeedOpponentRule ( $ player , $ move ) ; $ this -> move ( $ player , $ move ) -> setLastMove ( array ( 'player' => $ player , 'move' => $ move , ) ) -> changePlayerTurn ( ) ; if ( ! $ this -> hasSeeds ( 1 - $ this -> currentPlayer ) && ! $ this -> canFeedOpponent ( $ this -> currentPlayer ) ) { $ this -> storeRemainingSeeds ( $ this -> currentPlayer ) ; } return $ this ; }
Play a turn check current player turn .
44,006
private function getPlayerWithMoreThanHalfSeeds ( ) { $ seedsToWin = $ this -> getSeedsNeededToWin ( ) ; if ( $ this -> grid [ Awale :: PLAYER_0 ] [ 'attic' ] > $ seedsToWin ) { return self :: PLAYER_0 ; } if ( $ this -> grid [ Awale :: PLAYER_1 ] [ 'attic' ] > $ seedsToWin ) { return self :: PLAYER_1 ; } return null ; }
Check if a player reached the seeds number to win and returns it . Or return null .
44,007
public function getWinner ( ) { if ( ! $ this -> isGameOver ( ) ) { return null ; } if ( $ this -> getScore ( self :: PLAYER_0 ) === $ this -> getScore ( self :: PLAYER_1 ) ) { return self :: DRAW ; } elseif ( $ this -> getScore ( self :: PLAYER_0 ) > $ this -> getScore ( self :: PLAYER_1 ) ) { return self :: PLAYER_0 ; } else { return self :: PLAYER_1 ; } }
Returns the winner or null if game not over .
44,008
public function getTrace ( $ trace = array ( ) ) { $ traceMessage = '' ; foreach ( $ trace as $ t ) { $ traceMessage .= sprintf ( ' at %s line %s' , $ t [ 'file' ] , $ t [ 'line' ] ) . "\n" ; } return $ traceMessage ; }
Implodes the trace into a readable string representation
44,009
public function getStatusCode ( FlattenException $ exception ) { $ str = '' ; if ( method_exists ( $ exception , 'getStatusCode' ) == true ) { $ str = $ exception -> getStatusCode ( ) ; } elseif ( method_exists ( $ exception , 'getCode' ) == true ) { $ str = $ exception -> getCode ( ) ; } return $ str ; }
Attempts to extract a nice exception code string
44,010
public function addConfig ( ParametersConfig $ config ) : void { array_unshift ( $ this -> configs , $ config ) ; foreach ( $ this -> info -> getNames ( ) as $ name ) { if ( $ config -> hasValue ( $ name ) ) { $ this -> missingValues [ $ name ] = false ; } } }
Add a parameter configuration that may provide values and type hints .
44,011
public function getType ( string $ name ) : ? string { if ( ! $ this -> info -> includes ( $ name ) ) { throw ArgumentListException :: parameterNotFound ( $ name ) ; } foreach ( $ this -> configs as $ config ) { if ( $ config -> hasType ( $ name ) ) { return $ config -> getType ( $ name ) ; } } return $ this -> info -> getType ( $ name ) ; }
Get the type of an argument .
44,012
public function getOptional ( int $ type = AII :: TYPE_BUILTIN | AII :: TYPE_UNTYPED | AII :: TYPE_CLASS ) : array { $ includeUntyped = ( $ type & AII :: TYPE_UNTYPED ) === AII :: TYPE_UNTYPED ; $ includeBuiltin = ( $ type & AII :: TYPE_BUILTIN ) === AII :: TYPE_BUILTIN ; $ includeClass = ( $ type & AII :: TYPE_CLASS ) === AII :: TYPE_CLASS ; $ names = [ ] ; foreach ( $ this -> info -> getNames ( ) as $ name ) { if ( $ this -> info -> isRequired ( $ name ) ) { continue ; } if ( $ this -> hasExplicitValue ( $ name ) ) { continue ; } $ type = $ this -> getType ( $ name ) ; if ( ! $ includeUntyped && is_null ( $ type ) ) { continue ; } if ( ! $ includeBuiltin && ! is_null ( $ type ) && Reflector :: isBuiltinType ( $ type ) ) { continue ; } if ( ! $ includeClass && ! is_null ( $ type ) && ! Reflector :: isBuiltinType ( $ type ) ) { continue ; } $ names [ ] = $ name ; } return $ names ; }
Get the names of optional arguments that are not yet provided .
44,013
public function getMissing ( int $ type = AII :: TYPE_BUILTIN | AII :: TYPE_UNTYPED | AII :: TYPE_CLASS ) : array { $ includeUntyped = ( $ type & AII :: TYPE_UNTYPED ) === AII :: TYPE_UNTYPED ; $ includeBuiltin = ( $ type & AII :: TYPE_BUILTIN ) === AII :: TYPE_BUILTIN ; $ includeClass = ( $ type & AII :: TYPE_CLASS ) === AII :: TYPE_CLASS ; $ names = [ ] ; foreach ( $ this -> info -> getNames ( ) as $ name ) { if ( ! $ this -> missingValues [ $ name ] ) { continue ; } $ type = $ this -> getType ( $ name ) ; if ( ! $ includeUntyped && is_null ( $ type ) ) { continue ; } $ isBuiltin = Reflector :: isBuiltinType ( $ type ) ; if ( ! $ includeBuiltin && $ isBuiltin && ! is_null ( $ type ) ) { continue ; } if ( ! $ includeClass && ! $ isBuiltin && ! is_null ( $ type ) ) { continue ; } $ names [ ] = $ name ; } return $ names ; }
Get the names of missing arguments .
44,014
public function setAccessTokenFromProfile ( TwitterProfile $ profile ) { $ tokens = $ profile -> get ( [ 'access_token' , 'access_token_secret' ] ) ; if ( ! empty ( $ tokens [ 'access_token' ] ) ) { $ this -> app [ 'twitter' ] -> setTokens ( $ tokens [ 'access_token' ] , $ tokens [ 'access_token_secret' ] ) ; $ this -> profile = $ profile ; } else { $ referencingProfile = $ profile -> relation ( 'most_recently_referenced_by' ) ; $ tokens = $ referencingProfile -> get ( [ 'access_token' , 'access_token_secret' ] ) ; if ( $ referencingProfile -> exists ( ) && ! empty ( $ tokens [ 'access_token' ] ) ) { $ this -> app [ 'twitter' ] -> setTokens ( $ tokens [ 'access_token' ] , $ tokens [ 'access_token_secret' ] ) ; $ this -> profile = $ referencingProfile ; } } return $ this ; }
Sets the appropriate Twitter API access token using a given Twitter Profile
44,015
protected function getReference ( $ name ) { $ default = $ this -> defaultValue ( $ name ) ; if ( false !== getenv ( $ name ) ) { return getenv ( $ name ) ; } elseif ( null !== $ default ) { return $ default ; } elseif ( '_' === $ name [ 0 ] ) { return $ this -> matchGlobalVars ( $ name ) ; } else { return null ; } }
Find the env value base on the name
44,016
protected function matchGlobalVars ( $ name ) { if ( false !== strpos ( $ name , '.' ) ) { list ( $ n , $ k ) = explode ( '.' , $ name , 2 ) ; if ( isset ( $ GLOBALS [ $ n ] ) && isset ( $ GLOBALS [ $ n ] [ $ k ] ) ) { return $ GLOBALS [ $ n ] [ $ k ] ; } } return '' ; }
Match with _SERVER . HTTP_HOST etc .
44,017
protected function setEnv ( $ key , $ val , $ overload ) { if ( $ overload || false === getenv ( $ key ) ) { putenv ( "$key=$val" ) ; $ _ENV [ $ key ] = $ val ; } }
Set the env pair
44,018
public static function setGlob_step ( ) { $ project = $ _POST [ 'project_name' ] ; $ name = $ _POST [ 'dev_name' ] ; if ( isset ( $ _POST [ 'ckeck_loggin' ] ) ) { $ loggin = true ; } else { $ loggin = false ; } if ( isset ( $ _POST [ 'ckeck_maintenance' ] ) ) { $ maintenance = 'true' ; } else { $ maintenance = 'false' ; } if ( isset ( $ _POST [ 'ckeck_search' ] ) ) { $ robot = true ; } else { $ robot = false ; } if ( ! Application :: $ isTest ) { $ appCont = App :: set ( $ name , $ project , true ) ; $ translatorCont = Translator :: set ( 'en' ) ; $ logginCont = Loggin :: set ( $ loggin ) ; Robots :: set ( $ robot ) ; file_put_contents ( Application :: $ root . 'config/app.php' , $ appCont , 0 ) ; file_put_contents ( Application :: $ root . 'config/lang.php' , $ translatorCont , 0 ) ; file_put_contents ( Application :: $ root . 'config/loggin.php' , $ logginCont , 0 ) ; echo 'true' ; } }
set global setup .
44,019
public static function page ( $ page = null ) { if ( $ page !== null ) { self :: $ _page = $ page ; } return self :: $ _page ; }
Get or set the current page .
44,020
public static function startPage ( $ page = null ) { if ( $ page !== null ) { self :: $ _startPage = $ page ; } return self :: $ _startPage ; }
Get or set the start page .
44,021
protected function getHint ( ) { $ groups = collect ( config ( 'flame' ) ) -> mapWithKeys ( function ( $ item , $ key ) { return [ $ key => $ item [ 'namespace' ] ] ; } ) ; $ namespaces = $ groups -> values ( ) ; $ matchedNamespace = Str :: longestMatch ( $ namespaces -> toArray ( ) , $ this -> controllerNamespace ( ) ) ; if ( is_null ( $ matchedNamespace ) ) { throw FlameException :: namespaceNotFound ( $ this -> controllerNamespace ( ) ) ; } return $ groups -> flip ( ) [ $ matchedNamespace ] ; }
Computes the View hint based in the Controller namespace and the Flame configuration .
44,022
protected function getIntermediatePath ( $ hint ) { $ namespace = config ( "flame.{$hint}.namespace" ) ; $ namespaceTail = substr ( $ this -> controllerNamespace ( ) , strlen ( $ namespace ) + 1 ) ; return collect ( explode ( '\\' , $ namespaceTail ) ) -> splice ( 0 , - 2 ) -> implode ( '.' ) ; }
Resolves the view intermediate path .
44,023
protected function createScreenshot ( ) { $ image = imagecreatefromstring ( $ this -> webDriver -> screenshotAsImage ( ) ) ; if ( false === $ image ) { throw new WebDriver_Exception ( "Invalid screenshot data" ) ; } return $ image ; }
Takes screenshot and returns image resource .
44,024
public static function getBackend ( ) { if ( ! is_object ( self :: $ backend ) ) { self :: $ backend = new \ Monolog \ Logger ( self :: $ name ) ; self :: $ backend -> pushHandler ( self :: getStreamHandler ( ) ) ; self :: setLogFormat ( self :: $ logFormat ) ; } return self :: $ backend ; }
Returns a singleton instance of a monolog logger .
44,025
public static function setLogFormat ( $ format ) { self :: $ logFormat = $ format ; self :: getStreamHandler ( ) -> setFormatter ( new LineFormatter ( $ format ) ) ; }
Sets up the log format of the log lines written to the log files . This method actually creates a new monolog LineFormatter and passes the format argument directly to it . Due to this implementation the format it accepts is exactly what monolog uses .
44,026
private static function getStreamHandler ( ) { if ( ! is_object ( self :: $ stream ) ) { self :: $ stream = new StreamHandler ( self :: $ logFilePath , self :: $ minimumLevel ) ; } return self :: $ stream ; }
Returns a singleton instance of the monolog stream handler .
44,027
public static function init ( $ path , $ name = 'log' , $ minimumLevel = self :: DEBUG ) { if ( $ path === 'php://output' ) { self :: $ active = true ; } else if ( is_writable ( $ path ) ) { self :: $ active = true ; } else { self :: $ active = false ; } self :: $ backend = null ; self :: $ stream = null ; self :: $ name = $ name ; self :: $ logFilePath = $ path ; self :: $ minimumLevel = $ minimumLevel ; }
Initializes the logger .
44,028
public static function log ( $ level , $ message ) { if ( self :: $ active ) { self :: getBackend ( ) -> addRecord ( $ level , $ message ) ; } }
Write out the log message to the log file at the specified log level .
44,029
public function currentPath ( $ params = null , $ withParams = true , array $ queries = null ) { $ base = Base :: instance ( ) ; return $ this -> build ( $ base [ 'ALIAS' ] , ( ( array ) $ params ) + ( $ withParams ? $ base [ 'PARAMS' ] : [ ] ) , $ queries ) ; }
Get current path
44,030
public static function isHtmlView ( ) { if ( self :: $ _isHtmlView === NULL ) { self :: $ _isHtmlView = false ; $ view = Registry :: get ( 'view' ) ; if ( $ view === NULL ) { $ template = ViewAbstract :: getTemplateConfig ( ) ; if ( is_array ( $ template ) and isset ( $ template [ 'type' ] ) and $ template [ 'type' ] === ViewInterface :: TYPE_HTML ) { self :: $ _isHtmlView = true ; } } else if ( $ view instanceof View and $ view -> getType ( ) == ViewInterface :: TYPE_HTML ) { self :: $ _isHtmlView = true ; } } return self :: $ _isHtmlView ; }
Check if the view is of HTML type .
44,031
public static function log ( $ pMessage ) { if ( is_array ( $ pMessage ) or is_object ( $ pMessage ) ) { $ message = json_encode ( $ pMessage ) ; } else { $ message = ( string ) $ pMessage ; } $ logId = mt_rand ( ) ; if ( Agl :: isInitialized ( ) ) { $ message = '[agl_' . $ logId . '] [' . date ( 'Y-m-d H:i:s' ) . '] [' . APP_PATH . '] ' . $ message . "\n" ; $ dir = APP_PATH . Agl :: APP_VAR_DIR . sprintf ( self :: LOG_DIR , date ( 'Y' ) , date ( 'm' ) ) ; if ( ! is_writable ( APP_PATH . Agl :: APP_VAR_DIR ) or ( ! is_dir ( $ dir ) and ! mkdir ( $ dir , 0777 , true ) ) or ! is_writable ( $ dir ) ) { return 0 ; } $ file = $ dir . sprintf ( self :: LOG_FILE , date ( 'Y-m-d' ) ) ; $ logged = FileData :: write ( $ file , $ message , true ) ; if ( ! $ logged ) { return 0 ; } } else { return 0 ; } return $ logId ; }
Log a message in the syslog .
44,032
public static function getInfos ( ) { $ xDebugEnabled = self :: isXdebugEnabled ( ) ; $ debugInfos = array ( ) ; $ debugInfos [ 'app' ] [ 'path' ] = APP_PATH ; $ debugInfos [ 'app' ] [ 'cache' ] = Agl :: app ( ) -> isCacheEnabled ( ) ; if ( $ xDebugEnabled ) { $ debugInfos [ 'time' ] = xdebug_time_index ( ) ; $ debugInfos [ 'memory' ] = xdebug_peak_memory_usage ( ) ; } if ( Agl :: app ( ) -> getDb ( ) !== NULL ) { $ debugInfos [ 'db' ] [ 'db_engine' ] = Agl :: app ( ) -> getConfig ( 'main/db/engine' ) ; $ debugInfos [ 'db' ] [ 'queries' ] = Agl :: app ( ) -> getDb ( ) -> countQueries ( ) ; } $ debugInfos [ 'opcache' ] = ( ini_get ( 'opcache.enable' ) ) ? true : false ; $ debugInfos [ 'apcu' ] = ( ini_get ( 'apc.enabled' ) ) ? true : false ; $ debugInfos [ 'xdebug' ] = $ xDebugEnabled ; $ debugInfos [ 'more_modules' ] = Agl :: getLoadedModules ( ) ; $ debugInfos [ 'request' ] = Agl :: getRequest ( ) ; return $ debugInfos ; }
Return some debug informations about the running script .
44,033
public static function check ( ) { if ( R :: count ( "permission" ) < 1 ) { $ role = R :: dispense ( "permission" ) ; $ role -> name = "guest" ; R :: store ( $ role ) ; } }
checks if table is created
44,034
protected function _render ( $ context = null ) { if ( $ context === null ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Cannot render with a null context' ) , null , null , $ context ) ; } try { $ expr = $ this -> _containerGet ( $ context , ExprCtx :: K_EXPRESSION ) ; $ result = $ this -> _renderExpression ( $ expr , $ context ) ; return $ result ; } catch ( NotFoundExceptionInterface $ notFoundException ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Context does not contain an expression' ) , null , $ notFoundException , $ context ) ; } }
Renders the given context as an expression .
44,035
public static function options2html ( array $ options = [ ] , $ selectedValue = null ) { $ buffer = [ ] ; foreach ( $ options as $ key => $ value ) { if ( is_array ( $ value ) ) { $ optgroupOptions = static :: options2html ( $ value , $ selectedValue ) ; $ buffer [ ] = "<optgroup label='$key'>$optgroupOptions</options>" ; } else { $ selected = static :: selected ( $ selectedValue , $ value ) ; $ buffer [ ] = "<option value='$value' $selected>$key</option>" ; } } $ html = implode ( '' , $ buffer ) ; return $ html ; }
generate html code by options array
44,036
protected function getFreshApplicationRoutes ( ) { $ app = require $ this -> laravel -> basePath ( ) . '/bootstrap/app.php' ; $ app -> make ( 'Illuminate\Contracts\Console\Kernel' ) -> bootstrap ( ) ; return $ app [ 'router' ] -> getRoutes ( ) ; }
Boot a fresh copy of the application and get the routes .
44,037
protected function registerNavigation ( ) { do_action ( "before_theme_register_navigation" ) ; foreach ( $ this -> getConfig ( "navigation" ) as $ name => $ description ) : register_nav_menu ( $ name , $ description ) ; endforeach ; do_action ( "after_theme_register_navigation" ) ; }
Register navigation menus
44,038
public function getRenderer ( ) { $ locator = $ this -> getServiceLocator ( ) ; if ( null === $ this -> renderer && $ locator -> has ( Renderer \ RendererInterface :: class ) ) { $ this -> setRenderer ( $ locator -> get ( Renderer \ RendererInterface :: class ) ) ; } return $ this -> renderer ; }
Retrieve renderer instance
44,039
public function injectRenderer ( $ helper ) { $ renderer = $ this -> getRenderer ( ) ; if ( null === $ renderer ) { return ; } $ helper -> setView ( $ renderer ) ; }
Inject a helper instance with the registered renderer
44,040
public function injectTranslator ( $ helper ) { if ( ! $ helper instanceof TranslatorAwareInterface ) { return ; } $ locator = $ this -> getServiceLocator ( ) ; if ( ! $ locator ) { return ; } if ( $ locator -> has ( 'MvcTranslator' ) ) { $ helper -> setTranslator ( $ locator -> get ( 'MvcTranslator' ) ) ; return ; } if ( $ locator -> has ( TranslatorInterface :: class ) ) { $ helper -> setTranslator ( $ locator -> get ( TranslatorInterface :: class ) ) ; return ; } if ( $ locator -> has ( 'Translator' ) ) { $ helper -> setTranslator ( $ locator -> get ( 'Translator' ) ) ; return ; } }
Inject a helper instance with the registered translator
44,041
public function setDirPermissions ( $ permissions ) { if ( ! is_int ( $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid directory permissins provided; must be an ' . 'integer, "%s" received.' , is_object ( $ permissions ) ? get_class ( $ permissions ) : gettype ( $ permissions ) ) ) ; } if ( ! ( 0b100000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for reading.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b010000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'Directories will not available for writing.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b001000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid permissions "%s" for directories. ' . 'The content of directories will not available.' , decoct ( $ permissions ) ) ) ; } $ this -> dirPermissions = $ permissions ; }
Sets the permissions of new directories .
44,042
function _getName ( $ string ) { if ( preg_match ( '/name=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is' , $ string , $ match ) ) { $ val_match = trim ( $ match [ 1 ] ) ; $ val_match = trim ( $ val_match , '"\'' ) ; unset ( $ string ) ; return trim ( $ val_match , '"' ) ; } return false ; }
gets the name
44,043
function _getValue ( $ string ) { if ( preg_match ( '/value=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is' , $ string , $ match ) ) { $ val_match = trim ( $ match [ 1 ] ) ; $ val_match = trim ( $ val_match , '"\'' ) ; unset ( $ string ) ; return $ val_match ; } return false ; }
gets the value
44,044
function _getId ( $ string ) { if ( preg_match ( '/id=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is' , $ string , $ match ) ) { $ val_match = trim ( $ match [ 1 ] ) ; $ val_match = trim ( $ val_match , '"\'' ) ; unset ( $ string ) ; return $ val_match ; } return false ; }
gets the id
44,045
function _getClass ( $ string ) { if ( preg_match ( '/class=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is' , $ string , $ match ) ) { $ val_match = trim ( $ match [ 1 ] ) ; $ val_match = trim ( $ val_match , '"\'' ) ; unset ( $ string ) ; return $ val_match ; } return false ; }
gets the class
44,046
public function beforeDelete ( $ subject , \ Magento \ Quote \ Api \ Data \ CartInterface $ quote ) { $ quoteId = $ quote -> getId ( ) ; $ this -> daoPartialQuote -> deleteById ( $ quoteId ) ; return [ $ quote ] ; }
Delete partial payment registry data before quote deletion .
44,047
public function setParameter ( $ key , $ value ) { if ( is_bool ( $ value ) ) $ value = ( $ value ? 'true' : 'false' ) ; $ this -> parameters [ $ key ] = $ value ; }
Set a parameter to be used for the request .
44,048
public function get ( ) { $ this -> appendApiKeyToRequestParameters ( ) ; $ target = $ this -> generateRequestTarget ( ) ; return $ this -> performGetRequest ( $ target , $ this -> parameters ) ; }
Execute the request and return the parsed response .
44,049
protected function performGetRequest ( $ target , $ parameters ) { $ response = $ this -> doGetRequest ( $ target , $ parameters ) ; $ result = $ this -> parseResponse ( $ response ) ; return $ result ; }
Orchestrates the GET request and response parsing .
44,050
private function doGetRequest ( $ target , $ parameters ) { $ guzzle = $ this -> client -> getGuzzle ( ) ; $ response = $ guzzle -> get ( $ target , [ 'query' => $ parameters ] ) ; return $ response ; }
Executes the GET request over the given target with the given GET parameters .
44,051
private function appendApiKeyToRequestParameters ( ) { if ( ! $ this -> client -> getApiKey ( ) ) throw new AuthorizationException ( 'Missing API key.' ) ; $ this -> setParameter ( Client :: API_KEY_PARAM_NAME , $ this -> client -> getApiKey ( ) ) ; }
Gets the API key from the Client instance and adds it to the request parameters . An AuthorizationException is thrown when the API key is missing from the Client .
44,052
public function driver ( $ driver = '' , array $ configs = [ ] ) { $ driverList = $ this -> defaultDriverList ; if ( isset ( $ driverList [ $ driver ] ) ) { $ driver = $ driverList [ $ driver ] ; $ driver = new $ driver ( $ configs ) ; if ( $ driver instanceof DriverInterface ) { return $ driver ; } else { throw new DriverException ( sprintf ( 'your %s driver has not Driver Interface' , get_class ( $ driver ) ) ) ; } } else { throw new DriverNotInstalledException ( sprintf ( 'your %s driver is not installed' , $ driver ) ) ; } }
select a driver
44,053
public function send ( $ name = '' , callable $ callback ) { $ configs = Config :: get ( $ name ) ; $ driver = $ this -> driver ( isset ( $ configs [ 'driver' ] ) ? $ configs [ 'driver' ] : 'swift' , $ configs ) ; return $ callback ( $ driver ) ; }
send the mail with config name and closure callback
44,054
public function getAvailableTemplateLayouts ( $ pageUid ) { $ templateLayouts = [ ] ; if ( isset ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXT' ] [ 'dvoconnector' ] [ 'templateLayouts' ] ) && is_array ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXT' ] [ 'dvoconnector' ] [ 'templateLayouts' ] ) ) { $ templateLayouts = $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXT' ] [ 'dvoconnector' ] [ 'templateLayouts' ] ; } foreach ( $ this -> getTemplateLayoutsFromTsConfig ( $ pageUid ) as $ templateKey => $ title ) { if ( GeneralUtility :: isFirstPartOfStr ( $ title , '--div--' ) ) { $ optGroupParts = GeneralUtility :: trimExplode ( ',' , $ title , true , 2 ) ; $ title = $ optGroupParts [ 1 ] ; $ templateKey = $ optGroupParts [ 0 ] ; } $ templateLayouts [ ] = [ $ title , $ templateKey ] ; } return $ templateLayouts ; }
Get available template layouts for a certain page
44,055
protected function getTemplateLayoutsFromTsConfig ( $ pageUid ) { $ templateLayouts = [ ] ; $ pagesTsConfig = BackendUtility :: getPagesTSconfig ( $ pageUid ) ; if ( isset ( $ pagesTsConfig [ 'tx_dvoconnector.' ] [ 'templateLayouts.' ] ) && is_array ( $ pagesTsConfig [ 'tx_dvoconnector.' ] [ 'templateLayouts.' ] ) ) { $ templateLayouts = $ pagesTsConfig [ 'tx_dvoconnector.' ] [ 'templateLayouts.' ] ; } return $ templateLayouts ; }
Get template layouts defined in TsConfig
44,056
public function findSameCategoryProduct ( $ product , $ direction ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'p' ) -> andWhere ( 'p.category = :category' ) -> setMaxResults ( 1 ) -> setParameter ( 'category' , $ product -> getCategory ( ) ) ; if ( 'next' == $ direction ) { $ qb -> andWhere ( 'p.id > :id' ) -> orderBy ( 'p.id' , 'asc' ) ; } else { $ qb -> andWhere ( 'p.id < :id' ) -> orderBy ( 'p.id' , 'desc' ) ; } $ qb -> setParameter ( 'id' , $ product -> getId ( ) ) ; if ( 0 == count ( $ qb -> getQuery ( ) -> getResult ( ) ) ) { return null ; } return $ qb -> getQuery ( ) -> getSingleResult ( ) ; }
Find a product from the same category
44,057
public function findNews ( $ family , $ limit = null ) { $ qb = $ this -> getQueryBuilder ( ) -> orderBy ( 'p.highlighted' , 'desc' ) -> addOrderBy ( 'p.createdAt' , 'desc' ) ; if ( ! is_null ( $ family ) ) { $ qb -> innerJoin ( 'p.category' , 'c' ) -> innerJoin ( 'c.parentCategory' , 'pc' ) -> andWhere ( 'pc.family = :family' ) -> setParameter ( 'family' , $ family ) ; } if ( ! is_null ( $ limit ) ) { $ qb -> setMaxResults ( $ limit ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find new products
44,058
public function findAttributeValues ( $ product ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'a.name attributeName, av.name, i.path imagePath' ) ; $ qb -> join ( 'p.attributeValues' , 'av' ) -> join ( 'av.attribute' , 'a' ) -> leftJoin ( 'av.image' , 'i' ) ; $ qb -> andWhere ( 'p = :product' ) -> setParameter ( 'product' , $ product ) ; $ qb -> orderBy ( 'a.order' , 'asc' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find sorted attribute values
44,059
public function getQueryProductsAssembly ( ) { $ category_id = $ this -> getEntityManager ( ) -> getRepository ( 'EcommerceBundle:Category' ) -> AssemblyCategory ( ) ; return $ this -> createQueryBuilder ( 'p' ) -> where ( 'p.category = :category_id' ) -> setParameter ( 'category_id' , $ category_id ) ; }
Return products of the assembly category
44,060
private function start ( $ message , $ hook = true ) { if ( ! isset ( $ this -> status ) ) $ this -> status = new \ SplStack ; if ( $ hook ) $ this -> applyHooks ( 'Pre' , $ message ) ; $ this -> status -> push ( [ microtime ( true ) , $ message , ] ) ; if ( $ this -> verbose >= 1 ) echo PHP_EOL , str_repeat ( "\t" , $ this -> status -> count ( ) - 1 ) , $ message , '... ' ; return $ this ; }
Report current action being taken
44,061
protected final static function rglob ( $ pattern , $ flags = 0 ) { $ files = glob ( $ pattern , $ flags ) ; foreach ( glob ( dirname ( $ pattern ) . DIRECTORY_SEPARATOR . '*' , GLOB_ONLYDIR | GLOB_NOSORT ) as $ dir ) $ files = array_merge ( self :: rglob ( $ dir . DIRECTORY_SEPARATOR . basename ( $ pattern ) , $ flags ) , $ files ) ; return $ files ; }
Recursively gets files in path
44,062
protected final static function readyDir ( $ dir ) { if ( is_file ( $ dir ) ) return false ; if ( ! is_dir ( dirname ( $ dir ) ) ) return mkdir ( dirname ( $ dir ) , 0777 , true ) ; return true ; }
Makes all directories leading up to given file or folder
44,063
protected final static function wipeDir ( $ dir , $ rmdir = false ) { if ( file_exists ( $ dir ) ) { $ it = new \ RecursiveDirectoryIterator ( $ dir , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ files = new \ RecursiveIteratorIterator ( $ it , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ file ) if ( $ file -> isDir ( ) ) self :: wipeDir ( $ file -> getRealPath ( ) , true ) ; else unlink ( $ file -> getRealPath ( ) ) ; if ( $ rmdir ) rmdir ( $ dir ) ; } }
Remove everything in a directory
44,064
private static function commandExists ( $ command ) { $ whereIsCommand = ( PHP_OS == 'WINNT' ) ? 'where' : 'which' ; $ process = proc_open ( "$whereIsCommand $command" , [ 0 => array ( "pipe" , "r" ) , 1 => array ( "pipe" , "w" ) , 2 => array ( "pipe" , "w" ) , ] , $ pipes ) ; if ( $ process !== false ) { $ stdout = stream_get_contents ( $ pipes [ 1 ] ) ; $ stderr = stream_get_contents ( $ pipes [ 2 ] ) ; fclose ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 2 ] ) ; proc_close ( $ process ) ; return $ stdout != '' ; } return false ; }
Determines if a command exists on the current environment
44,065
public static function checkBinaries ( \ Composer \ Script \ Event $ event ) { foreach ( self :: $ binaries as $ cmd ) { if ( ! self :: commandExists ( $ cmd ) ) throw new \ Exception ( 'Binary "' . $ cmd . '" not found in PATH' ) ; } }
Makes sure all binaries are on system
44,066
private function makeTpl ( ) { $ this -> localTpl = rtrim ( $ this -> localTpl , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; $ this -> wipe [ ] = $ output = self :: path ( sys_get_temp_dir ( ) ) . 'twigjs' . time ( ) . DIRECTORY_SEPARATOR ; self :: readyDir ( $ output ) ; $ data = array ( ) ; foreach ( self :: rglob ( $ this -> localTpl . '*.twig' ) as $ file ) { $ id = substr ( $ file , strlen ( $ this -> localTpl ) ) ; $ data [ $ id ] = file_get_contents ( $ file ) ; } file_put_contents ( $ output . 'tpl.js' , 'var templates = ' . json_encode ( $ data ) . ';' ) ; $ this -> addLocalStatic ( 'js' , $ output ) ; return $ this ; }
Make Twig Templates in Javascript
44,067
private function makeDoc ( ) { $ neon = file_get_contents ( $ this -> localDoc ) ; $ data = \ Nette \ Neon \ Neon :: decode ( $ neon ) ; $ dest = $ data [ 'destination' ] ; self :: wipeDir ( $ dest , true ) ; $ this -> wipe [ ] = $ dest ; return $ this -> runLocal ( [ self :: BIN . 'apigen.bat' , 'generate' , '--config' , $ this -> localDoc , ] ) ; }
Make Documentation for site
44,068
private function sass ( ) { foreach ( $ this -> localStatic [ __FUNCTION__ ] as $ dir ) { $ this -> start ( 'Converting SASS to CSS in ' . $ dir ) ; foreach ( glob ( $ dir . DIRECTORY_SEPARATOR . '*.{scss,sass}' , GLOB_BRACE ) as $ file ) { $ output = basename ( $ file ) ; if ( substr ( $ output , 0 , 1 ) === '_' ) continue ; $ this -> start ( 'Working on ' . $ output ) ; $ scss = ( substr ( $ file , - 5 ) === '.scss' ) ; if ( isset ( $ GLOBALS [ "constants" ] ) ) { $ old = $ file ; $ file .= md5 ( time ( ) ) . '.sex' ; $ f = fopen ( $ file , 'w' ) ; exec ( 'attrib +H ' . escapeshellarg ( $ file ) ) ; $ const = array ( ) ; foreach ( $ GLOBALS [ "constants" ] as $ name => $ val ) $ const [ ] = '$const-' . str_replace ( '\\' , '-' , strtolower ( $ name ) ) . ': \'' . $ val . '\' !default;' ; fwrite ( $ f , implode ( PHP_EOL , $ const ) ) ; fwrite ( $ f , file_get_contents ( $ old ) ) ; fclose ( $ f ) ; } echo $ output = $ this -> tmp [ __FUNCTION__ ] . $ output ; $ output = substr ( $ output , 0 , - 4 ) . 'css' ; self :: readyDir ( $ output ) ; $ this -> runLocal ( [ 'sass' , ( $ scss ? '--scss' : null ) , '--trace' , '--unix-newlines' , '--style' , ( $ this -> compress ? 'compressed --sourcemap=none' : 'expanded -l' ) , $ file , $ output , ] ) ; $ this -> finish ( ) ; } foreach ( glob ( $ dir . DIRECTORY_SEPARATOR . '*.sex' ) as $ file ) unlink ( $ file ) ; $ this -> finish ( ) ; } return $ this ; }
Combines SASS to a file foreach folder
44,069
private function js ( ) { foreach ( $ this -> localStatic [ __FUNCTION__ ] as $ jswip ) { if ( $ this -> compress ) { $ rjsBuild = $ jswip . DIRECTORY_SEPARATOR . self :: RJS_BUILD ; if ( is_file ( $ rjsBuild ) ) { $ this -> start ( 'Optimizing ' . self :: RJS_BUILD . ' with r.js' ) -> runLocal ( [ 'r.js.cmd' , '-o' , $ rjsBuild , ] ) -> finish ( ) ; $ jswip .= DIRECTORY_SEPARATOR . 'dist' ; $ this -> wipe [ ] = $ jswip ; } } foreach ( glob ( $ jswip . DIRECTORY_SEPARATOR . '*' , GLOB_ONLYDIR ) as $ v ) { if ( $ this -> compress ) { $ output = $ this -> tmp [ __FUNCTION__ ] . basename ( $ v ) . '.js' ; self :: readyDir ( $ output ) ; $ this -> start ( 'Minifing ' . basename ( $ v ) . ' with closure' ) ; $ this -> runLocal ( [ self :: BIN . 'closure.bat' , '--language_in' , 'ECMASCRIPT5' , '--js_output_file' , $ output , $ v . DIRECTORY_SEPARATOR . '**' , ] ) ; $ this -> finish ( ) ; } else { $ this -> start ( 'Merging ' . basename ( $ v ) . '\'s JS files' ) ; $ full = $ this -> tmp [ __FUNCTION__ ] . basename ( $ v ) . '.js' ; if ( is_file ( $ full ) ) unlink ( $ full ) ; self :: readyDir ( $ full ) ; $ f = fopen ( $ full , 'a' ) ; $ g = self :: rglob ( $ v . DIRECTORY_SEPARATOR . '*.js' ) ; foreach ( $ g as $ vv ) { ob_start ( ) ; echo "\n\n\n/*** " , basename ( $ vv ) , " ***/\n\n" ; require $ vv ; $ file = ob_get_clean ( ) ; fwrite ( $ f , $ file ) ; } fclose ( $ f ) ; $ this -> finish ( ) ; } } } return $ this ; }
Merges all files
44,070
protected function img ( ) { foreach ( $ this -> localStatic [ __FUNCTION__ ] as $ imgDir ) { foreach ( self :: rglob ( $ imgDir . DIRECTORY_SEPARATOR . '*.{jpg,jpeg,png,gif,svg,bmp}' , GLOB_BRACE ) as $ image ) { $ output = $ this -> tmp [ __FUNCTION__ ] . substr ( $ image , strlen ( $ imgDir ) + 1 ) ; self :: readyDir ( $ output ) ; if ( $ this -> compress ) $ this -> start ( 'Optimizing ' . $ image ) -> runLocal ( [ 'imagemin' , $ image , '>' , $ output ] ) -> finish ( ) ; else copy ( $ image , $ output ) ; } } return $ this ; }
Move images to upload dir Optimize them if needed
44,071
private function runRemote ( $ command ) { if ( ! is_array ( $ command ) ) $ command = array ( $ command ) ; $ command = strval ( implode ( ';' , $ command ) ) ; return $ this -> runLocal ( [ 'plink' , '-ssh' , '-i' , static :: safeDir ( $ this -> ppk ) , $ this -> host , '"' . $ command . '"' , ] ) ; }
Run some commands on the remote server
44,072
private function runLocal ( $ command ) { if ( ! is_array ( $ command ) ) $ command = array ( $ command ) ; $ command = strval ( implode ( ' ' , $ command ) ) ; if ( $ this -> verbose >= 3 ) { echo "\n$ $command\n" ; passthru ( $ command ) ; } else exec ( $ command ) ; return $ this ; }
Run some commands on this computer
44,073
protected function uploadStatic ( ) { foreach ( $ this -> remoteStatic as $ type => $ destDir ) { if ( isset ( $ this -> s3 ) ) { foreach ( self :: rglob ( $ this -> tmp [ $ type ] . '*' ) as $ file ) { $ info = new \ SplFileInfo ( $ file ) ; if ( $ info -> isDir ( ) || ! $ info -> isReadable ( ) ) continue ; $ this -> start ( 'Putting ' . $ info -> getBasename ( ) . ' on ' . $ destDir ) ; $ mime = 'text/plain' ; if ( isset ( static :: $ mimes [ $ info -> getExtension ( ) ] ) ) $ mime = static :: $ mimes [ $ info -> getExtension ( ) ] ; $ headers = [ 'Content-Type' => $ mime , 'Cache-Control' => 'max-age=315360000' , 'Expires' => 'Thu, 31 Dec 2037 23:55:55 GMT' , 'Vary' => 'Accept-Encoding' , ] ; $ data = file_get_contents ( $ file ) ; if ( substr ( $ mime , 0 , 5 ) === 'text/' || $ mime === 'application/javascript' || $ mime === 'application/x-javascript' || $ mime === 'application/json' ) { $ data = gzencode ( $ data , 9 ) ; $ headers [ 'Content-Encoding' ] = 'gzip' ; } $ headers [ 'Content-Length' ] = mb_strlen ( $ data , '8bit' ) ; $ this -> s3 -> putObject ( $ data , $ destDir , $ info -> getBasename ( ) , \ S3 :: ACL_PUBLIC_READ , array ( ) , $ headers ) ; $ this -> finish ( ) ; } } else { $ this -> start ( 'Local object ' . $ type . ' -> ' . $ destDir ) -> runLocal ( [ 'pscp' , '-p' , '-r' , '-q' , '-batch' , '-C' , '-i' , static :: safeDir ( $ this -> ppk ) , static :: safeDir ( $ this -> tmp [ $ type ] ) , $ this -> host . ':' . $ destDir , ] ) -> finish ( ) ; } } return $ this ; }
Uploads to S3 or remote server
44,074
public function setS3 ( $ key = null , $ secret = null ) { $ this -> s3 = new \ S3 ( $ key , $ secret ) ; $ this -> setCompress ( true ) ; }
Uploads the static files S3
44,075
public function setFieldValue ( $ fieldName , $ value ) { if ( isset ( $ this -> originalValues [ $ fieldName ] ) && $ this -> originalValues [ $ fieldName ] === $ value ) { unset ( $ this -> givenValues [ $ fieldName ] ) ; } elseif ( isset ( $ this -> originalValues [ $ fieldName ] ) && $ this -> originalValues [ $ fieldName ] !== $ value && isset ( $ this -> defaults [ $ fieldName ] ) && $ this -> defaults [ $ fieldName ] === $ value ) { $ this -> givenValues [ $ fieldName ] = $ value ; } elseif ( isset ( $ this -> defaults [ $ fieldName ] ) && $ this -> defaults [ $ fieldName ] === $ value ) { unset ( $ this -> givenValues [ $ fieldName ] ) ; } else { $ this -> givenValues [ $ fieldName ] = $ value ; } return $ this ; }
Set the value of a named field .
44,076
public static function set ( $ enabled , $ params ) { $ docs = self :: documentations ( ) ; $ content = $ docs [ 'enabled' ] . self :: enbaledFormat ( $ enabled ) ; $ content .= $ docs [ 'kernel' ] . self :: arrayFormat ( $ params [ 'kernel' ] , 'kernel' ) ; $ content .= $ docs [ 'exceptions' ] . self :: arrayFormat ( $ params [ 'exceptions' ] , 'exceptions' ) ; $ content .= $ docs [ 'controllers' ] . self :: arrayFormat ( $ params [ 'controllers' ] , 'controllers' ) ; $ content .= $ docs [ 'models' ] . self :: arrayFormat ( $ params [ 'models' ] , 'models' ) ; $ content .= $ docs [ 'mailables' ] . self :: arrayFormat ( $ params [ 'mailables' ] , 'mailables' ) ; if ( array_has ( $ params , 'querying' ) ) { $ content .= $ docs [ 'querying' ] . self :: arrayFormat ( $ params [ 'querying' ] , 'querying' ) ; } $ content = self :: fileFormat ( $ content ) ; return self :: setFile ( $ content ) ; }
Set the config params .
44,077
protected static function setFile ( $ content ) { $ root = Process :: root ; if ( file_exists ( Process :: root . 'config/alias.php' ) ) { $ file = fopen ( Process :: root . 'config/alias.php' , 'w' ) ; fwrite ( $ file , $ content ) ; fclose ( $ file ) ; return true ; } return false ; }
Set the file .
44,078
protected static function arrayFormat ( array $ data , $ name ) { $ format = "\t'$name' => [\n" ; if ( count ( $ data ) > 0 ) { foreach ( $ data as $ key => $ value ) { $ format .= "\t\t'$key' => $value::class , \n" ; } } else { $ format .= "\t\t//\n" ; } $ format .= "\t],\n\n" ; return $ format ; }
Format args array .
44,079
public static function create ( int $ year , int $ month , int $ day , int $ hour , int $ minute , int $ second , ? string $ timezone = null ) : DateTime { $ timezone = $ timezone ? : date_default_timezone_get ( ) ; assert ( Validate :: isTimezone ( $ timezone ) , sprintf ( 'Invalid timezone: %s' , $ timezone ) ) ; return new static ( Date :: create ( $ year , $ month , $ day ) , Time :: create ( $ hour , $ minute , $ second ) , Timezone :: create ( $ timezone ) ) ; }
Creates instance from date and time values
44,080
public static function now ( ? string $ timezone = null ) : DateTime { $ timezone = $ timezone ? : date_default_timezone_get ( ) ; assert ( Validate :: isTimezone ( $ timezone ) , sprintf ( 'Invalid timezone: %s' , $ timezone ) ) ; $ dateTime = new DateTimeImmutable ( 'now' , new DateTimeZone ( $ timezone ) ) ; $ year = ( int ) $ dateTime -> format ( 'Y' ) ; $ month = ( int ) $ dateTime -> format ( 'n' ) ; $ day = ( int ) $ dateTime -> format ( 'j' ) ; $ hour = ( int ) $ dateTime -> format ( 'G' ) ; $ minute = ( int ) $ dateTime -> format ( 'i' ) ; $ second = ( int ) $ dateTime -> format ( 's' ) ; return new static ( Date :: create ( $ year , $ month , $ day ) , Time :: create ( $ hour , $ minute , $ second ) , Timezone :: create ( $ timezone ) ) ; }
Creates instance for the current date and time
44,081
public function withYear ( int $ year ) : DateTime { return new static ( Date :: create ( $ year , $ this -> month ( ) , $ this -> day ( ) ) , $ this -> time ( ) , $ this -> timezone ( ) ) ; }
Creates instance with a given year
44,082
public function withHour ( int $ hour ) : DateTime { return new static ( $ this -> date ( ) , Time :: create ( $ hour , $ this -> minute ( ) , $ this -> second ( ) ) , $ this -> timezone ( ) ) ; }
Creates instance with a given hour
44,083
public function withTimezone ( $ timezone ) : DateTime { return new static ( $ this -> date ( ) , $ this -> time ( ) , Timezone :: create ( $ timezone ) ) ; }
Creates instance with a given timezone
44,084
public function localeFormat ( string $ format ) : string { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) == 'WIN' ) { $ format = preg_replace ( '#(?<!%)((?:%%)*)%e#' , '\1%#d' , $ format ) ; } return strftime ( $ format , $ this -> timestamp ( ) ) ; }
Retrieves localized formatted string representation
44,085
public function modify ( string $ modify ) : DateTime { $ dateTime = $ this -> dateTime ( ) -> modify ( $ modify ) ; return static :: fromNative ( $ dateTime ) ; }
Creates an instance with a modified timestamp
44,086
private static function createNative ( int $ year , int $ month , int $ day , int $ hour , int $ minute , int $ second , string $ timezone ) : DateTimeImmutable { $ time = sprintf ( '%04d-%02d-%02dT%02d:%02d:%02d' , $ year , $ month , $ day , $ hour , $ minute , $ second ) ; return DateTimeImmutable :: createFromFormat ( self :: STRING_FORMAT , $ time , new DateTimeZone ( $ timezone ) ) ; }
Creates a native DateTime from date and time values
44,087
public static function get ( $ string , $ rule = 'Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();' ) { $ trans = self :: createTranslit ( $ rule ) ; $ string = preg_replace ( '/[-\s]+/' , '-' , $ trans -> transliterate ( $ string ) ) ; $ out = trim ( $ string , '-' ) ; return $ out ; }
Transliterate a string .
44,088
public function build ( ) { foreach ( $ this -> datasource as $ index => $ val ) { $ option = $ this -> createOption ( ) ; $ option -> setInner ( $ val ) ; $ option -> setValue ( $ this -> index_is_value ? $ index : $ val ) ; if ( ! empty ( $ this -> selected ) ) { if ( is_array ( $ this -> selected ) ) { if ( array_search ( ( $ this -> index_is_value ? $ index : $ val ) , $ this -> selected ) ) { $ option -> isSelected ( 1 ) ; } } else { if ( $ this -> selected == ( $ this -> index_is_value ? $ index : $ val ) ) { $ option -> isSelected ( 1 ) ; } } } } return parent :: build ( ) ; }
Builds and returns html code
44,089
public function setRules ( $ rules ) { $ this -> rules = array ( ) ; foreach ( $ rules as $ rule ) { $ this -> addRule ( $ rule ) ; } return $ this ; }
Set all rules
44,090
public function addRule ( $ rule ) { if ( ! ( $ rule instanceof RuleStructure ) ) { $ rule = new RuleStructure ( $ rule ) ; } $ this -> rules [ ] = $ rule ; return $ this ; }
Add a rule
44,091
public function resetContents ( ) { $ this -> setImports ( array ( ) ) -> setRules ( array ( ) ) ; if ( $ this -> hasExtraContent ( ) ) { $ this -> setExtraContent ( null ) ; } return $ this ; }
Reset all contents
44,092
public function render ( $ file = null , $ eol = null ) { static $ escape = array ( '"' => '\\"' ) ; $ renderer = AbstractRenderer :: factory ( $ file , $ eol ) ; $ eol = $ renderer -> getEol ( ) ; $ renderer -> writeLine ( '@charset "' . strtr ( static :: RENDER_CHARSET , $ escape ) . '";' ) ; if ( ! $ this -> comment && $ this -> extra && $ this -> extra -> updated ) { $ this -> comment = $ this -> extra -> updated -> format ( DateTime :: ISO8601 ) ; } if ( $ this -> comment ) { $ commentLines = array_map ( function ( $ line ) { return ' * ' . $ line ; } , preg_split ( '/\s*[\n\r]+\s*/' , $ this -> comment ) ) ; array_unshift ( $ commentLines , $ eol . '/**' ) ; array_push ( $ commentLines , ' */' ) ; foreach ( $ commentLines as $ comment ) { $ renderer -> writeLine ( $ comment ) ; } } foreach ( $ this -> imports as $ import ) { $ renderer -> writeLine ( '@import url("' . strtr ( $ import , $ escape ) . '");' . $ eol ) ; } $ media = '' ; foreach ( $ this -> rules as $ rule ) { $ newMedia = ( string ) $ rule -> media ; if ( $ media != $ newMedia ) { if ( $ media ) { $ renderer -> writeLine ( '}' . $ eol ) ; } $ media = $ newMedia ; $ renderer -> writeLine ( '@media ' . $ media . $ eol . '{' . $ eol ) ; } $ rawPropertyNames = $ rule -> getRawPropertyNames ( ) ; if ( ! empty ( $ rawPropertyNames ) ) { $ renderer -> writeLine ( ( $ media ? "\t" : '' ) . $ rule -> selector . $ eol . ( $ media ? "\t" : '' ) . '{' ) ; foreach ( $ rawPropertyNames as $ propery ) { $ renderer -> writeLine ( ( $ media ? "\t" : '' ) . "\t" . $ propery . ': ' . $ rule -> getRawPropertyValue ( $ propery ) . $ rule -> getRawPropertyPostfix ( $ propery ) . ';' ) ; } $ renderer -> writeLine ( ( $ media ? "\t" : '' ) . '}' . $ eol ) ; } } if ( $ media ) { $ renderer -> writeLine ( '}' ) ; } if ( $ this -> hasExtraContent ( ) ) { $ renderer -> writeLine ( $ eol . $ this -> getExtraContent ( ) ) ; } return $ renderer ; }
Render rules to a css - file
44,093
public function getColumns ( ) { $ translationManager = $ this -> framework -> getInstance ( '\\Zepi\\Core\\Language\\Manager\\TranslationManager' ) ; return array ( new Column ( 'name' , $ translationManager -> translate ( 'Username' , '\\Zepi\\Web\\AccessControl' ) , 50 , true , true , Column :: DATA_TYPE_HTML , 'icon-column' ) , new Column ( 'uuid' , $ translationManager -> translate ( 'UUID' , '\\Zepi\\Web\\AccessControl' ) , 50 , true , true , Column :: DATA_TYPE_STRING ) , new Column ( 'actions' , '' , Column :: WIDTH_AUTO , false , false , Column :: DATA_TYPE_HTML , 'auto-width button-column' ) ) ; }
Returns an array with all columns
44,094
private function checkSeoAttributes ( ) { $ model = $ this -> owner ; $ transliterationFunction = $ this -> transliterationFunction ; if ( $ this -> slugAttribute && $ model -> { $ this -> slugAttribute } == null ) { $ model -> { $ this -> slugAttribute } = $ transliterationFunction ( $ model -> { $ this -> nameAttribute } ) ; } foreach ( $ this -> seoAttributes as $ seoAttribute ) { if ( $ model -> { $ seoAttribute } == null ) { $ model -> { $ seoAttribute } = $ model -> { $ this -> nameAttribute } ; } } }
Slug and seo attributes generating
44,095
public function create ( $ request , $ response , $ args ) { $ params = $ this -> getCreateParams ( $ request ) ; if ( $ this -> createWithClientID ) { $ params [ 'client_id' ] = $ request -> getAttribute ( 'client_id' ) ; } $ validation = $ this -> validator -> validateParams ( $ params , $ this -> getValidation ( 0 ) ) ; if ( $ validation -> failed ( ) ) { return $ this -> error_helper -> validationFailed ( $ response , $ validation -> getErrors ( ) ) ; } if ( ! $ created_id = $ this -> Model -> insertGetId ( $ params ) ) { return $ this -> error_helper -> createFailed ( $ response , '' ) ; } $ data [ 'error' ] = false ; $ data [ $ this -> name_s ] = $ this -> Model -> find ( $ created_id ) ; $ response = $ response -> withAddedHeader ( 'insert_id' , $ created_id ) ; return $ response -> withJson ( $ data ) ; }
Creates a new element in the model according to the request
44,096
public function onAuthenticationSuccess ( AuthenticationEvent $ event ) { if ( ! $ this -> config [ 'admin_login' ] ) { return ; } $ token = $ event -> getAuthenticationToken ( ) ; $ userIsAdmin = $ this -> accessDecisionManager -> decide ( $ token , [ 'ROLE_ADMIN' ] ) ; if ( ! ( $ userIsAdmin && $ token instanceof UsernamePasswordToken ) ) { return ; } $ user = $ token -> getUser ( ) ; $ this -> mailer -> sendSuccessfulLoginEmailMessage ( $ user ) ; }
Handle login success event .
44,097
public function read ( ) { parent :: read ( ) ; if ( isset ( $ _SESSION [ static :: SESSION_NAME ] ) ) { $ sess_table = $ this -> _uncrypt ( $ _SESSION [ static :: SESSION_NAME ] ) ; if ( isset ( $ sess_table [ static :: SESSION_FLASHESNAME ] ) ) { $ this -> old_flashes = $ sess_table [ static :: SESSION_FLASHESNAME ] ; } } $ this -> addSessionTable ( static :: SESSION_FLASHESNAME , $ this -> old_flashes ) ; return $ this ; }
Start the current session if so
44,098
public function getFlash ( $ index ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } $ _oldf = null ; if ( ! empty ( $ index ) && isset ( $ this -> old_flashes [ $ index ] ) ) { $ _oldf = $ this -> old_flashes [ $ index ] ; unset ( $ this -> old_flashes [ $ index ] ) ; return $ _oldf ; } return null ; }
Get a current session flash parameter
44,099
public function setFlash ( $ value , $ index = null ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } if ( ! empty ( $ index ) ) { $ this -> flashes [ $ index ] = $ value ; } else { $ this -> flashes [ ] = $ value ; } return $ this ; }
Set a current session flash parameter