idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
46,500
public function boot ( Application $ application , InputInterface $ input , $ output ) { if ( true === $ this -> booted ) { return ; } $ this -> application = $ application ; $ this -> input = $ input ; $ this -> output = $ output ; $ this -> initializeContainer ( ) ; $ this -> booted = true ; }
Boots kernel by setting up the container
46,501
protected function initializeContainer ( ) { $ this -> container = $ this -> buildContainer ( ) ; $ this -> getContainerLoader ( $ this -> container ) -> load ( 'services.xml' ) ; $ this -> container -> compile ( ) ; }
Initialize the container and compile
46,502
protected function buildContainer ( ) { $ container = new ContainerBuilder ( new ParameterBag ( $ this -> getContainerParameters ( ) ) ) ; $ container -> setResourceTracking ( true ) ; $ container -> set ( 'kernel' , $ this ) ; $ container -> set ( 'application' , $ this -> application ) ; $ this -> getContainerLoader ( $ container ) -> load ( $ this -> getBuildFile ( ) , self :: TYPE_BUILD_FILE ) ; $ file = $ this -> getPropertiesFile ( ) ; if ( $ file ) { $ this -> getContainerLoader ( $ container ) -> load ( $ file , self :: TYPE_PROPERTIES_FILE ) ; } return $ container ; }
Build the container and get it setup in a basic state
46,503
protected function getEnvironmentVariables ( ) { $ env = array ( ) ; foreach ( $ _SERVER as $ name => $ val ) { if ( is_array ( $ val ) || ! in_array ( strtolower ( $ name ) , $ this -> getEnvironmentVariablesThatICareAbout ( ) ) ) { continue ; } $ env [ 'env.' . $ name ] = $ val ; } return $ env ; }
Returns an array of various environmental variables
46,504
protected function getBuildFile ( ) { $ buildfile = getcwd ( ) . '/build.yml' ; if ( true === $ this -> input -> hasParameterOption ( '--buildfile' ) ) { $ buildfile = realpath ( $ this -> input -> getParameterOption ( '--buildfile' ) ) ; } if ( is_file ( $ buildfile ) && is_readable ( $ buildfile ) ) { return $ buildfile ; } throw new \ Exception ( sprintf ( 'Could not find build file "%s"' , $ buildfile ) ) ; }
Used to return the location of the build file
46,505
protected function getPropertiesFile ( ) { $ propertyfile = getcwd ( ) . '/build.properties' ; if ( true === $ this -> input -> hasParameterOption ( '--propertyfile' ) ) { $ propertyfile = realpath ( $ this -> input -> getParameterOption ( '--propertyfile' ) ) ; } if ( is_file ( $ propertyfile ) && is_readable ( $ propertyfile ) ) { return $ propertyfile ; } if ( true === $ this -> input -> hasParameterOption ( '--propertyfile' ) ) { throw new \ Exception ( sprintf ( 'Could not find properties file "%s"' , $ this -> input -> getParameterOption ( '--propertyfile' ) ) ) ; } return false ; }
Finds and returns the file set as the build . properties file .
46,506
public function getMetaDataValue ( $ key ) { return ( isset ( $ this -> meta [ $ key ] ) ? $ this -> meta [ $ key ] : null ) ; }
Get the stream meta data value
46,507
public function getContent ( ) { if ( $ this -> isSeekable ( ) ) $ this -> rewind ( ) ; if ( ! $ this -> isReadable ( ) || ( $ contents = stream_get_contents ( $ this -> stream ) ) === false ) { throw new \ RuntimeException ( 'Could not get contents of not readable stream' ) ; } return $ contents ; }
Get the stream content
46,508
public function read ( $ length = null ) { if ( is_null ( $ length ) ) $ length = $ this -> getSize ( 0 ) ; if ( ! $ this -> isReadable ( ) || ( $ data = fread ( $ this -> stream , $ length ) ) === false ) { throw new \ RuntimeException ( 'Could not read from not readable stream' ) ; } return $ data ; }
Read the stream from the current offset
46,509
public function write ( $ string ) { if ( ! $ this -> isWritable ( ) || ( $ written = fwrite ( $ this -> stream , $ string ) ) === false ) { throw new \ RuntimeException ( 'Could not write in a not writable stream' ) ; } return $ written ; }
Write within the stream
46,510
public function getByClassname ( string $ classname ) { foreach ( $ this -> container as $ value ) { if ( is_object ( $ value ) && $ value instanceof $ classname ) { return $ value ; } } return null ; }
Get registered value by class name . If not found will return null .
46,511
public function connect ( ) { $ count = 0 ; do { $ count += 1 ; $ this -> Resource = pg_connect ( $ this -> getConnectionString ( ) ) ; if ( $ this -> Resource !== false ) { return true ; } } while ( $ count < $ this -> getConnectTries ( ) ) ; throw new TriesOverConnectException ( ) ; }
Connect to postgres instance
46,512
private function getConnectionString ( ) { $ parameters = array ( 'host=' . $ this -> getHost ( ) , 'connect_timeout=' . $ this -> getConnectTimeout ( ) , 'user=' . $ this -> getUserName ( ) , ) ; $ this -> hasPort ( ) && $ parameters [ ] = 'port=' . $ this -> getPort ( ) ; $ this -> hasPassword ( ) && $ parameters [ ] = 'password=' . $ this -> getPassword ( ) ; $ this -> hasDatabase ( ) && $ parameters [ ] = 'dbname=' . $ this -> getDatabase ( ) ; return implode ( ' ' , $ parameters ) ; }
Build postgres connection string
46,513
public static function replace_callback ( $ subject , $ pattern , $ callback , $ limit = - 1 ) { return preg_replace_callback ( self :: set_u_modifier ( $ pattern , TRUE ) , $ callback , $ subject , $ limit ) ; }
So wie replace allerdings mit einer Callback Funktion mit einem Parameter
46,514
public function filterByPartId ( $ partId = null , $ comparison = null ) { if ( is_array ( $ partId ) ) { $ useMinMax = false ; if ( isset ( $ partId [ 'min' ] ) ) { $ this -> addUsingAlias ( SkillPartTableMap :: COL_PART_ID , $ partId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ partId [ 'max' ] ) ) { $ this -> addUsingAlias ( SkillPartTableMap :: COL_PART_ID , $ partId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SkillPartTableMap :: COL_PART_ID , $ partId , $ comparison ) ; }
Filter the query on the part_id column
46,515
public function filterByCompositeId ( $ compositeId = null , $ comparison = null ) { if ( is_array ( $ compositeId ) ) { $ useMinMax = false ; if ( isset ( $ compositeId [ 'min' ] ) ) { $ this -> addUsingAlias ( SkillPartTableMap :: COL_COMPOSITE_ID , $ compositeId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ compositeId [ 'max' ] ) ) { $ this -> addUsingAlias ( SkillPartTableMap :: COL_COMPOSITE_ID , $ compositeId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SkillPartTableMap :: COL_COMPOSITE_ID , $ compositeId , $ comparison ) ; }
Filter the query on the composite_id column
46,516
public function useSkillRelatedByPartIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinSkillRelatedByPartId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillRelatedByPartId' , '\gossi\trixionary\model\SkillQuery' ) ; }
Use the SkillRelatedByPartId relation Skill object
46,517
public function useSkillRelatedByCompositeIdQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinSkillRelatedByCompositeId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillRelatedByCompositeId' , '\gossi\trixionary\model\SkillQuery' ) ; }
Use the SkillRelatedByCompositeId relation Skill object
46,518
public function setAuthSubPrivateKeyFile ( $ file , $ passphrase = null , $ useIncludePath = false ) { $ fp = @ fopen ( $ file , "r" , $ useIncludePath ) ; if ( ! $ fp ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Failed to open private key file for AuthSub.' ) ; } $ key = '' ; while ( ! feof ( $ fp ) ) { $ key .= fread ( $ fp , 8192 ) ; } $ this -> setAuthSubPrivateKey ( $ key , $ passphrase ) ; fclose ( $ fp ) ; }
Sets the PEM formatted private key as read from a file .
46,519
public function setAuthSubPrivateKey ( $ key , $ passphrase = null ) { if ( $ key != null && ! function_exists ( 'openssl_pkey_get_private' ) ) { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'You cannot enable secure AuthSub if the openssl module ' . 'is not enabled in your PHP installation.' ) ; } $ this -> _authSubPrivateKeyId = openssl_pkey_get_private ( $ key , $ passphrase ) ; return $ this ; }
Sets the PEM formatted private key to be used for secure AuthSub auth .
46,520
public function filterHttpRequest ( $ method , $ url , $ headers = array ( ) , $ body = null , $ contentType = null ) { if ( $ this -> getAuthSubToken ( ) != null ) { if ( $ this -> getAuthSubPrivateKeyId ( ) != null ) { $ time = time ( ) ; $ nonce = mt_rand ( 0 , 999999999 ) ; $ dataToSign = $ method . ' ' . $ url . ' ' . $ time . ' ' . $ nonce ; $ pKeyId = $ this -> getAuthSubPrivateKeyId ( ) ; $ signSuccess = openssl_sign ( $ dataToSign , $ signature , $ pKeyId , OPENSSL_ALGO_SHA1 ) ; if ( ! $ signSuccess ) { require_once 'Zend/Gdata/App/Exception.php' ; throw new Zend_Gdata_App_Exception ( 'openssl_signing failure - returned false' ) ; } $ encodedSignature = base64_encode ( $ signature ) ; $ headers [ 'authorization' ] = 'AuthSub token="' . $ this -> getAuthSubToken ( ) . '" ' . 'data="' . $ dataToSign . '" ' . 'sig="' . $ encodedSignature . '" ' . 'sigalg="rsa-sha1"' ; } else { $ headers [ 'authorization' ] = 'AuthSub token="' . $ this -> getAuthSubToken ( ) . '"' ; } } elseif ( $ this -> getClientLoginToken ( ) != null ) { $ headers [ 'authorization' ] = 'GoogleLogin auth=' . $ this -> getClientLoginToken ( ) ; } return array ( 'method' => $ method , 'url' => $ url , 'body' => $ body , 'headers' => $ headers , 'contentType' => $ contentType ) ; }
Filters the HTTP requests being sent to add the Authorization header .
46,521
public function singleEventAction ( ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ this -> settings [ self :: SETTINGS_ASSOCIATION_ID ] , self :: VIEW_VARIABLE_EVENT_ID => $ this -> settings [ self :: SETTINGS_EVENT_ID ] ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
single event action .
46,522
public function getErrorMessages ( ) { $ messages = array ( ) ; foreach ( $ this -> entries as $ entry ) { if ( $ entry -> isError ( ) ) { $ messages [ ] = $ entry -> getMessage ( ) ; } } return $ messages ; }
Returns an array of error message strings
46,523
public function toArray ( ) : array { $ data = ReflectionUtil :: objToSnakeArray ( $ this , static :: blacklist ( ) ) ; foreach ( $ this -> renamed as $ name => $ newName ) { if ( ! array_key_exists ( $ name , $ data ) ) { continue ; } $ data [ $ newName ] = $ data [ $ name ] ; unset ( $ data [ $ name ] ) ; } return $ data ; }
Return the object as Array .
46,524
public function get ( $ id ) : Domain { if ( ! $ model = Domain :: findOne ( $ id ) ) { throw new NotFoundException ( $ this -> i18n -> t ( 'setrun/sys/domain' , 'Domain is not found' ) ) ; } return $ model ; }
Find a domain item .
46,525
public function save ( Domain $ model ) : void { if ( ! $ model -> save ( ) ) { throw new \ RuntimeException ( $ this -> i18n -> t ( 'setrun/sys' , 'Saving error' ) ) ; } }
Save a domain item .
46,526
protected function encodeArray ( array $ args ) : array { foreach ( $ args as $ key => $ value ) { if ( is_object ( $ value ) ) { $ args [ $ key ] = get_class ( $ value ) ; } } return $ args ; }
Default array encoder
46,527
public static function ahoy ( array $ config = [ ] ) { static $ inst = null ; if ( $ inst === null ) { $ inst = new Application ( ) ; $ inst -> registry = Registry :: ahoy ( ) ; $ inst -> treasureChest = new Container ( ) ; $ inst -> setConfig ( $ config ) ; $ env = getenv ( 'APPLICATION_ENV' ) ; if ( $ env ) { $ inst -> setEnvironment ( $ env ) ; } } return $ inst ; }
Ahoy! There nay be boardin without yer configuration
46,528
public function setSail ( ) { $ env = new Environment ( $ _SERVER ) ; if ( ! count ( $ this -> registry -> getAll ( ) ) ) { $ config = $ env -> fetchConfig ( $ this -> configFolder , $ this -> environment ) ; $ this -> setConfig ( $ config ) ; } $ request = ServerRequestFactory :: fromGlobals ( $ _SERVER , $ _GET , $ _POST , $ _COOKIE , $ _FILES ) ; $ response = new Response ( ) ; $ dispatcher = new Dispatcher ( $ request , $ response , $ env ) ; $ dispatcher -> fireCannons ( ) ; }
T the high seas! Garrr!
46,529
private function listResources ( $ filters = array ( ) , $ listType = null ) { $ uri = '/resources' ; $ query = array ( ) ; if ( $ listType ) { $ query [ ] = $ listType ; } foreach ( $ filters as $ name => $ value ) { $ query [ ] = "{$name}={$value}" ; } if ( sizeof ( $ query ) ) { $ uri .= '?' . implode ( '&' , $ query ) ; } $ body = $ this -> sendRequest ( $ uri ) ; $ node = $ this -> parseXml ( ( string ) $ body ) ; return $ this -> parseResourcesXmlToResources ( $ node ) ; }
Get a list of Resources .
46,530
public function decode ( $ data ) { $ mod = strlen ( $ data ) % 8 ; if ( $ mod === 1 || $ mod === 3 || $ mod === 6 ) { throw new \ DomainException ( 'Invalid input.' ) ; } $ bits = '' ; foreach ( str_split ( strtoupper ( $ data ) ) as $ char ) { $ index = strpos ( $ this -> getConfig ( 'alphabet' ) , $ char ) ; if ( $ index === false ) { throw new \ DomainException ( 'Invalid character in input.' ) ; } $ bits .= sprintf ( '%05b' , $ index ) ; } if ( preg_match ( '/[^0]/' , substr ( $ bits , 0 - strlen ( $ bits ) % 8 ) ) === 1 ) { throw new \ DomainException ( 'Invalid input.' ) ; } $ output = '' ; foreach ( str_split ( $ bits , 8 ) as $ chunk ) { $ output .= chr ( bindec ( $ chunk ) ) ; } return rtrim ( $ output ) ; }
Decode a base32 string .
46,531
public function encode ( $ data ) { $ bits = '' ; foreach ( str_split ( $ data ) as $ char ) { $ bits .= sprintf ( '%08b' , ord ( $ char ) ) ; } $ len = strlen ( $ bits ) ; $ mod = $ len % 5 ; if ( $ mod !== 0 ) { $ bits = str_pad ( $ bits , $ len + 5 - $ mod , '0' , STR_PAD_RIGHT ) ; } $ output = '' ; foreach ( str_split ( $ bits , 5 ) as $ chunk ) { $ output .= substr ( $ this -> getConfig ( 'alphabet' ) , bindec ( $ chunk ) , 1 ) ; } return $ output ; }
Base32 encode a string .
46,532
public function get_handler ( $ path , array $ config = array ( ) , $ content = array ( ) ) { $ path = $ this -> get_path ( $ path ) ; if ( is_file ( $ path ) ) { $ info = pathinfo ( $ path ) ; isset ( $ info [ 'extension' ] ) or $ info [ 'extension' ] = '' ; if ( ! empty ( $ this -> extensions ) && ! in_array ( $ info [ 'extension' ] , $ this -> extensions ) ) { throw new \ FileAccessException ( 'File operation not allowed: disallowed file extension.' ) ; } if ( array_key_exists ( $ info [ 'extension' ] , $ this -> file_handlers ) ) { $ class = '\\' . ltrim ( $ this -> file_handlers [ $ info [ 'extension' ] ] , '\\' ) ; return $ class :: forge ( $ path , $ config , $ this ) ; } return \ File_Handler_File :: forge ( $ path , $ config , $ this ) ; } elseif ( is_dir ( $ path ) ) { return \ File_Handler_Directory :: forge ( $ path , $ config , $ this , $ content ) ; } throw new \ FileAccessException ( 'Invalid path for file or directory.' ) ; }
Handler factory for given path
46,533
public function get_path ( $ path ) { $ pathinfo = is_dir ( $ path ) ? array ( 'dirname' => $ path , 'extension' => null , 'basename' => '' ) : pathinfo ( $ path ) ; isset ( $ pathinfo [ 'dirname' ] ) or $ pathinfo [ 'dirname' ] = '' ; if ( ! empty ( $ this -> basedir ) && substr ( $ pathinfo [ 'dirname' ] , 0 , strlen ( $ this -> basedir ) ) == $ this -> basedir ) { $ pathinfo [ 'dirname' ] = realpath ( $ pathinfo [ 'dirname' ] ) ; } else { $ pathinfo [ 'dirname' ] = ( ! empty ( $ this -> basedir ) ? realpath ( $ this -> basedir . DS . $ pathinfo [ 'dirname' ] ) : realpath ( $ pathinfo [ 'dirname' ] ) ) ? : ( ! empty ( $ this -> basedir ) ? $ this -> basedir . DS . str_replace ( '..' , '' , $ pathinfo [ 'dirname' ] ) : $ pathinfo [ 'dirname' ] ) ; } if ( ! empty ( $ this -> basedir ) && substr ( $ pathinfo [ 'dirname' ] , 0 , strlen ( $ this -> basedir ) ) != $ this -> basedir ) { throw new \ OutsideAreaException ( 'File operation not allowed: given path is outside the basedir for this area.' ) ; } if ( ! empty ( static :: $ extensions ) && array_key_exists ( $ pathinfo [ 'extension' ] , static :: $ extensions ) ) { throw new \ FileAccessException ( 'File operation not allowed: disallowed file extension.' ) ; } return $ pathinfo [ 'dirname' ] . DS . $ pathinfo [ 'basename' ] ; }
Translate relative path to real path throws error when operation is not allowed
46,534
public function get_url ( $ path ) { if ( empty ( $ this -> url ) ) { throw new \ LogicException ( 'File operation now allowed: cannot create a file url without an area url.' ) ; } $ path = $ this -> get_path ( $ path ) ; $ basedir = $ this -> basedir ; empty ( $ basedir ) and $ basedir = DOCROOT ; if ( stripos ( $ path , $ basedir ) !== 0 ) { throw new \ LogicException ( 'File operation not allowed: cannot create file url whithout a basedir and file outside DOCROOT.' ) ; } return rtrim ( $ this -> url , '/' ) . '/' . ltrim ( str_replace ( DS , '/' , substr ( $ path , strlen ( $ basedir ) ) ) , '/' ) ; }
Translate relative path to accessible path throws error when operation is not allowed
46,535
public function getPayload ( string $ key , $ default = null ) { if ( $ this -> payload === null ) { $ contentType = $ this -> getHeader ( 'Content-Type' , '' ) ; if ( ! $ contentType ) { $ contentType = $ this -> getHeader ( 'Content-type' ) ; } if ( $ contentType ) { $ contentTypeParts = preg_split ( '/\s*[;,]\s*/' , $ contentType ) ; $ contentType = $ contentTypeParts [ 0 ] ; $ contentType = strtolower ( $ contentType ) ; if ( isset ( $ this -> bodyParsers [ $ contentType ] ) ) { $ parser = $ this -> bodyParsers [ $ contentType ] ; $ this -> payload = $ parser ( $ this -> body ) ; } } } return $ this -> payload [ $ key ] ?? $ default ; }
get body param
46,536
public function end ( $ name = self :: DEFAULT_NAME ) { $ this -> end_time [ $ name ] = microtime ( true ) ; $ this -> memory_usage [ $ name ] = memory_get_usage ( true ) ; }
Sets end microtime
46,537
public function getTime ( $ raw = false , $ format = null , $ name = self :: DEFAULT_NAME ) { $ elapsed = $ this -> end_time [ $ name ] - $ this -> start_time [ $ name ] ; return $ raw ? $ elapsed : self :: readableElapsedTime ( $ elapsed , $ format , $ name ) ; }
Returns the elapsed time readable or not
46,538
public function getMemoryUsage ( $ raw = false , $ format = null , $ name = self :: DEFAULT_NAME ) { return $ raw ? $ this -> memory_usage [ $ name ] : self :: readableSize ( $ this -> memory_usage [ $ name ] , $ format ) ; }
Returns the memory usage at the end checkpoint
46,539
public function getMemoryPeak ( $ raw = false , $ format = null ) { $ memory = memory_get_peak_usage ( true ) ; return $ raw ? $ memory : self :: readableSize ( $ memory , $ format ) ; }
Returns the memory peak readable or not
46,540
public function mostRecentOrdersAction ( $ max = 20 ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ productOrderRepo = $ em -> getRepository ( 'AmulenShopBundle:ProductOrder' ) ; $ orders = $ productOrderRepo -> recentOrders ( $ max ) ; return [ 'orders' => $ orders , ] ; }
Last n product orders .
46,541
public function process ( Request $ request , Transaction $ transaction , Delivery $ delivery ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ pm = $ em -> getRepository ( 'EcommerceBundle:PaymentMethod' ) -> findOneBySlug ( 'bank-transfer-test' ) ; $ transaction -> setStatus ( Transaction :: STATUS_PAID ) ; $ transaction -> setPaymentMethod ( $ pm ) ; $ em -> persist ( $ transaction ) ; $ em -> flush ( ) ; $ answer = new stdClass ( ) ; $ answer -> redirectUrl = $ this -> container -> get ( 'router' ) -> generate ( 'ecommerce_checkout_confirmationpayment' ) ; return $ answer ; }
Process payment OK
46,542
protected function buildOptions ( ) { $ created = '' ; foreach ( $ this -> getOptions ( ) as $ key => $ value ) { if ( $ key === 'class' ) { $ value = $ this -> buildClassString ( $ value ) ; } $ created .= "$key='$value' " ; } return rtrim ( $ created , ' ' ) ; }
build options string
46,543
public function add ( DocumentInterface $ document ) { $ this -> documents [ ( string ) $ document -> getIdentity ( ) ] = $ document ; return $ this ; }
Adds a document to the result set .
46,544
public function register ( Application $ app ) { $ assets = $ this ; $ app [ 'assets' ] = $ app -> share ( function ( ) use ( $ app , $ assets ) { return $ assets ; } ) ; }
implementation of Silex Service Provider register method
46,545
public function boot ( Application $ app ) { $ assets = $ this ; $ app -> before ( function ( Request $ request ) use ( $ app , $ assets ) { $ baseUrl = rtrim ( $ request -> getScheme ( ) . '://' . $ request -> getHttpHost ( ) . $ request -> getBasePath ( ) ) . '/' ; $ assets -> setCoreUrl ( $ baseUrl ) ; $ assets -> setOption ( 'baseUrl' , $ baseUrl ) ; $ assets -> setOption ( 'jsPosition' , $ assets :: ON_BODY ) ; return $ assets ; } ) ; $ options = isset ( $ app [ 'assets.options' ] ) ? $ app [ 'assets.options' ] : array ( ) ; if ( ! empty ( $ options ) ) array_walk ( $ options , function ( $ optionValue , $ optionName ) use ( $ assets ) { $ assets -> setOption ( $ optionName , $ optionValue ) ; } ) ; $ js = isset ( $ app [ 'assets.js' ] ) ? $ app [ 'assets.js' ] : array ( ) ; if ( ! empty ( $ js ) ) array_walk ( $ js , function ( $ value ) use ( $ assets ) { $ assets -> registerJs ( $ value ) ; } ) ; $ css = isset ( $ app [ 'assets.css' ] ) ? $ app [ 'assets.css' ] : array ( ) ; if ( ! empty ( $ css ) ) array_walk ( $ css , function ( $ value ) use ( $ assets ) { $ assets -> registerCss ( $ value ) ; } ) ; $ app -> after ( function ( Request $ request , Response $ response ) use ( $ app , $ assets ) { if ( $ response -> headers -> get ( 'content_type' ) != 'application/json' ) { $ content = $ response -> getContent ( ) ; $ assets -> renderAssets ( $ content ) ; $ response -> setContent ( $ content ) ; } return $ response ; } ) ; }
implementation of Silex Service Provider boot method
46,546
public function renderAssets ( & $ content ) { $ this -> prepareAssets ( ) ; $ js = $ this -> renderJs ( ) ; $ css = $ this -> renderCss ( ) ; $ bodyJs = $ this -> renderJs ( self :: ON_BODY ) ; if ( ! empty ( $ css ) ) { if ( strpos ( $ content , "</head>" ) > 0 ) $ content = str_replace ( "</head>" , "####replace-css-here####</head>" , $ content ) ; else $ content = "####replace-css-here####" . $ content ; $ content = str_replace ( "####replace-css-here####" , $ css , $ content ) ; } if ( ! empty ( $ js ) ) { if ( strpos ( $ content , "</body>" ) > 0 ) $ content = str_replace ( "</body>" , "####replace-js-here####</body>" , $ content ) ; else $ content .= "####replace-js-here####" ; $ content = str_replace ( "####replace-js-here####" , $ js , $ content ) ; } if ( ! empty ( $ bodyJs ) ) { if ( strpos ( $ content , "</body>" ) > 0 ) $ content = str_replace ( "</body>" , "####replace-js-here####</body>" , $ content ) ; else $ content .= "####replace-js-here####" ; $ content = str_replace ( "####replace-js-here####" , $ bodyJs , $ content ) ; } return $ content ; }
begin rendering assets when response is valid and has been processed . this is automatically triggered so you don t need to trigger it manually
46,547
public function renderJs ( $ position = self :: ON_HEAD ) { $ result = "" ; $ js = $ this -> getJs ( $ position ) ; if ( ! empty ( $ js ) ) array_walk ( $ js , function ( $ value ) use ( & $ result ) { $ result .= '<script src="' . $ value . '" type="text/javascript"></script>' ; } ) ; $ custom = $ this -> getCustomJs ( $ position ) ; if ( ! empty ( $ custom ) ) { $ customJs = '<script type="text/javascript" id="silex-assets-service-js-' . substr ( md5 ( time ( ) ) , 0 , 5 ) . '">' ; if ( $ custom !== array ( ) ) array_walk ( $ custom , function ( $ value ) use ( & $ customJs ) { $ customJs .= $ value . "\n" ; } ) ; $ customJs .= "</script>" ; $ result .= $ customJs ; } return $ result ; }
Begin processing registering Javascripts if available
46,548
public function renderCss ( ) { $ result = "" ; $ css = $ this -> getCss ( ) ; if ( ! empty ( $ css ) ) array_walk ( $ css , function ( $ value ) use ( & $ result ) { $ result .= '<link href="' . $ value . '" type="text/css" rel="stylesheet">' ; } ) ; $ custom = $ this -> getCustomCss ( ) ; if ( ! empty ( $ custom ) ) { $ customCss = '<style type="text/css" rel="stylesheet" id="silex-assets-service-css-' . substr ( md5 ( time ( ) ) , 0 , 5 ) . '">' ; if ( $ custom !== array ( ) ) array_walk ( $ custom , function ( $ value ) use ( & $ customCss ) { $ customCss .= $ value . "\n" ; } ) ; $ customCss .= "</style>" ; $ result .= $ customCss ; } return $ result ; }
Begin processing registering Css Files if available
46,549
public function getJs ( $ position = self :: ON_HEAD ) { if ( $ this -> js === array ( ) ) return array ( ) ; $ js = isset ( $ this -> js [ $ position ] ) && ! empty ( $ this -> js [ $ position ] ) ? $ this -> js [ $ position ] : array ( ) ; if ( $ js === array ( ) ) return $ js ; $ options = $ this -> options ; if ( $ this -> isCombineEnabled ( ) ) $ this -> combine ( 'js' , $ js ) ; $ js = array_flip ( array_flip ( $ js ) ) ; array_walk ( $ js , function ( & $ value ) use ( $ options ) { if ( ! empty ( $ options [ 'baseUrl' ] ) && strpos ( $ value , 'http://' ) === false ) $ value = $ options [ 'baseUrl' ] . $ value ; } ) ; return $ js ; }
Get all registered javascripts
46,550
public function getCss ( ) { $ css = $ this -> css ; $ options = $ this -> options ; if ( $ this -> isCombineEnabled ( ) ) $ this -> combine ( 'css' , $ css ) ; $ css = array_flip ( array_flip ( $ css ) ) ; array_walk ( $ css , function ( & $ value ) use ( $ options ) { if ( ! empty ( $ options [ 'baseUrl' ] ) && strpos ( $ value , 'http://' ) === false ) $ value = $ options [ 'baseUrl' ] . $ value ; } ) ; return $ css ; }
Get all registered css files
46,551
public function customJs ( $ id , $ script = "" , $ position = self :: ON_HEAD ) { if ( ! isset ( $ this -> customJs [ $ position ] ) ) $ this -> customJs [ $ position ] = array ( ) ; $ this -> customJs [ $ position ] [ $ id ] = $ script ; return $ this ; }
Add custom script on your apps . It is useful when you want to attach some custom script on the fly .
46,552
public function getCustomJs ( $ position = self :: ON_HEAD ) { return isset ( $ this -> customJs [ $ position ] ) ? $ this -> customJs [ $ position ] : array ( ) ; }
It is used to get custom javascript by reserved position .
46,553
public function customCss ( $ id , $ css = "" ) { if ( func_num_args ( ) == 1 ) { $ css = $ id ; $ id = uniqid ( ) ; } $ this -> customCss [ $ id ] = $ css ; return $ this ; }
Register custom style on your apps . It is useful when you want to attach some custom style on the fly .
46,554
public function combine ( $ type , & $ files ) { $ basePath = realpath ( $ this -> getOption ( 'basePath' ) ) ; if ( empty ( $ basePath ) ) return $ files ; $ cacheName = $ this -> createCachePath ( $ this -> getOption ( 'cacheFileName' ) ? $ this -> getOption ( 'cacheFileName' ) : $ this -> createFileName ( $ type , $ files ) ) . '.' . $ type ; $ this -> setOption ( 'coreUrl' , $ this -> coreUrl ) ; $ minifier = new AssetsMinifier ( $ this -> options ) ; $ cacheUrl = $ minifier -> compress ( $ type , $ files , $ cacheName ) ; if ( ! empty ( $ files ) ) array_walk ( $ files , function ( & $ value , $ key ) use ( $ cacheUrl ) { $ value = $ cacheUrl ; } ) ; $ this -> cached [ $ type ] = $ cacheUrl ; }
Combining cache path
46,555
private function prepareAssets ( ) { $ lib = $ this ; $ attached_groups = $ this -> getAttachedGroups ( ) ; array_walk ( $ lib -> attached_groups , function ( $ group_name ) use ( $ lib ) { $ groups = $ lib -> getGroups ( ) ; $ group_contents = $ groups [ $ group_name ] ; array_walk ( $ group_contents , function ( $ value , $ key ) use ( $ lib , $ group_name ) { switch ( $ key ) { case 'css' : array_walk ( $ value , function ( $ value , $ key ) use ( $ lib , $ group_name ) { $ lib -> registerCss ( $ group_name . '/' . $ value , $ group_name ) ; } ) ; break ; case 'js' : array_walk ( $ value , function ( $ value , $ key ) use ( $ lib , $ group_name ) { $ lib -> registerJs ( $ group_name . '/' . $ value , $ lib -> getOption ( 'jsPosition' ) , $ group_name ) ; } ) ; break ; } } ) ; } ) ; return $ this ; }
preparing auto attached groups before registering any asset files
46,556
public function add ( $ name ) { $ this -> repository -> setCurrentUser ( $ this -> repository -> getUserService ( ) -> loadUser ( $ this -> adminID ) ) ; $ contentTypeService = $ this -> repository -> getContentTypeService ( ) ; $ contentTypeGroupStruct = $ contentTypeService -> newContentTypeGroupCreateStruct ( $ name ) ; try { $ contentTypeGroup = $ contentTypeService -> createContentTypeGroup ( $ contentTypeGroupStruct ) ; return $ contentTypeGroup ; } catch ( UnauthorizedException $ e ) { throw new \ RuntimeException ( $ e -> getMessage ( ) ) ; } catch ( InvalidArgumentException $ e ) { throw new \ RuntimeException ( $ e -> getMessage ( ) ) ; } }
Create eZ ContentTypeGroup
46,557
public function replace ( ) { foreach ( $ this -> matches as $ match ) { $ value = $ this -> extractValue ( $ match ) ; $ this -> insertValue ( $ value , $ match [ 'raw' ] ) ; } }
Loops through the matches and replaces their value with the mask string
46,558
public function insertValue ( $ value , $ match ) { $ this -> str = str_replace ( $ match , $ value , $ this -> str ) ; }
Performs str_replace with value and match on the str
46,559
public function extractValue ( Array $ match ) { switch ( gettype ( $ match [ 'value' ] ) ) { case 'string' : return $ match [ 'value' ] ; break ; case 'object' : if ( get_class ( $ match [ 'value' ] ) == 'Closure' ) { return $ this -> closureExtract ( $ match ) ; } return $ this -> classExtract ( $ match ) ; break ; } throw new Exceptions \ UnexpectedMaskValue ( $ match [ 'value' ] , $ match [ 'raw' ] ) ; }
Checks the type of value and formats it as we could be getting closures passed
46,560
public function classExtract ( Array $ match ) { $ extract = new ClassExtraction ( get_class ( $ match [ 'value' ] ) , $ match ) ; return $ extract -> extract ( ) ; }
Extracts value from class
46,561
public function dispatch ( ResponseInterface $ response , int $ status , $ result ) { $ contents = [ 'status' => $ status , 'result' => $ result , ] ; $ contents = json_encode ( $ contents , JSON_PRETTY_PRINT ) ; $ response -> getBody ( ) -> write ( $ contents ) ; return $ response -> withStatus ( $ status ) ; }
JSON response class
46,562
public function sort ( bool $ desc = false ) { $ items = $ this -> items ; asort ( $ items ) ; if ( $ desc ) { $ items = array_reverse ( $ items , true ) ; } return new static ( $ items ) ; }
Sort an collection and maintain index association
46,563
public function sortKeys ( int $ options = SORT_REGULAR , bool $ desc = false ) { $ items = $ this -> items ; $ desc ? krsort ( $ items , $ options ) : ksort ( $ items , $ options ) ; return new static ( $ items ) ; }
Sort an collection by key
46,564
public function sortBy ( \ Closure $ callback , bool $ save_keys = true ) { $ items = $ this -> items ; $ save_keys ? uasort ( $ items , $ callback ) : usort ( $ items , $ callback ) ; return new static ( $ items ) ; }
Sort an collection by values using a user - defined comparison function
46,565
public function sortByKeys ( \ Closure $ callback ) { $ items = $ this -> items ; uksort ( $ items , $ callback ) ; return new static ( $ items ) ; }
Sort an collection by keys using a user - defined comparison function
46,566
private function remove_remarks ( $ sql ) { $ lines = explode ( "\n" , $ sql ) ; $ sql = "" ; $ linecount = count ( $ lines ) ; $ output = "" ; for ( $ i = 0 ; $ i < $ linecount ; $ i ++ ) { if ( ( $ i != ( $ linecount - 1 ) ) || ( strlen ( $ lines [ $ i ] ) > 0 ) ) { if ( isset ( $ lines [ $ i ] [ 0 ] ) && $ lines [ $ i ] [ 0 ] != "#" ) { $ output .= $ lines [ $ i ] . "\n" ; } else { $ output .= "\n" ; } $ lines [ $ i ] = "" ; } } return $ output ; }
Remove_remarks will strip the sql comment lines out of an uploaded sql file .
46,567
public function removeModuleQueueItem ( $ key_or_regex ) { $ removed_queue_items = [ ] ; if ( is_numeric ( $ key_or_regex ) ) { $ removed_queue_items [ ] = $ this -> _module_queue [ $ key_or_regex ] ; unset ( $ this -> _module_queue [ $ key_or_regex ] ) ; } else { foreach ( $ this -> _module_queue as $ key => $ queueItem ) { if ( preg_match ( $ key_or_regex , $ queueItem [ 'class' ] ) ) { $ removed_queue_items [ ] = $ this -> _module_queue [ $ key ] ; unset ( $ this -> _module_queue [ $ key ] ) ; } } } return $ removed_queue_items ; }
Removes a module from the module queue either by key or by a regex matched against the module controller namespace .
46,568
private function _insertModuleConfig ( $ namespace , $ overwrite ) { $ namespace_array = explode ( '\\' , trim ( $ namespace , '\\' ) ) ; $ path_array = array_slice ( $ namespace_array , 1 , 2 ) ; $ module_config_path = ROOT_PATH . implode ( '/' , $ path_array ) . '/configs/' ; $ module_config_path = str_replace ( '\\' , '/' , $ module_config_path ) ; $ module_name = $ path_array [ 1 ] ; $ module_config = Factory :: load ( 'Config:' . $ module_name ) ; $ module_config -> load ( $ module_config_path ) ; foreach ( $ overwrite as $ key => $ value ) { $ module_config -> set ( $ key , $ value ) ; } $ this -> _global_config -> set ( 'modules.' . $ module_name , $ module_config -> get ( ) ) ; }
Inserts a module s config params into the global config instance .
46,569
private function _runModuleController ( $ page_module ) { $ view = ( new $ page_module [ 'class' ] ) -> run ( $ this -> _dom ) ; if ( is_resource ( $ view ) && get_resource_type ( $ view ) == 'stream' ) { return [ 'handle' => $ view , 'type' => 'stream' , ] ; } if ( is_object ( $ view ) && is_subclass_of ( $ view , '\Morrow\Views\AbstractView' ) ) { $ view -> init ( $ page_module [ 'class' ] ) ; return [ 'handle' => $ view -> getOutput ( ) , 'type' => 'html' , ] ; } if ( is_string ( $ view ) ) { $ handle = fopen ( 'php://temp/maxmemory:' . ( 1 * 1024 * 1024 ) , 'r+' ) ; fwrite ( $ handle , $ view ) ; return [ 'handle' => $ handle , 'type' => 'string' , ] ; } if ( is_null ( $ view ) ) { return [ 'handle' => null , 'type' => null , ] ; } if ( ! isset ( $ handle ) ) { throw new \ Exception ( __CLASS__ . ': The return value of a controller has to be of type "stream", "string" or a child of \Morrow\Views\AbstractView.' ) ; } }
Execute any module .
46,570
private function doExecute ( $ fetch = false , $ fetchMode = null , $ fetchClass = null ) { if ( $ fetch ) { $ fetchMode = Database :: normalizeFetchType ( $ fetchMode ) ; } $ sql = $ this -> query -> getSQL ( ) ; $ bind = $ this -> query -> getBind ( ) ; $ statement = $ this -> connection -> prepare ( $ sql ) ; foreach ( $ bind as $ idx => $ value ) { $ statement -> bindValue ( ( $ idx + 1 ) , $ value , Database :: typeOfValue ( $ value ) ) ; } if ( $ fetch ) { if ( $ fetchMode === Database :: FETCH_CLASS ) { new \ ReflectionClass ( $ fetchClass ) ; $ statement -> setFetchMode ( $ fetchMode , $ fetchClass ) ; } else { $ statement -> setFetchMode ( $ fetchMode ) ; } } $ success = $ statement -> execute ( ) ; if ( ! $ success ) { return false ; } if ( $ fetch && $ fetch === 'single' ) { return $ statement -> fetch ( ) ; } if ( $ fetch ) { return $ statement -> fetchAll ( ) ; } return true ; }
Execute the query fetch if provided details to do so .
46,571
public function excel ( $ filename , $ data ) { \ Excel :: create ( $ filename , function ( $ excel ) use ( $ filename , $ data ) { $ excel -> sheet ( $ filename , function ( $ sheet ) use ( $ data ) { $ sheet -> fromArray ( $ data ) ; } ) ; } ) -> export ( 'xlsx' ) ; }
Export date to Excel file .
46,572
public function geoCoder ( $ lat , $ lng , $ ak , $ mcode , $ url ) { $ client = new \ GuzzleHttp \ Client ( ) ; $ parameters = [ 'form_params' => [ 'ak' => $ ak , 'location' => $ lat . ',' . $ lng , 'output' => 'json' , 'pois' => 0 , 'mcode' => $ mcode , ] , ] ; $ geo_coder = $ client -> request ( 'POST' , $ url , $ parameters ) ; $ geo_coder = json_decode ( $ geo_coder -> getBody ( ) ) ; return $ geo_coder ; }
Get geoCoder by Baidu .
46,573
private static function _remoteIP ( ) { foreach ( array ( 'HTTP_CLIENT_IP' , 'HTTP_X_FORWARDED_FOR' , 'HTTP_X_FORWARDED' , 'HTTP_X_CLUSTER_CLIENT_IP' , 'HTTP_FORWARDED_FOR' , 'HTTP_FORWARDED' , 'REMOTE_ADDR' ) as $ key ) { if ( array_key_exists ( $ key , $ _SERVER ) ) { foreach ( dejoin ( ',' , $ _SERVER [ $ key ] ) as $ ip ) { if ( filter_var ( $ ip , FILTER_VALIDATE_IP ) ) { return $ ip ; } ; } ; } ; } ; return null ; }
Get probable browser IP address
46,574
private static function _initCommon ( ) { global $ PPHP ; self :: $ _req [ 'warnings' ] = array ( ) ; self :: $ _req [ 'status' ] = 200 ; self :: $ _req [ 'redirect' ] = false ; self :: $ _req [ 'protocol' ] = ( self :: $ _req [ 'ssl' ] ? 'https' : 'http' ) ; }
Initialization common to CLI and web
46,575
public static function initCLI ( ) { global $ PPHP ; self :: $ _PATH = array ( ) ; self :: $ _req [ 'lang' ] = $ PPHP [ 'config' ] [ 'global' ] [ 'default_lang' ] ; self :: $ _req [ 'default_lang' ] = $ PPHP [ 'config' ] [ 'global' ] [ 'default_lang' ] ; self :: $ _req [ 'base' ] = '' ; self :: $ _req [ 'binary' ] = true ; self :: $ _req [ 'path' ] = '' ; self :: $ _req [ 'query' ] = '' ; self :: $ _req [ 'host' ] = $ PPHP [ 'config' ] [ 'global' ] [ 'host' ] ; self :: $ _req [ 'remote_addr' ] = '127.0.0.1' ; self :: $ _req [ 'ssl' ] = $ PPHP [ 'config' ] [ 'global' ] [ 'use_ssl' ] ; self :: $ _req [ 'get' ] = array ( ) ; self :: $ _req [ 'post' ] = array ( ) ; self :: $ _req [ 'path_args' ] = array ( ) ; self :: _initCommon ( ) ; trigger ( 'language' , self :: $ _req [ 'lang' ] ) ; }
Initialize request for CLI runs
46,576
public static function startup ( ) { global $ PPHP ; trigger ( 'language' , self :: $ _req [ 'lang' ] ) ; if ( isset ( self :: $ _PATH [ 1 ] ) && listeners ( 'route/' . self :: $ _PATH [ 0 ] . '+' . self :: $ _PATH [ 1 ] ) ) { self :: $ _base = array_shift ( self :: $ _PATH ) . '+' . array_shift ( self :: $ _PATH ) ; } elseif ( isset ( self :: $ _PATH [ 0 ] ) ) { if ( listeners ( 'route/' . self :: $ _PATH [ 0 ] ) ) { self :: $ _base = array_shift ( self :: $ _PATH ) ; } else { trigger ( 'http_status' , 404 ) ; } ; } elseif ( listeners ( 'route/main' ) ) { self :: $ _base = 'main' ; } else { trigger ( 'http_status' , 404 ) ; } ; self :: $ _req [ 'path_args' ] = self :: $ _PATH ; }
Build route from requested URL
46,577
public static function run ( ) { if ( ! pass ( 'validate_request' , 'route/' . self :: $ _base ) ) { return ; } ; if ( self :: $ _base !== null && ! pass ( 'route/' . self :: $ _base , self :: $ _PATH ) ) { trigger ( 'http_status' , 500 ) ; } ; }
Trigger handler for current route
46,578
public static function addWarning ( $ code , $ level = 1 , $ args = null ) { if ( $ args === null ) { $ args = array ( ) ; } ; if ( ! is_array ( $ args ) ) { $ args = array ( $ args ) ; } ; switch ( $ level ) { case 0 : case 1 : case 2 : case 3 : break ; default : $ level = 1 ; } ; self :: $ _req [ 'warnings' ] [ ] = array ( $ level , $ code , $ args ) ; }
Add warning to the list
46,579
public function factory ( $ adapter , $ options = null ) { $ adapter = parent :: factory ( $ adapter , $ options ) ; $ adapter -> setModel ( $ this -> getModel ( ) ) ; if ( $ adapter instanceof ServiceLocatorAwareInterface ) { $ adapter -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } return $ adapter ; }
Factory an object
46,580
public function generateModuleUrl ( $ actionName , array $ parameters = array ( ) , $ absolute = false ) { return $ this -> module -> generateModuleUrl ( $ actionName , $ parameters , $ absolute ) ; }
Generates a module url .
46,581
public function render ( $ template , array $ parameters = array ( ) , $ response = null ) { if ( is_array ( $ template ) ) { $ parameters = $ template ; $ bundle = '' ; $ module = null ; foreach ( explode ( '\\' , get_class ( $ this -> getModule ( ) ) ) as $ part ) { if ( null === $ module ) { if ( strlen ( $ part ) > 6 && 'Bundle' === substr ( $ part , - 6 ) ) { $ bundle .= $ part ; $ module = '' ; } elseif ( 'Bundle' !== $ part ) { $ bundle .= $ part ; } } elseif ( strlen ( $ part ) > 6 && 'Module' === substr ( $ part , - 6 ) ) { $ module = substr ( $ part , 0 , strlen ( $ part ) - 6 ) ; } } if ( null === $ bundle || null === $ module ) { throw new \ RuntimeException ( sprintf ( 'The template for the action "%s" from the module "%s" cannot be guessed.' , $ this -> getName ( ) , get_class ( $ this -> getModule ( ) ) ) ) ; } $ template = sprintf ( '%s:%s:%s.html.twig' , $ bundle , $ module , $ this -> getName ( ) ) ; } $ parameters [ 'module' ] = $ this -> module -> createView ( ) ; return $ this -> getContainer ( ) -> get ( 'templating' ) -> renderResponse ( $ template , $ parameters , $ response ) ; }
Renders a view a returns a response .
46,582
public function createFormBuilder ( $ data = null , array $ options = array ( ) ) { return $ this -> getContainer ( ) -> get ( 'form.factory' ) -> createBuilder ( 'form' , $ data , $ options ) ; }
Creates and returns a form builder instance
46,583
public function execute ( Request $ request , Response $ response ) { $ handle = curl_init ( ) ; curl_setopt ( $ handle , CURLOPT_HEADERFUNCTION , array ( & $ response , 'header' ) ) ; curl_setopt ( $ handle , CURLOPT_FORBID_REUSE , 1 ) ; curl_setopt ( $ handle , CURLOPT_FRESH_CONNECT , 1 ) ; if ( $ request -> hasHeaders ( ) ) { curl_setopt ( $ handle , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ handle , CURLOPT_HTTPHEADER , $ request -> getHeaders ( ) ) ; } if ( $ request -> hasUsername ( ) && $ request -> hasPassword ( ) ) { curl_setopt ( $ handle , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; curl_setopt ( $ handle , CURLOPT_USERPWD , $ request -> getUsername ( ) . ':' . $ request -> getPassword ( ) ) ; } if ( $ request -> hasTimeout ( ) ) curl_setopt ( $ handle , CURLOPT_TIMEOUT , $ request -> getTimeout ( ) ) ; curl_setopt ( $ handle , CURLOPT_URL , $ request -> getUrl ( ) ) ; curl_setopt ( $ handle , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ handle , CURLOPT_SSL_VERIFYPEER , FALSE ) ; curl_setopt ( $ handle , CURLOPT_SSL_VERIFYHOST , 0 ) ; curl_setopt ( $ handle , CURLOPT_FOLLOWLOCATION , 1 ) ; $ method = $ request -> getMethod ( ) ; if ( ! method_exists ( $ this , strtolower ( $ method ) ) ) throw new Exception ( __METHOD__ . '; Request method "' . $ method . '" not supported' ) ; call_user_func ( array ( $ this , strtolower ( $ method ) ) , $ handle , $ request , $ response ) ; curl_exec ( $ handle ) ; $ info = curl_getinfo ( $ handle ) ; $ response -> setInfo ( $ info ) ; if ( ! is_null ( $ handle ) && is_resource ( $ handle ) ) curl_close ( $ handle ) ; }
Do rest call
46,584
protected function processIncludes ( ) { foreach ( $ this -> getXml ( ) -> xpath ( '/includes/include[@type != "" and @file != ""]' ) as $ include ) { $ processor = $ this -> getIncludeProcessor ( ( string ) $ include [ 'type' ] ) ; if ( ! $ processor ) { trigger_error ( sprintf ( 'No include processor for "%s" available. Did you forget to register it?' , ( string ) $ include [ 'type' ] ) , E_USER_WARNING ) ; continue ; } $ file = $ this -> getModulePath ( ( string ) $ include [ 'file' ] ) ; $ processor -> load ( $ file , $ this -> manifest ) ; } return $ this ; }
Process include directives
46,585
public function validate ( $ xsd = null ) { if ( ! $ xsd ) { $ xsdPath = __DIR__ . '/../../../resources/xsd/' ; $ xsd = $ xsdPath . 'rampage/core/ModuleManifest.xsd' ; } try { $ dom = new DOMDocument ( ) ; $ dom -> loadXML ( $ this -> getXml ( ) -> asXML ( ) ) ; $ result = $ dom -> schemaValidate ( $ xsd ) ; unset ( $ dom ) ; } catch ( \ Exception $ e ) { return false ; } return $ result ; }
Validate manifest xml
46,586
public function getModulePath ( $ file , $ asFileInfo = false ) { $ path = $ this -> moduleDirectory . ltrim ( $ file , '/' ) ; if ( $ asFileInfo ) { $ path = new \ SplFileInfo ( $ path ) ; } return $ path ; }
Returns the file path for the current module
46,587
protected function loadServiceConfig ( ) { $ xml = $ this -> getNode ( './servicemanager' ) ; $ config = $ this -> createServiceManagerConfig ( $ xml , true ) ; if ( $ config ) { $ this -> manifest [ 'application_config' ] [ 'service_manager' ] = $ config ; } return $ this ; }
Load service config
46,588
protected function loadPluginManagerConfigs ( ) { foreach ( $ this -> getXml ( ) -> xpath ( 'plugins/pluginmanager[@type != ""]' ) as $ pmConfig ) { $ key = ( string ) $ pmConfig [ 'type' ] ; $ config = $ this -> createServiceManagerConfig ( $ pmConfig ) ; if ( $ config ) { $ this -> manifest [ 'application_config' ] [ $ key ] = $ config ; } } return $ this ; }
Plugin manager configs
46,589
protected function loadLocaleConfig ( ) { $ xml = $ this -> getXml ( ) ; $ config = & $ this -> manifest [ 'application_config' ] ; if ( ! isset ( $ xml -> locale -> pattern ) ) { return $ this ; } foreach ( $ xml -> xpath ( 'locale/pattern[@pattern != ""]' ) as $ node ) { $ dir = isset ( $ node [ 'basedir' ] ) ? ( string ) $ node [ 'basedir' ] : 'locale' ; $ config [ 'translator' ] [ 'translation_file_patterns' ] [ ] = array ( 'type' => isset ( $ node [ 'type' ] ) ? ( string ) $ node [ 'type' ] : 'php' , 'base_dir' => $ this -> getModulePath ( $ dir ) , 'pattern' => isset ( $ node [ 'pattern' ] ) ? ( string ) $ node [ 'pattern' ] : '%s.php' , ) ; } return $ this ; }
Load locale config
46,590
protected function childToArray ( SimpleXmlElement $ xml , $ name ) { if ( ! isset ( $ xml -> { $ name } ) ) { return array ( ) ; } return $ xml -> { $ name } -> toPhpValue ( 'array' ) ; }
Child node to array
46,591
protected function getRouteConfig ( $ node ) { if ( ( ! $ node instanceof SimpleXmlElement ) || ! $ node -> route ) { return false ; } $ config = array ( ) ; foreach ( $ node -> route as $ route ) { $ type = ( string ) $ route [ 'type' ] ; $ name = ( string ) $ route [ 'name' ] ; if ( ! $ name ) { continue ; } $ routeConfig = $ this -> getRouteConfigOptions ( $ route , $ type ) ; if ( ! is_array ( $ routeConfig ) ) { return null ; } $ config [ $ name ] = $ routeConfig ; if ( isset ( $ route [ 'mayterminate' ] ) ) { $ config [ $ name ] [ 'may_terminate' ] = $ route -> is ( 'mayterminate' ) ; } $ children = $ this -> getRouteConfig ( $ route -> routes ) ; if ( ! empty ( $ children ) ) { $ config [ $ name ] [ 'child_routes' ] = $ children ; } } return $ config ; }
get route config from manifest xml
46,592
protected function loadRouteConfig ( ) { $ xml = $ this -> getNode ( 'router' ) ; if ( ! $ xml instanceof SimpleXmlElement ) { return $ this ; } $ config = $ this -> getRouteConfig ( $ xml ) ; if ( ! $ config ) { return $ this ; } $ this -> manifest [ 'application_config' ] [ 'router' ] [ 'routes' ] = $ config ; return $ this ; }
Load route config from manifest
46,593
protected function loadThemeConfig ( ) { $ xml = $ this -> getXml ( ) ; foreach ( $ xml -> xpath ( './resources/themes/theme[@name != "" and @path != ""]' ) as $ node ) { $ path = ( string ) $ node [ 'path' ] ; $ name = ( string ) $ node [ 'name' ] ; $ this -> manifest [ 'application_config' ] [ 'rampage' ] [ 'themes' ] [ $ name ] [ 'path' ] = $ this -> getModulePath ( $ path ) ; if ( isset ( $ node [ 'fallbacks' ] ) ) { $ fallbacks = explode ( ',' , ( string ) $ node [ 'fallbacks' ] ) ; $ fallbacks = array_filter ( array_map ( 'trim' , $ fallbacks ) ) ; $ this -> manifest [ 'application_config' ] [ 'rampage' ] [ 'themes' ] [ $ name ] [ 'fallbacks' ] = $ fallbacks ; } } return $ this ; }
Load theme config
46,594
public function getStatistics ( $ status ) { $ qb = $ this -> createQueryBuilder ( 'q' ) ; $ qb -> select ( 'SUBSTRING(q.job, 1, 200) AS class' ) ; $ qb -> where ( $ qb -> expr ( ) -> eq ( 'q.status' , $ qb -> expr ( ) -> literal ( $ status ) ) ) ; $ result = $ qb -> getQuery ( ) -> getScalarResult ( ) ; $ stats = [ ] ; foreach ( $ result as $ item ) { if ( ! preg_match ( '/"(.+?)"/' , $ item [ 'class' ] , $ match ) ) { continue ; } $ class = $ match [ 1 ] ; if ( ! isset ( $ stats [ $ class ] ) ) { $ stats [ $ class ] = 0 ; } ++ $ stats [ $ class ] ; } return $ stats ; }
Return job statistics .
46,595
protected function getConfigArr ( string $ configAppFile ) : array { $ configCoreFile = __DIR__ . '/../Config/config.php' ; $ configCore = $ this -> requireFile ( $ configCoreFile ) ; $ configApp = $ this -> requireFile ( $ configAppFile ) ; $ services = [ ] ; $ skipCoreServices = $ configApp [ 'skipCoreServices' ] ?? false ; if ( isset ( $ configCore [ 'services' ] ) && ! $ skipCoreServices ) { $ services [ ] = $ configCore [ 'services' ] ; } if ( isset ( $ configApp [ 'services' ] ) ) { $ services [ ] = $ configApp [ 'services' ] ; } $ configArr = array_replace_recursive ( $ configCore , $ configApp ) ; $ configArr [ 'services' ] = $ services ; return $ configArr ; }
Gets a configuration array .
46,596
public function preAdd ( Event $ e ) { $ form = $ e -> getParam ( 'form' ) ; $ inputFilter = $ form -> getInputFilter ( ) ; $ inputFilter -> addEmailNoRecordExists ( ) ; }
Pre subscriber add checks
46,597
public function getObject ( ) { if ( ! empty ( $ this -> _embedded ) ) { $ parts = array ( ) ; if ( $ this -> _html != null ) { $ part = new Zend_Mime_Part ( $ this -> _html ) ; $ part -> charset = $ this -> _object -> getCharset ( ) ; $ part -> encoding = Zend_Mime :: ENCODING_QUOTEDPRINTABLE ; $ part -> disposition = Zend_Mime :: DISPOSITION_INLINE ; $ part -> type = Zend_Mime :: TYPE_HTML ; $ parts = array ( $ part ) ; } $ msg = new Zend_Mime_Message ( ) ; $ msg -> setParts ( array_merge ( $ parts , $ this -> _embedded ) ) ; $ this -> _object -> setBodyHtml ( $ msg -> generateMessage ( ) ) ; $ related = $ this -> _object -> getBodyHtml ( ) ; $ related -> type = Zend_Mime :: MULTIPART_RELATED ; $ related -> encoding = Zend_Mime :: ENCODING_8BIT ; $ related -> boundary = $ msg -> getMime ( ) -> boundary ( ) ; $ related -> disposition = null ; $ related -> charset = null ; } else if ( $ this -> _html != null ) { $ this -> _object -> setBodyHtml ( $ this -> _html ) ; } return $ this -> _object ; }
Returns the internal Zend mail object .
46,598
protected function prefixModule ( $ name ) { if ( strpos ( $ name , ':' ) === false ) { $ name = $ this -> getModuleName ( ) . ':' . $ name ; } return $ name ; }
Prefix a service name with the current module name if one is not already set .
46,599
protected function checkCache ( $ name ) { if ( ! isset ( $ this -> files [ $ name ] ) ) { $ this -> files [ $ name ] = $ this -> getObject ( $ name ) ; } }
Check to see whether a file exists in the local cache