idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
56,800
public function getConfigModel ( $ store = null ) { return Mage :: getModel ( 'radial_core/config_registry' ) -> setStore ( $ store ) -> addConfigModel ( Mage :: getSingleton ( 'radial_order/config' ) ) ; }
Gets a combined configuration model from core and order
56,801
public function removeOrderIncrementPrefix ( $ incrementId ) { $ stores = $ this -> _getAllStores ( ) ; foreach ( $ stores as $ store ) { $ prefix = $ this -> _coreHelper -> getConfigModel ( $ store -> getId ( ) ) -> clientOrderIdPrefix ; if ( strpos ( $ incrementId , $ prefix ) === 0 ) { return substr ( $ incrementId , strlen ( $ prefix ) ) ; } } return ( string ) $ incrementId ; }
Remove a client order id prefix from the increment id . As the prefix on the increment id may have been any of the configured order id prefixes need to check through all possible prefixes configured to find the one to remove .
56,802
public function setup ( Model $ Model , $ config = array ( ) ) { parent :: setup ( $ Model , $ config ) ; $ this -> config [ $ Model -> alias ] = $ config + ( array ) Configure :: read ( 'Serializable' ) + array ( 'fields' => array ( ) , 'serialize' => 'serialize' , 'unserialize' => 'unserialize' , 'aliases' => array ( ) , 'merge' => false ) ; }
Initialize Serializable Behavior
56,803
public function afterFind ( Model $ Model , $ results , $ primary = false ) { foreach ( $ results as $ key => & $ result ) { foreach ( $ this -> config [ $ Model -> alias ] [ 'fields' ] as $ field ) { $ this -> _unserializeFindField ( $ field , $ key , $ result , $ Model ) ; } } unset ( $ result ) ; return $ results ; }
After find callback . Unserializes all specified fields in each result
56,804
public function beforeSave ( Model $ Model , $ options = array ( ) ) { $ currentData = false ; if ( $ this -> config [ $ Model -> alias ] [ 'merge' ] && ( isset ( $ Model -> data [ $ Model -> alias ] [ $ Model -> primaryKey ] ) || isset ( $ Model -> data [ $ Model -> primaryKey ] ) ) ) { $ Model -> recursive = - 1 ; $ currentData = $ Model -> find ( 'first' , array ( 'conditions' => array ( $ Model -> primaryKey => ( isset ( $ Model -> data [ $ Model -> alias ] [ $ Model -> primaryKey ] ) ? $ Model -> data [ $ Model -> alias ] [ $ Model -> primaryKey ] : $ Model -> data [ $ Model -> primaryKey ] ) ) , 'fields' => $ this -> config [ $ Model -> alias ] [ 'fields' ] ) ) ; } foreach ( $ this -> config [ $ Model -> alias ] [ 'fields' ] as $ field ) { if ( isset ( $ Model -> data [ $ Model -> alias ] [ $ field ] ) ) { if ( $ currentData ) { $ Model -> data [ $ Model -> alias ] [ $ field ] = array_replace_recursive ( ( array ) $ currentData [ $ Model -> alias ] [ $ field ] , ( array ) $ Model -> data [ $ Model -> alias ] [ $ field ] ) ; } $ Model -> data [ $ Model -> alias ] [ $ field ] = $ this -> _serialize ( $ Model -> alias , $ Model -> data [ $ Model -> alias ] [ $ field ] ) ; } elseif ( isset ( $ Model -> data [ $ field ] ) ) { if ( $ currentData ) { $ Model -> data [ $ field ] = array_replace_recursive ( $ currentData [ $ Model -> alias ] [ $ field ] , $ Model -> data [ $ field ] ) ; } $ Model -> data [ $ field ] = $ this -> _serialize ( $ Model -> alias , $ Model -> data [ $ field ] ) ; } } return true ; }
Before save callback . Serializes all specified fields in model data
56,805
public function afterSave ( Model $ model , $ created , $ options = array ( ) ) { $ model -> data = $ this -> afterFind ( $ model , $ model -> data ) ; }
After save callback . Unserializes all specified fields in each result
56,806
protected function _unserializeFindField ( $ field , $ key , & $ result , Model $ Model ) { if ( isset ( $ result [ $ field ] ) ) { $ result [ $ field ] = $ this -> _unserialize ( $ Model -> alias , $ result [ $ field ] ) ; } elseif ( $ key === $ field ) { $ result = $ this -> _unserialize ( $ Model -> alias , $ result ) ; } else { foreach ( $ this -> _getAliases ( $ Model ) as $ alias ) { if ( isset ( $ result [ $ alias ] [ $ field ] ) ) { $ result [ $ alias ] [ $ field ] = $ this -> _unserialize ( $ Model -> alias , $ result [ $ alias ] [ $ field ] ) ; } elseif ( isset ( $ result [ $ alias ] ) && is_array ( $ result [ $ alias ] ) ) { foreach ( $ result [ $ alias ] as $ _key => & $ _result ) { $ this -> _unserializeFindField ( $ field , $ _key , $ _result , $ Model ) ; } } } } }
Unserialize one field after find
56,807
protected function _unserialize ( $ alias , $ data ) { if ( ! is_string ( $ data ) ) { return $ data ; } return call_user_func ( $ this -> config [ $ alias ] [ 'unserialize' ] , $ data ) ; }
Invokes unserialization . Unserialization function is set by globall config model config or defaults to unserialize
56,808
private function path2action ( $ s ) { $ s = strtolower ( $ s ) ; $ s = preg_replace ( '#-(?=[a-z])#' , ' ' , $ s ) ; $ s = substr ( ucwords ( 'x' . $ s ) , 1 ) ; $ s = str_replace ( ' ' , '' , $ s ) ; return $ s ; }
dash - separated - > camelCaseAction name .
56,809
public function start ( string $ id , string $ name = 'PHPSESSID' , array $ options = [ ] ) : self { if ( $ this -> disabled ( ) ) { throw new \ RuntimeException ( 'PHP sessions are disabled' ) ; } if ( $ this -> active ( ) ) { throw new \ RuntimeException ( 'Failed to start the session: already started by PHP.' ) ; } session_name ( $ name ) ; session_id ( $ id ) ; session_start ( $ options ) ; $ this -> name = $ name ; $ this -> id = $ id ; $ this -> options = $ options ; $ this -> data = $ _SESSION ; return $ this ; }
Starts session with specific id name and options .
56,810
public function save ( ) : void { if ( $ this -> active ( ) && session_name ( ) == $ this -> name ( ) ) { $ _SESSION = $ this -> all ( ) ; session_write_close ( ) ; } }
Save and close session .
56,811
public function decode ( $ hash ) { $ binary = "" ; $ hl = strlen ( $ hash ) ; for ( $ i = 0 ; $ i < $ hl ; $ i ++ ) { $ binary .= $ this -> codingMap [ substr ( $ hash , $ i , 1 ) ] ; } $ bl = strlen ( $ binary ) ; $ blat = "" ; $ blong = "" ; for ( $ i = 0 ; $ i < $ bl ; $ i ++ ) { if ( $ i % 2 ) $ blat = $ blat . substr ( $ binary , $ i , 1 ) ; else $ blong = $ blong . substr ( $ binary , $ i , 1 ) ; } $ lat = $ this -> binDecode ( $ blat , - 90 , 90 ) ; $ long = $ this -> binDecode ( $ blong , - 180 , 180 ) ; $ latErr = $ this -> calcError ( strlen ( $ blat ) , - 90 , 90 ) ; $ longErr = $ this -> calcError ( strlen ( $ blong ) , - 180 , 180 ) ; $ latPlaces = max ( 1 , - round ( log10 ( $ latErr ) ) ) - 1 ; $ longPlaces = max ( 1 , - round ( log10 ( $ longErr ) ) ) - 1 ; $ lat = round ( $ lat , $ latPlaces ) ; $ long = round ( $ long , $ longPlaces ) ; return array ( $ lat , $ long ) ; }
Decode a geohash and return an array with decimal lat long in it
56,812
public function encode ( $ lat , $ long ) { $ plat = $ this -> precision ( $ lat ) ; $ latbits = 1 ; $ err = 45 ; while ( $ err > $ plat ) { $ latbits ++ ; $ err /= 2 ; } $ plong = $ this -> precision ( $ long ) ; $ longbits = 1 ; $ err = 90 ; while ( $ err > $ plong ) { $ longbits ++ ; $ err /= 2 ; } $ bits = max ( $ latbits , $ longbits ) ; $ longbits = $ bits ; $ latbits = $ bits ; $ addlong = 1 ; while ( ( $ longbits + $ latbits ) % 5 != 0 ) { $ longbits += $ addlong ; $ latbits += ! $ addlong ; $ addlong = ! $ addlong ; } $ blat = $ this -> binEncode ( $ lat , - 90 , 90 , $ latbits ) ; $ blong = $ this -> binEncode ( $ long , - 180 , 180 , $ longbits ) ; $ binary = "" ; $ uselong = 1 ; while ( strlen ( $ blat ) + strlen ( $ blong ) ) { if ( $ uselong ) { $ binary = $ binary . substr ( $ blong , 0 , 1 ) ; $ blong = substr ( $ blong , 1 ) ; } else { $ binary = $ binary . substr ( $ blat , 0 , 1 ) ; $ blat = substr ( $ blat , 1 ) ; } $ uselong = ! $ uselong ; } $ hash = "" ; for ( $ i = 0 ; $ i < strlen ( $ binary ) ; $ i += 5 ) { $ n = bindec ( substr ( $ binary , $ i , 5 ) ) ; $ hash = $ hash . $ this -> coding [ $ n ] ; } return $ hash ; }
Encode a hash from given lat and long
56,813
public static function setOption ( $ key , $ val ) { self :: init ( ) ; return self :: $ instance -> setOption ( $ key , $ val ) ; }
set log option for all future executions of makeLog
56,814
public function refreshProfile ( array $ userProfile = [ ] ) { if ( count ( $ userProfile ) == 0 ) { $ userProfile = $ this -> getProfileFromApi ( ) ; } $ success = false ; if ( is_array ( $ userProfile ) ) { $ info = $ this -> mapPropertiesFromApi ( $ userProfile ) ; $ this -> grantAllPermissions ( ) ; $ success = $ this -> set ( $ info ) ; $ this -> enforcePermissions ( ) ; } return $ success ; }
Refreshes this profile using the API of the social network .
56,815
public static function refreshProfiles ( ) { $ profile = new static ( ) ; $ staleDate = time ( ) - ( $ profile -> daysUntilStale ( ) * 86400 ) ; $ profiles = static :: findAll ( [ 'where' => [ 'access_token <> ""' , 'last_refreshed < ' . $ staleDate , ] , 'limit' => $ profile -> numProfilesToRefresh ( ) , 'sortBy' => 'last_refreshed DESC' , ] ) ; foreach ( $ profiles as $ profile ) { $ profile -> refreshProfile ( ) ; } return true ; }
Refreshes stale twitter profiles . One call currently only refreshes 180 profiles to minimize bumping into twitter s rate limiting .
56,816
protected function mapPropertiesFromApi ( array $ user_profile ) { $ info = [ ] ; foreach ( $ this -> apiPropertyMapping ( ) as $ modelProperty => $ apiProperty ) { $ info [ $ modelProperty ] = U :: array_value ( $ user_profile , $ apiProperty ) ; } return $ info ; }
Maps the properties of the user profile from the API to the properties in our model .
56,817
protected static function is_numeric ( $ type ) { switch ( $ type ) { case self :: INT : case self :: TINYINT : case self :: MEDIUMINT : case self :: BIGINT : case self :: DOUBLE : case self :: FLOAT : case self :: REAL : case self :: DECIMAL : return true ; break ; default : return false ; break ; } }
Type is numeric
56,818
public function getServiceSpecification ( $ entity ) { if ( ! is_object ( $ entity ) ) { if ( ( is_string ( $ entity ) && ( ! class_exists ( $ entity ) ) ) || ( ! is_string ( $ entity ) ) ) { throw new Exception \ InvalidArgumentException ( sprintf ( '%s expects an object or valid class name; received "%s"' , __METHOD__ , var_export ( $ entity , 1 ) ) ) ; } } $ serviceSpec = new ArrayObject ( ) ; $ serviceSpec [ 'operations' ] = new ArrayObject ( ) ; $ reflection = new ClassReflection ( $ entity ) ; $ this -> parseClassSpecifications ( $ reflection , $ serviceSpec ) ; return $ serviceSpec ; }
Creates and returns service definition as an array object
56,819
protected function parseClassSpecifications ( ClassReflection $ class , ArrayObject $ serviceSpec ) { if ( $ class -> getParentClass ( ) ) { $ this -> parseClassSpecifications ( $ class -> getParentClass ( ) , $ serviceSpec ) ; } $ annotationManager = $ this -> getAnnotationManager ( ) ; $ annotations = $ class -> getAnnotations ( $ annotationManager ) ; if ( ! array_key_exists ( 'version' , $ serviceSpec ) ) { $ serviceSpec [ 'version' ] = null ; } $ serviceSpec [ 'exclude_patterns' ] = array ( ) ; $ serviceSpec [ 'exclude' ] = false ; $ serviceSpec [ 'contexts' ] = array ( 'native' ) ; if ( $ annotations instanceof AnnotationCollection ) { $ this -> configureService ( $ annotations , $ class , $ serviceSpec ) ; } if ( $ serviceSpec [ 'exclude' ] ) { return ; } foreach ( $ class -> getMethods ( ) as $ method ) { if ( $ method -> getDeclaringClass ( ) -> getName ( ) !== $ class -> getName ( ) ) { continue ; } if ( $ this -> isDeclaredInTrait ( $ method ) ) { continue ; } try { $ annotations = $ method -> getAnnotations ( $ annotationManager ) ; } catch ( \ Doctrine \ Common \ Annotations \ AnnotationException $ e ) { throw new AnnotationException ( 'Error parsing annotation for class "' . $ class -> getName ( ) . '::' . $ method -> getName ( ) . '"' , 0 , $ e ) ; } catch ( \ Exception $ e ) { if ( strpos ( $ e -> getMessage ( ) , 'Argument 3 passed to Zend\Code\Scanner\AnnotationScanner' ) === 0 ) { continue ; } throw $ e ; } if ( ! $ annotations instanceof AnnotationCollection ) { $ annotations = new AnnotationCollection ( ) ; } $ this -> configureOperation ( $ annotations , $ method , $ serviceSpec ) ; } }
Parse class level specs for service
56,820
public function getAnnotationManager ( ) { if ( $ this -> annotationManager ) { return $ this -> annotationManager ; } $ this -> setAnnotationManager ( new AnnotationManager ( ) ) ; return $ this -> annotationManager ; }
Retrieve annotation manager
56,821
public function setAnnotationManager ( AnnotationManager $ annotationManager ) { $ parser = new Parser \ DoctrineAnnotationParser ( ) ; foreach ( $ this -> defaultAnnotations as $ annotationName ) { $ class = __NAMESPACE__ . '\\' . $ annotationName ; $ parser -> registerAnnotation ( $ class ) ; } $ annotationManager -> attach ( $ parser ) ; $ this -> annotationManager = $ annotationManager ; return $ this ; }
Set annotation manager to use when building form from annotations
56,822
public function setEventManager ( EventManagerInterface $ events ) { $ events -> setIdentifiers ( array ( __CLASS__ , get_class ( $ this ) , ) ) ; $ events -> attach ( new OperationAnnotationsListener ( ) ) ; $ events -> attach ( new ServiceAnnotationsListener ( ) ) ; $ this -> events = $ events ; return $ this ; }
Set event manager instance
56,823
protected function configureService ( AnnotationCollection $ annotations , ClassReflection $ reflection , ArrayObject $ serviceSpec ) { $ events = $ this -> getEventManager ( ) ; foreach ( $ annotations as $ annotation ) { $ events -> trigger ( __FUNCTION__ , $ this , array ( 'annotation' => $ annotation , 'name' => $ reflection -> getName ( ) , 'serviceSpec' => $ serviceSpec ) ) ; } }
Configure service based on annotations
56,824
protected function configureOperation ( AnnotationCollection $ annotations , MethodReflection $ method , ArrayObject $ serviceSpec ) { if ( ! $ annotations -> count ( ) && isset ( $ serviceSpec [ 'operations' ] [ $ method -> getName ( ) ] ) ) { return ; } $ operationSpec = new ArrayObject ( array ( 'events' => array ( ) , 'contexts' => $ serviceSpec [ 'contexts' ] , 'aliases' => array ( ) , 'inherit' => false , 'exclude' => null ) ) ; $ events = $ this -> getEventManager ( ) ; $ event = new Event ( ) ; $ event -> setParams ( array ( 'name' => $ method -> getName ( ) , 'serviceSpec' => $ serviceSpec , 'operationSpec' => $ operationSpec ) ) ; foreach ( $ annotations as $ annotation ) { $ event -> setParam ( 'annotation' , $ annotation ) ; $ events -> trigger ( __FUNCTION__ , $ this , $ event ) ; } if ( $ operationSpec [ 'inherit' ] === true ) { return ; } $ excludePatterns = $ serviceSpec [ 'exclude_patterns' ] ; if ( $ operationSpec [ 'exclude' ] === true ) { return ; } elseif ( $ operationSpec [ 'exclude' ] === null && sizeof ( $ excludePatterns ) ) { foreach ( $ excludePatterns as $ excludePattern ) { if ( preg_match ( $ excludePattern , $ method -> getName ( ) ) ) { return ; } } } unset ( $ operationSpec [ 'exclude' ] ) ; $ serviceSpec [ 'operations' ] [ $ method -> getName ( ) ] = $ operationSpec ; }
Configure operation based on annotations
56,825
public function parse ( ) { return $ this -> setDescription ( ) -> setArray ( 'IS_ARRAY' ) -> setOptional ( ) -> setDefault ( ) -> setRequired ( ) -> calculateMode ( InputArgument :: class ) -> setName ( ) ; }
Parse the set argument string .
56,826
protected function setOptional ( ) { if ( substr ( $ this -> input , - 1 ) === '?' ) { $ this -> modeArray [ ] = 'OPTIONAL' ; $ this -> input = str_replace ( '?' , '' , $ this -> input ) ; } return $ this ; }
Set optional argument mode .
56,827
protected function setDefault ( ) { if ( strpos ( $ this -> input , '=' ) ) { list ( $ this -> input , $ this -> default ) = explode ( '=' , $ this -> input ) ; $ this -> modeArray [ ] = 'OPTIONAL' ; } return $ this ; }
Set default option value .
56,828
public function add ( $ method = 'GET' , $ uri = '/' , $ pattern = '' , array $ options = [ ] ) { $ this -> method [ ] = $ method ; $ this -> uri [ ] = $ uri ; $ this -> pattern [ ] = $ pattern ; $ this -> filter [ $ uri ] [ $ method ] = ( isset ( $ options [ 'filter' ] ) ) ? $ options [ 'filter' ] : '' ; }
To add route
56,829
public function register ( ) { $ route = new RouteCollector ( new Std ( ) , new DataGenerator ( ) ) ; for ( $ i = 0 ; $ i < count ( $ this -> uri ) ; $ i ++ ) { $ route -> addRoute ( $ this -> method [ $ i ] , $ this -> uri [ $ i ] , $ this -> pattern [ $ i ] ) ; } $ this -> dispatcher = new Dispatcher ( $ route -> getData ( ) ) ; }
To register route
56,830
public function dispatch ( $ method , $ uri ) { $ routeInfo = $ this -> dispatcher -> dispatch ( $ method , $ uri ) ; if ( $ routeInfo [ 0 ] === Dispatcher :: NOT_FOUND ) { $ this -> filterRequest ( '*' , $ method ) ; $ routeInfo = $ this -> dispatcher -> dispatch ( $ method , '*' ) ; if ( ! $ routeInfo [ 0 ] ) { throw new Exception ( "Route [ {$uri} ] not found." ) ; } } if ( $ routeInfo [ 0 ] === Dispatcher :: METHOD_NOT_ALLOWED ) { $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; throw new Exception ( "[ $method ] method not allowed." ) ; } if ( $ routeInfo [ 0 ] === Dispatcher :: FOUND ) { $ handler = $ routeInfo [ 1 ] ; $ params = $ routeInfo [ 2 ] ; if ( ! empty ( $ filterResponse = $ this -> filterRequest ( $ uri , $ method ) ) ) { return $ filterResponse ; } return $ this -> methodDispatcher ( $ handler , $ params ) ; } }
To dispatch a route
56,831
protected function methodDispatcher ( $ handler , $ params ) { if ( is_callable ( $ handler ) ) { $ resolving = $ this -> container -> resolveCallback ( $ handler , $ params ) ; $ this -> validateForm ( $ resolving ) ; return call_user_func_array ( $ handler , $ resolving ) ; } list ( $ controller , $ method ) = explode ( '@' , $ handler ) ; return $ this -> invoke ( $ controller , $ method , $ params ) ; }
To execute route handler
56,832
protected function invoke ( $ controller , $ method , $ params ) { if ( ! class_exists ( $ controller ) ) { throw new Exception ( "Controller [ $controller ] does not exist." ) ; } try { $ instance = $ this -> container -> make ( $ controller ) ; $ resolving = $ this -> container -> resolveMethod ( $ controller , $ method , $ params , true ) ; $ this -> validateForm ( $ resolving ) ; return call_user_func_array ( [ $ instance , $ method ] , $ resolving ) ; } catch ( DefinitionException $ e ) { throw new BindingException ( "Binding Error [ " . $ e -> getMessage ( ) . " ]" ) ; } }
To execute handler
56,833
protected function filterRequest ( $ uri , $ method ) { if ( ! empty ( $ filtersPattern = $ this -> filter [ $ uri ] [ $ method ] ) ) { $ filters = explode ( '|' , $ filtersPattern ) ; foreach ( $ filters as $ filter ) { list ( $ className , $ params ) = $ this -> getClassNameWithParams ( $ filter ) ; $ name = app ( ) -> getNamespace ( ) . 'Filters\\' . $ className ; $ instance = $ this -> container -> make ( $ name ) ; $ filterResponse = call_user_func_array ( [ $ instance , 'handle' ] , $ params ) ; if ( ! $ filterResponse instanceof Request ) { return $ filterResponse ; } } } }
To filter http request
56,834
protected function getClassNameWithParams ( $ filter ) { $ pattern = explode ( ':' , $ filter ) ; $ className = trim ( $ pattern [ 0 ] ) ; $ params = [ ] ; if ( isset ( $ pattern [ 1 ] ) ) { $ params = array_map ( 'trim' , explode ( ',' , $ pattern [ 1 ] ) ) ; } return [ $ className , $ params ] ; }
Get filterable class name and params
56,835
protected function signInUser ( UserInterface $ user , $ remember = false ) { return $ this -> auth -> signInUser ( $ user , $ this -> getId ( ) , $ remember ) ; }
Helper method to start a new user session from this strategy .
56,836
public function getServiceDescription ( ) { if ( null === $ this -> serviceDescription ) { $ serviceDescription = static :: loadServiceDescription ( ) ; $ serviceDescription [ 'ravelry.access_key' ] = $ this -> authentication -> getAccessKey ( ) ; $ serviceDescription [ 'operations' ] [ 'upload_image' ] [ 'parameters' ] [ 'access_key' ] [ 'default' ] = $ serviceDescription [ 'ravelry.access_key' ] ; $ this -> serviceDescription = new Description ( $ serviceDescription ) ; } return $ this -> serviceDescription ; }
Create our service description from the schema file . We inject a few runtime - specific values into the description .
56,837
public function getAvailableRollbacksByTarget ( Target $ target , $ limit = 50 , $ page = 0 ) { $ dql = sprintf ( self :: DQL_ROLLBACKS , Release :: class ) ; $ params = [ 'target' => $ target , 'release_status' => JobStatusEnum :: TYPE_SUCCESS , 'build_status' => JobStatusEnum :: TYPE_SUCCESS , ] ; return $ this -> getPaginator ( $ dql , $ limit , $ page , $ params ) ; }
Get all releases that can be used as a rollback paged .
56,838
public function getByTarget ( Target $ target , $ limit = 50 , $ page = 0 ) { $ dql = sprintf ( self :: DQL_BY_TARGET , Release :: class ) ; $ params = [ 'target' => $ target ] ; return $ this -> getPaginator ( $ dql , $ limit , $ page , $ params ) ; }
Get all releases to a target paged .
56,839
public function getByApplication ( Application $ application , $ limit = 50 , $ page = 0 , $ filter = '' ) { $ template = ( $ filter ) ? self :: DQL_BY_APPLICATION_WITH_REF_FILTER : self :: DQL_BY_APPLICATION ; $ dql = sprintf ( $ template , Release :: class ) ; $ params = [ 'application' => $ application ] ; if ( $ filter ) { $ params [ 'ref' ] = $ filter ; } return $ this -> getPaginator ( $ dql , $ limit , $ page , $ params ) ; }
Get all releases for an application paged .
56,840
public function requestingHelpInformation ( ) { $ validHelpTokens = [ '-h' , '--help' ] ; foreach ( $ this -> tokens as $ token ) { if ( in_array ( $ token , $ validHelpTokens ) ) { return true ; } } return false ; }
Determines if a user is requesting help information .
56,841
public function getTemplateName ( ) { if ( $ this -> templateName == null ) { $ this -> templateName = $ this -> tokens [ 1 ] ; } return $ this -> templateName ; }
Gets the template name from the input tokens .
56,842
private function initializeTemplatePath ( ) { $ this -> customTemplatePath = null ; foreach ( $ this -> tokens as $ token ) { if ( str_is ( '--newup-directory*' , $ token ) ) { $ this -> customTemplatePath = substr ( $ token , 18 ) ; break ; } } }
Initializes the custom template path variable .
56,843
private function getPackageClass ( ) { if ( $ this -> packageClass !== null ) { return $ this -> packageClass ; } $ includePath = $ this -> getPackageClassPath ( ) ; if ( ! file_exists ( $ includePath ) ) { Application :: getOutput ( ) -> writeln ( "<comment>{$this->getTemplateName()} is not installed. Attempting to install it now...</comment>" ) ; $ result = app ( Kernel :: class ) -> getApplication ( ) -> callWithSharedOutput ( 'template:install' , [ 'name' => $ this -> getTemplateName ( ) , '--confirm' => true ] ) ; if ( $ result === Install :: INSTALL_FAIL ) { throw new TemplatePackageMissingException ( "The package template {$this->getTemplateName()} is not installed or it cannot be found. The package template must be installed before it can be built." ) ; } else { Application :: getOutput ( ) -> writeln ( '<comment>It looks like everything went well. We will continue building the package template...</comment>' ) ; } } scope_include ( $ includePath ) ; $ this -> packageClass = $ packageClass = $ this -> getNamespacedPackageName ( ) ; if ( ! class_exists ( $ packageClass ) ) { throw new InvalidPackageTemplateException ( "{$packageClass} class does not exist." ) ; } return $ packageClass ; }
Gets the package class .
56,844
public function bind ( InputDefinition $ definition ) { $ this -> arguments = array ( ) ; $ this -> options = array ( ) ; $ this -> definition = $ definition ; $ packageClass = $ this -> getPackageClass ( ) ; $ options = $ packageClass :: getOptions ( ) ; $ arguments = $ packageClass :: getArguments ( ) ; foreach ( $ options as $ option ) { $ this -> definition -> addOption ( new InputOption ( array_get ( $ option , 0 , null ) , array_get ( $ option , 1 , null ) , array_get ( $ option , 2 , null ) , array_get ( $ option , 3 , null ) , array_get ( $ option , 4 , null ) ) ) ; } foreach ( $ arguments as $ argument ) { $ this -> definition -> addArgument ( new InputArgument ( array_get ( $ argument , 0 , null ) , array_get ( $ argument , 1 , null ) , array_get ( $ argument , 2 , null ) , array_get ( $ argument , 3 , null ) ) ) ; } $ this -> parse ( ) ; if ( ( count ( $ options ) + count ( $ arguments ) ) == 0 && count ( $ this -> arguments ) == 2 ) { $ this -> arguments = array_merge ( $ this -> arguments , [ 'newup-output-directory' => '.' ] ) ; } }
Binds the current Input instance with the given arguments and options .
56,845
private function getNamespacedPackageName ( ) { $ path = $ this -> getTemplateArgumentPath ( ) ; $ templateName = json_decode ( file_get_contents ( $ path . 'composer.json' ) ) -> name ; $ parts = explode ( '/' , $ templateName ) ; return package_vendor_namespace ( $ parts [ 0 ] , $ parts [ 1 ] ) . '\Package' ; }
Gets the namespaced package name .
56,846
private function getTemplateArgumentPath ( ) { if ( $ this -> customTemplatePath !== null ) { return str_finish ( $ this -> customTemplatePath , '/' ) ; } return str_finish ( find_tse_template ( $ this -> getTemplateName ( ) ) , '/' ) ; }
Determines the template path .
56,847
public function translate ( $ sentence ) { $ key = Inflector :: slug ( $ sentence ) ; $ translate = $ this -> db ( ) -> select ( "entity_name = 'translation_" . $ this -> language . "' AND table_name = '" . $ key . "'" , true ) ; if ( null !== $ translate ) { return unserialize ( $ translate -> getData ( ) ) ; } return null ; }
Retrieve an item from the translation driver .
56,848
static function removeIdentity ( \ Db \ Connection $ db , User $ user , $ openid ) { if ( ! $ user ) { throw new \ InvalidArgumentException ( "No user provided." ) ; } $ q = $ db -> prepare ( "DELETE FROM user_openid_identities WHERE user_id=? AND identity=? LIMIT 1" ) ; return $ q -> execute ( array ( $ user -> getId ( ) , $ openid ) ) ; }
Remove the given OpenID identity from the given user .
56,849
public function toString ( $ type = 'jpg' , $ quality = 75 ) { ob_start ( ) ; if ( $ type == 'jpg' && ( imagetypes ( ) & IMG_JPG ) ) imagejpeg ( $ this -> im , null , $ quality ) ; elseif ( $ type == 'png' && ( imagetypes ( ) & IMG_PNG ) ) imagepng ( $ this -> im ) ; elseif ( $ type == 'gif' && ( imagetypes ( ) & IMG_GIF ) ) imagegif ( $ this -> im ) ; return ob_get_clean ( ) ; }
Is there a way to do this without using output buffering?
56,850
public function scale ( $ new_width = null , $ new_height = null ) { if ( ! is_null ( $ new_width ) && is_null ( $ new_height ) ) $ new_height = $ new_width * $ this -> height / $ this -> width ; elseif ( is_null ( $ new_width ) && ! is_null ( $ new_height ) ) $ new_width = $ this -> width / $ this -> height * $ new_height ; elseif ( ! is_null ( $ new_width ) && ! is_null ( $ new_height ) ) { if ( $ this -> width < $ this -> height ) $ new_width = $ this -> width / $ this -> height * $ new_height ; else $ new_height = $ new_width * $ this -> height / $ this -> width ; } else return false ; return $ this -> resize ( $ new_width , $ new_height ) ; }
Resizes an image and maintains aspect ratio .
56,851
public function resize ( $ new_width , $ new_height ) { $ dest = imagecreatetruecolor ( $ new_width , $ new_height ) ; imagealphablending ( $ dest , false ) ; imagesavealpha ( $ dest , true ) ; if ( imagecopyresampled ( $ dest , $ this -> im , 0 , 0 , 0 , 0 , $ new_width , $ new_height , $ this -> width , $ this -> height ) ) { $ this -> im = $ dest ; $ this -> width = imagesx ( $ this -> im ) ; $ this -> height = imagesy ( $ this -> im ) ; return true ; } return false ; }
Resizes an image to an exact size
56,852
public static function isSupportedShell ( ) { if ( isset ( $ _ENV [ 'TERM' ] ) ) { if ( isset ( self :: $ _supportedShells [ $ _ENV [ 'TERM' ] ] ) ) { return true ; } } elseif ( isset ( $ _SERVER [ 'TERM' ] ) ) { if ( isset ( self :: $ _supportedShells [ $ _SERVER [ 'TERM' ] ] ) ) { return true ; } } elseif ( isset ( $ _SERVER [ 'ConEmuANSI' ] ) && $ _SERVER [ 'ConEmuANSI' ] == 'ON' ) { return true ; } return isAke ( $ _SERVER , 'CLI' , false ) ; }
Identify if console supports colors .
56,853
public static function warningLine ( $ msg ) { return self :: colorize ( $ msg , Console :: FG_RED , Console :: AT_BOLD ) . PHP_EOL . PHP_EOL ; }
Get warning line message .
56,854
public static function infoLine ( $ msg , $ lineBefore = true , $ afterLinesCount = 2 , $ color = Console :: FG_GREEN ) { $ out = '' ; if ( $ lineBefore ) { $ out .= PHP_EOL ; } $ out .= self :: colorize ( $ msg , $ color , Console :: AT_BOLD ) ; if ( $ afterLinesCount ) { for ( $ i = 0 ; $ i < $ afterLinesCount ; $ i ++ ) { $ out .= PHP_EOL ; } } return $ out ; }
Get info line message .
56,855
public static function commandLine ( $ cmd , $ comment = '' , $ commentColor = Console :: FG_BROWN , $ cmdColor = Console :: FG_GREEN ) { $ messageLength = strlen ( $ cmd ) + 3 ; $ startPosition = self :: COMMENT_START_POSITION ; return self :: colorize ( ' ' . $ cmd , $ cmdColor ) . self :: tab ( $ startPosition , $ messageLength ) . self :: colorize ( $ comment , $ commentColor ) . PHP_EOL ; }
Get command line message .
56,856
public function set ( $ name , $ value ) { $ this -> instance -> unlock ( ) ; $ result = $ this -> instance -> set ( $ name , $ value ) ; $ this -> instance -> lock ( ) ; return $ result ; }
Set a key value in the standard session
56,857
public function remove ( $ name ) { $ this -> instance -> unlock ( ) ; $ result = $ this -> instance -> remove ( $ name ) ; $ this -> instance -> lock ( ) ; return $ result ; }
Remove a single value from the session
56,858
public function removeAll ( ) { $ this -> instance -> unlock ( ) ; $ result = $ this -> instance -> removeAll ( ) ; $ this -> instance -> lock ( ) ; return $ result ; }
Clear all session values outside of the namespace .
56,859
public function toArrayParent ( $ chaine_parent = 'parent_id' , $ chaine_id = 'id' , array $ indices = array ( ) , $ unset_indice = false ) { $ array = $ this -> toArray ( ) ; $ num = 0 ; $ final = array ( ) ; do { $ is_present = false ; foreach ( $ array as $ key => $ row ) { if ( $ row [ $ chaine_parent ] == $ num ) { if ( count ( $ indices ) > 0 ) { $ buffer = & $ final ; foreach ( $ indices as $ indice ) { if ( isset ( $ row [ $ indice ] ) ) { $ buffer = & $ buffer [ $ row [ $ indice ] ] ; if ( $ unset_indice ) { unset ( $ row [ $ indice ] ) ; } } } $ buffer = $ row ; } else { $ final [ ] = $ row ; } $ num = $ row [ $ chaine_id ] ; unset ( $ array [ $ key ] ) ; $ is_present = true ; break ; } } } while ( $ is_present ) ; return $ final ; }
To Array by parent id .
56,860
protected function execute ( InputInterface $ input , OutputInterface $ output ) { if ( $ root = $ input -> getArgument ( 'root-dir' ) ) { chdir ( realpath ( $ root ) ) ; } $ rootDir = realpath ( getcwd ( ) ) ; $ logger = new ConsoleLogger ( $ output ) ; $ composerJson = $ rootDir . '/composer.json' ; if ( ! file_exists ( $ composerJson ) ) { $ logger -> error ( '<error>File not found, can not analyze: {file}</error> ' , array ( 'file' => $ composerJson ) ) ; return 1 ; } $ destinations = array ( ) ; $ destinations [ ] = new PsrLogDestination ( $ logger ) ; $ report = $ this -> prepareReport ( $ input , $ logger ) ; $ composer = json_decode ( file_get_contents ( $ composerJson ) , true ) ; $ ignore = $ this -> getIgnoredFiles ( $ composer , $ input -> getOption ( 'ignore-files' ) ) ; $ factory = new AutoloadValidatorFactory ( $ rootDir , new ClassMapGenerator ( $ ignore ) , $ report ) ; $ test = new AutoloadValidator ( $ factory -> createFromComposerJson ( $ composer ) , $ report ) ; $ test -> validate ( ) ; if ( $ report -> hasError ( ) ) { $ logger -> error ( '<error>Testing loaders found errors</error> ' ) ; } $ enumLoader = new EnumeratingClassLoader ( ) ; $ this -> prepareLoader ( $ enumLoader , $ test ) ; $ hacker = new HackPreparator ( $ enumLoader , $ logger ) ; if ( $ custom = $ input -> getOption ( 'add-autoloader' ) ) { $ hacker -> prepareHacks ( $ custom , array ( $ rootDir , dirname ( dirname ( __DIR__ ) ) . DIRECTORY_SEPARATOR . 'hacks' ) ) ; } $ this -> prepareComposerFallbackLoader ( $ enumLoader , $ rootDir , $ composer ) ; if ( ! ( $ input -> getOption ( 'disable-legacy-hacks' ) || $ input -> getOption ( 'add-autoloader' ) ) ) { $ hacker -> prepareLegacyHack ( ) ; } $ loadCycle = new AllLoadingAutoLoader ( $ enumLoader , $ test -> getClassMap ( ) , $ logger ) ; return static :: $ exitCodes [ $ loadCycle -> run ( ) && ! $ report -> hasError ( ) ] ; }
Execute the tests .
56,861
private function prepareReport ( InputInterface $ input , LoggerInterface $ logger ) { $ reportMap = array ( ) ; if ( $ input -> getOption ( 'strict' ) ) { $ reportMap = array ( DestinationInterface :: SEVERITY_ERROR => DestinationInterface :: SEVERITY_ERROR , DestinationInterface :: SEVERITY_WARNING => DestinationInterface :: SEVERITY_ERROR , DestinationInterface :: SEVERITY_INFO => DestinationInterface :: SEVERITY_ERROR , ) ; } $ destinations = array ( ) ; $ destinations [ ] = new PsrLogDestination ( $ logger ) ; $ report = new Report ( $ destinations , $ reportMap ) ; return $ report ; }
Prepare the report .
56,862
private function prepareLoader ( EnumeratingClassLoader $ enumLoader , AutoloadValidator $ autoloadValidator ) { $ loaders = $ autoloadValidator -> getLoaders ( ) ; foreach ( $ loaders as $ name => $ loader ) { $ enumLoader -> add ( $ loader , $ name ) ; } }
Create a class loader that contains the classes found by us and the classes from the real composer installation .
56,863
private function prepareComposerFallbackLoader ( EnumeratingClassLoader $ enumLoader , $ baseDir , $ composer ) { $ vendorDir = $ baseDir . DIRECTORY_SEPARATOR . 'vendor' ; if ( isset ( $ composer [ 'extra' ] [ 'vendor-dir' ] ) ) { $ vendorDir = $ baseDir . DIRECTORY_SEPARATOR . $ composer [ 'extra' ] [ 'vendor-dir' ] ; } if ( ! is_dir ( $ vendorDir ) ) { return ; } $ loader = new ClassLoader ( ) ; if ( $ map = $ this -> includeIfExists ( $ vendorDir . '/composer/autoload_namespaces.php' ) ) { foreach ( $ map as $ namespace => $ path ) { $ loader -> set ( $ namespace , $ path ) ; } } if ( $ map = $ this -> includeIfExists ( $ vendorDir . '/composer/autoload_psr4.php' ) ) { foreach ( $ map as $ namespace => $ path ) { $ loader -> setPsr4 ( $ namespace , $ path ) ; } } if ( $ classMap = $ this -> includeIfExists ( $ vendorDir . '/composer/autoload_classmap.php' ) ) { $ loader -> addClassMap ( $ classMap ) ; } $ enumLoader -> add ( array ( $ loader , 'loadClass' ) , 'composer.fallback' ) ; }
Prepare the composer fallback loader .
56,864
private function getIgnoredFiles ( $ composer , $ fileList ) { $ ignored = $ fileList ; foreach ( array ( 'autoload' , 'autoload-dev' ) as $ sectionName ) { if ( array_key_exists ( $ sectionName , $ composer ) ) { if ( array_key_exists ( 'exclude-from-classmap' , $ composer [ $ sectionName ] ) ) { $ ignored = array_merge ( $ ignored , $ composer [ $ sectionName ] [ 'exclude-from-classmap' ] ) ; } } } return $ ignored ; }
Retrieve the list of ignored files .
56,865
public function configure ( array $ configs , $ prefix , ConfigurationInterface $ configuration , ContainerBuilder $ container ) { $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( $ this -> getConfigurationDirectory ( ) ) ) ; $ this -> loadConfigurationFile ( $ this -> configFiles , $ loader ) ; if ( array_key_exists ( 'pools' , $ config ) ) { $ builder = new PoolBuilder ( $ container ) ; foreach ( $ config [ 'pools' ] as $ resourceName => $ params ) { $ builder -> configure ( $ prefix , $ resourceName , $ params ) -> build ( ) ; } } return $ config ; }
Configures the pool builder and returns the bundle processed configuration .
56,866
protected function loadConfigurationFile ( array $ config , XmlFileLoader $ loader ) { foreach ( $ config as $ filename ) { if ( file_exists ( $ file = sprintf ( '%s/%s.xml' , $ this -> getConfigurationDirectory ( ) , $ filename ) ) ) { $ loader -> load ( $ file ) ; } } }
Loads bundle configuration files .
56,867
public function handleOpen ( string $ fileName ) : void { if ( strpos ( $ fileName , '..' . DIRECTORY_SEPARATOR ) !== false ) { throw new InvalidArgumentException ; } $ file = $ this -> getFileInfo ( $ fileName ) ; if ( $ file -> isDir ) { $ path = $ this -> getPath ( ) ; $ path [ ] = $ fileName ; $ this -> setPath ( $ path ) ; } else { $ this -> viewFile ( $ file ) ; } $ this -> redrawControl ( 'fileManagerContainer' ) ; }
Otevreni souboru nebo adresare
56,868
public function handleFile ( string $ fileName ) : void { $ file = $ this -> getFileInfo ( $ fileName ) ; if ( strpos ( $ file -> type , 'image' ) !== false ) { $ response = new FileResponse ( $ this -> getFullPath ( $ file -> name ) , $ file -> name , $ file -> type , false ) ; $ this -> presenter -> sendResponse ( $ response ) ; } else { exit ; } }
Zobrazeni pouze souboru
56,869
private function getFiles ( ) : array { $ result = [ ] ; $ files = Finder :: find ( '*' ) -> in ( $ this -> getFullPath ( ) ) ; foreach ( $ files as $ file ) { $ result [ ] = new FileInfo ( $ file ) ; } usort ( $ result , function ( $ a , $ b ) { if ( $ a -> isDir == $ b -> isDir ) { return strcmp ( $ a -> name , $ b -> name ) ; } else { if ( $ a -> isDir ) { return - 1 ; } else { return 1 ; } } } ) ; return $ result ; }
Vrati polozky v adresari
56,870
private function getFileInfo ( string $ fileName , bool $ withSize = false ) : FileInfo { $ file = new SplFileInfo ( $ this -> getFullPath ( $ fileName ) ) ; return new FileInfo ( $ file , $ withSize ) ; }
Vrati informace o souboru nebo adresari
56,871
public function reverseTransform ( $ string ) { if ( $ string === null ) { return null ; } $ rClass = new \ ReflectionClass ( $ this -> specificationClass ) ; $ args = $ this -> constructorArgs ; array_unshift ( $ args , $ string ) ; return $ rClass -> newInstanceArgs ( $ args ) ; }
Transforms a string into a specification .
56,872
protected function doLoadMetadata ( $ metaType , $ key ) { if ( isset ( $ this -> arrayCache [ $ metaType ] [ $ key ] ) ) { return $ this -> arrayCache [ $ metaType ] [ $ key ] ; } $ path = $ this -> getFilePath ( $ metaType , $ key ) ; if ( null === $ path ) { return null ; } $ loadMethod = $ this -> getLoadMethod ( $ metaType ) ; $ metadata = $ this -> $ loadMethod ( $ key , $ path ) ; $ this -> arrayCache [ $ metaType ] [ $ key ] = $ metadata ; return $ this -> arrayCache [ $ metaType ] [ $ key ] ; }
Loads the metadata instance for a model or a mixin .
56,873
protected function getFilePath ( $ metaType , $ key ) { $ method = $ this -> getFindMethod ( $ metaType ) ; $ path = $ this -> fileLocator -> $ method ( $ key , $ this -> getExtension ( ) ) ; if ( null === $ path ) { throw MetadataException :: fatalDriverError ( $ key , sprintf ( 'No mapping file was found.' , $ path ) ) ; } return $ path ; }
Returns the file path for an entity type or mixin name .
56,874
public static function recursiveImplode ( $ glue , array $ array ) { $ return = '' ; $ index = 0 ; $ count = count ( $ array ) ; foreach ( $ array as $ piece ) { if ( is_array ( $ piece ) ) { $ return .= self :: recursiveImplode ( $ glue , $ piece ) ; } else { $ return .= $ piece ; } if ( $ index < $ count - 1 ) { $ return .= $ glue ; } ++ $ index ; } return $ return ; }
Return an imploded string from a multi dimensional array .
56,875
protected function getPreferredLanguage ( $ default = 'en-US' ) { $ acceptedLanguages = $ this -> getServerCollection ( ) -> get ( 'HTTP_ACCEPT_LANGUAGE' ) ; preg_match_all ( '/([a-z]{1,8}(-[a-z]{1,8})*)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i' , $ acceptedLanguages , $ lang_parse ) ; $ langs = $ lang_parse [ 1 ] ; $ ranks = $ lang_parse [ 4 ] ; $ lang2pref = array ( ) ; for ( $ i = 0 ; $ i < count ( $ langs ) ; $ i ++ ) { $ lang2pref [ $ langs [ $ i ] ] = ( float ) ( ! empty ( $ ranks [ $ i ] ) ? $ ranks [ $ i ] : 1 ) ; } $ cmpLangs = function ( $ a , $ b ) use ( $ lang2pref ) { if ( $ lang2pref [ $ a ] > $ lang2pref [ $ b ] ) return - 1 ; elseif ( $ lang2pref [ $ a ] < $ lang2pref [ $ b ] ) return 1 ; elseif ( strlen ( $ a ) > strlen ( $ b ) ) return - 1 ; elseif ( strlen ( $ a ) < strlen ( $ b ) ) return 1 ; else return 0 ; } ; uksort ( $ lang2pref , $ cmpLangs ) ; $ tokens = array_keys ( $ lang2pref ) ; $ current = array_shift ( $ tokens ) ; if ( strlen ( $ current ) !== strlen ( $ default ) ) { return ( $ default !== null ) ? $ default : $ current ; } return $ current ; }
If default is set to null will return the whatever value was found
56,876
public function client ( $ id ) { if ( isset ( $ this -> clients [ $ id ] ) ) { return $ this -> clients [ $ id ] ; } return new Client ( $ this , $ id ) ; }
Creates an instance of client .
56,877
public function refresh ( Client $ client ) { $ clientId = $ client -> getId ( ) ; $ this -> clients [ $ clientId ] = $ client ; $ this -> removeClientForRequest ( $ clientId , $ client -> getPreviousRequest ( ) ) ; $ requestId = $ client -> getRequest ( ) ; if ( $ requestId !== null ) { if ( ! isset ( $ this -> requests [ $ requestId ] ) ) { $ this -> requests [ $ requestId ] = array ( ) ; } $ this -> requests [ $ requestId ] [ $ clientId ] = $ client ; $ this -> clientRequest [ $ clientId ] = $ requestId ; } return $ this ; }
Removes and re - adds the client to the bucket . This way the requests array does not get outdated and the clients are sorted by time .
56,878
public function remove ( Client $ client ) { $ clientId = $ client -> getId ( ) ; if ( ! isset ( $ this -> clients [ $ clientId ] ) ) { return $ this ; } $ requestId = $ client -> getRequest ( ) ; $ this -> removeClientForRequest ( $ clientId , $ requestId ) ; unset ( $ this -> clients [ $ clientId ] ) ; return $ this ; }
Removes the client from the clients and the requests array .
56,879
public function get ( $ clientId ) { if ( ! isset ( $ this -> clients [ $ clientId ] ) ) { throw new \ RuntimeException ( 'Client with id ' . $ clientId . ' does not exist.' ) ; } return $ this -> clients [ $ clientId ] ; }
Gets a single client by id .
56,880
public function getExpired ( $ timeout ) { $ expired = array ( ) ; $ timeoutAt = microtime ( true ) - ( $ timeout / 1000 ) ; foreach ( $ this -> clients as $ client ) { if ( $ client -> getTime ( ) > $ timeoutAt ) { break ; } $ expired [ ] = $ client ; } return $ expired ; }
Gets all expired clients based on a timeout in microseconds .
56,881
public function add ( $ name , $ content = '' , $ http_equiv = false , $ condition = null ) { $ this -> __template -> registry -> addEntry ( array ( 'name' => $ name , 'content' => $ content , 'http-equiv' => $ http_equiv , 'condition' => $ condition ) , 'meta_tags' ) ; return $ this ; }
Add a meta tag in meta stack
56,882
public function set ( array $ tags ) { if ( ! empty ( $ tags ) ) { foreach ( $ tags as $ _tag ) { if ( is_array ( $ _tag ) && isset ( $ _tag [ 'name' ] ) && isset ( $ _tag [ 'content' ] ) ) { $ this -> add ( $ _tag [ 'name' ] , $ _tag [ 'content' ] , isset ( $ _tag [ 'http-equiv' ] ) && true === $ _tag [ 'http-equiv' ] ? true : false , isset ( $ _tag [ 'condition' ] ) ? $ _tag [ 'condition' ] : null ) ; } } } return $ this ; }
Set a full array of tags
56,883
public static function script_runner ( $ script , $ args = null ) { if ( ! $ args ) $ args = array ( ) ; array_unshift ( $ args , $ script ) ; return array ( 'Jar' => 's3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar' , 'Args' => $ args ) ; }
Runs a specified script on the master node of your cluster .
56,884
public static function hive_pig_script ( $ type , $ args = null ) { if ( ! $ args ) $ args = array ( ) ; $ args = is_array ( $ args ) ? $ args : array ( $ args ) ; $ args = array_merge ( array ( '--base-path' , 's3://us-east-1.elasticmapreduce/libs/' . $ type . '/' ) , $ args ) ; return self :: script_runner ( 's3://us-east-1.elasticmapreduce/libs/' . $ type . '/' . $ type . '-script' , $ args ) ; }
Prepares a Hive or Pig script before passing it to the script runner .
56,885
private function formatMessage ( $ level , $ message , $ context ) { $ level = strtoupper ( $ level ) ; if ( ! empty ( $ context ) ) { $ message .= PHP_EOL . $ this -> indent ( $ this -> contextToString ( $ context ) ) ; } return "[{$this->getTimestamp()}] [{$level}] {$message}" . PHP_EOL ; }
Formats the message for logging .
56,886
static public function getDefaultCacheHandler ( ) { if ( ! isset ( self :: $ defaultCacheHandler ) ) { global $ container ; if ( self :: BACKWORDS_COMPATIBLE && isset ( $ container ) && isset ( $ container [ 'memcache' ] ) ) { if ( class_exists ( "Memcache" ) && is_a ( $ container [ 'memcache' ] , "Memcache" ) ) { self :: $ defaultCacheHandler = new CacheHandler \ Memcache ( $ container [ 'memcache' ] ) ; } else if ( class_exists ( "Memcached" ) && is_a ( $ container [ 'memcache' ] , "Memcached" ) ) { self :: $ defaultCacheHandler = new CacheHandler \ Memcached ( $ container [ 'memcache' ] ) ; } else { trigger_error ( "Before using NoizuLabs/Fragmented you must set a cache handler using NoizuLabs\FragmentedKeys\Configuration::setDefaultCacheHandler(ICacheHandle \$handler) or use only KeyRing entries with a specified storage mechanism." , E_USER_ERROR ) ; } } else { trigger_error ( "Before using NoizuLabs/Fragmented you must set a cache handler using NoizuLabs\FragmentedKeys\Configuration::setDefaultCacheHandler(ICacheHandle \$handler) or use only KeyRing entries with a specified storage mechanism." , E_USER_ERROR ) ; } } return self :: $ defaultCacheHandler ; }
Specify the default mechanism to use for fetching and retrieving tag values .
56,887
static public function getGlobalPrefix ( ) { if ( ! isset ( self :: $ globalPrefix ) ) { global $ container ; if ( self :: BACKWORDS_COMPATIBLE ) { if ( isset ( $ container ) && isset ( $ container [ 'memcachePrefix' ] ) ) { self :: $ globalPrefix = $ container [ 'memcachePrefix' ] ; } else { self :: $ globalPrefix = "DefaultPrefix" ; } } else { trigger_error ( "Before using NoizuLabs/Fragmented you must set a global prefix using NoizuLabs\FragmentedKeys\Configuration::setGlobalPrefix(String \$prefix)" , E_USER_WARNING ) ; } } return self :: $ globalPrefix ; }
Get the global prefix added to all keys by FragementedKeySystem .
56,888
public static function negate ( $ a ) { self :: assertInteger ( $ a ) ; if ( $ a === self :: MIN_INT ) { return $ a ; } return - $ a ; }
Returns the negation of the argument .
56,889
public static function add ( $ a , $ b ) { self :: assertInteger ( $ a ) ; self :: assertInteger ( $ b ) ; if ( ( $ b > 0 ) && ( $ a <= ( PHP_INT_MAX - $ b ) ) ) { return $ a + $ b ; } if ( ( $ b < 0 ) && ( $ a >= ( PHP_INT_MIN - $ b ) ) ) { return $ a + $ b ; } while ( $ b !== 0 ) { $ carry = $ a & $ b ; $ a ^= $ b ; $ b = $ carry << 1 ; } return $ a ; }
Returns the sum of the arguments .
56,890
public static function subtract ( $ a , $ b ) { self :: assertInteger ( $ a ) ; self :: assertInteger ( $ b ) ; return self :: add ( ( int ) $ a , self :: negate ( $ b ) ) ; }
Returns the difference of the arguments .
56,891
public static function multiply ( $ a , $ b ) { self :: assertInteger ( $ a ) ; self :: assertInteger ( $ b ) ; if ( $ a === 0 || $ b === 0 ) { return 0 ; } if ( $ a === self :: MIN_INT ) { return $ b & 0x01 ? $ a : 0 ; } if ( $ b === self :: MIN_INT ) { return $ a & 0x01 ? $ b : 0 ; } $ max = self :: MIN_INT ; if ( $ a >= 0 && $ b >= 0 || $ a < 0 && $ b < 0 ) { $ max = self :: MAX_INT ; } if ( ( $ b > 0 && $ b <= ( $ max / $ a ) ) || ( $ b < 0 && $ b >= ( $ max / $ a ) ) ) { return $ a * $ b ; } $ sign = false ; if ( $ a < 0 ) { $ sign = ! $ sign ; $ a = self :: negate ( $ a ) ; } if ( $ b < 0 ) { $ sign = ! $ sign ; $ b = self :: negate ( $ b ) ; } $ product = 0 ; while ( $ a !== 0 ) { if ( ( $ a & 0x01 ) !== 0 ) { $ product = self :: add ( $ product , $ b ) ; } $ a >>= 1 ; $ b <<= 1 ; } if ( $ sign ) { $ product = self :: negate ( $ product ) ; } return $ product ; }
Returns the product of the arguments .
56,892
public static function divide ( $ a , $ b ) { self :: assertInteger ( $ a ) ; self :: assertInteger ( $ b ) ; if ( 0 === $ b ) { throw new DivisionByZeroException ( 'Division by zero.' ) ; } if ( $ a === self :: MIN_INT && $ b === - 1 ) { return $ a ; } return ( $ a - ( $ a % $ b ) ) / $ b ; }
Returns the quotient of the arguments .
56,893
private static function identify ( $ value ) { if ( ! is_numeric ( $ value ) || ! is_float ( $ value ) ) { return gettype ( $ value ) ; } if ( is_infinite ( $ value ) ) { return $ value < 0 ? '-INF' : 'INF' ; } if ( is_nan ( $ value ) ) { return 'NAN' ; } return 'float' ; }
Returns a string that identifies the specified value .
56,894
protected function skipIfEnvVarIsAlreadyInstalled ( $ env_var ) { if ( fp_env ( $ env_var , null ) != null ) { $ this -> info ( "The environment variable $env_var already exists in your environment (check .env file)." ) ; $ this -> info ( "Please remove the $env_var an re-execute command. Skipping..." ) ; die ( ) ; } }
Skip if token is already installed .
56,895
public function download ( $ fileClass , $ q ) { try { $ file = $ this -> handlers [ $ fileClass ] -> __invoke ( new FileOfIdQuery ( $ q ) ) ; $ filename = $ file [ 'file_name' ] ; } catch ( FileDoesNotExistException $ exception ) { $ filename = $ q ; } return $ this -> urlGenerator -> generate ( 'bengor_file_' . $ fileClass . '_download' , [ 'filename' => $ filename ] , UrlGeneratorInterface :: ABSOLUTE_URL ) ; }
Generates the url that returns the file of given file type and file .
56,896
public function preview ( $ file_name ) { if ( ! \ Entrust :: can ( 'preview-logs' ) ) { abort ( 403 , 'Unauthorized access - you do not have the necessary permission to preview logs.' ) ; } $ disk = Storage :: disk ( 'local' ) ; if ( $ disk -> exists ( 'logs/' . $ file_name ) ) { $ this -> data [ 'log' ] = [ 'file_path' => 'logs/' . $ file_name , 'file_name' => $ file_name , 'file_size' => $ disk -> size ( 'logs/' . $ file_name ) , 'last_modified' => $ disk -> lastModified ( 'logs/' . $ file_name ) , 'content' => $ disk -> get ( 'logs/' . $ file_name ) , ] ; return view ( "logmanager::log_item" , $ this -> data ) ; } else { abort ( 404 , "The log file doesn't exist." ) ; } }
Previews a log file .
56,897
public function download ( $ file_name ) { if ( ! \ Entrust :: can ( 'download-logs' ) ) { abort ( 403 , 'Unauthorized access - you do not have the necessary permission to download logs.' ) ; } $ disk = Storage :: disk ( 'local' ) ; if ( $ disk -> exists ( 'logs/' . $ file_name ) ) { return response ( ) -> download ( storage_path ( 'logs/' . $ file_name ) ) ; } else { abort ( 404 , "The log file doesn't exist." ) ; } }
Downloads a log file .
56,898
protected function makeOptionsDDL ( array $ options ) { $ escapedOptions = [ ] ; foreach ( $ options as $ option ) { $ escapedOptions [ ] = $ this -> quote ( ( string ) $ option ) ; } return implode ( ',' , $ escapedOptions ) ; }
Make just the portion of the DDL that describes the options
56,899
function activate ( ) { if ( ! defined ( 'WP_DEBUG' ) || ! WP_DEBUG ) return ; activate_plugin ( 'debug-bar/debug-bar.php' , null , is_multisite ( ) ) ; activate_plugin ( 'debug-bar-slow-actions/debug-bar-slow-actions.php' , null , is_multisite ( ) ) ; activate_plugin ( 'kint-debugger/Kint.class.php' , null , is_multisite ( ) ) ; activate_plugin ( 'debug-bar-timber/debug-bar-timber.php' , null , is_multisite ( ) ) ; }
Activate debug tools