idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
35,800
public function setValue ( $ value ) { if ( $ value instanceof DateInterval ) { $ value = Utils :: now ( ) -> add ( $ value ) ; } if ( $ value instanceof DateTimeInterface ) { $ value = $ value -> getTimestamp ( ) ; } return parent :: setValue ( $ value ) ; }
Set the claim value and call a validate method .
35,801
public function logout ( $ forceForever = false ) { $ this -> requireToken ( ) -> invalidate ( $ forceForever ) ; $ this -> user = null ; $ this -> jwt -> unsetToken ( ) ; }
Logout the user thus invalidating the token .
35,802
public function refresh ( $ forceForever = false , $ resetClaims = false ) { return $ this -> requireToken ( ) -> refresh ( $ forceForever , $ resetClaims ) ; }
Refresh the token .
35,803
protected function validateSubject ( ) { if ( ! method_exists ( $ this -> provider , 'getModel' ) ) { return true ; } return $ this -> jwt -> checkSubjectModel ( $ this -> provider -> getModel ( ) ) ; }
Ensure the JWTSubject matches what is in the token .
35,804
protected function extendAuthGuard ( ) { $ this -> app [ 'auth' ] -> extend ( 'jwt' , function ( $ app , $ name , array $ config ) { $ guard = new JWTGuard ( $ app [ 'tymon.jwt' ] , $ app [ 'auth' ] -> createUserProvider ( $ config [ 'provider' ] ) , $ app [ 'request' ] ) ; $ app -> refresh ( 'request' , $ guard , 'set...
Extend Laravel s Auth .
35,805
protected function registerJWT ( ) { $ this -> app -> singleton ( 'tymon.jwt' , function ( $ app ) { return ( new JWT ( $ app [ 'tymon.jwt.manager' ] , $ app [ 'tymon.jwt.parser' ] ) ) -> lockSubject ( $ this -> config ( 'lock_subject' ) ) ; } ) ; }
Register the bindings for the main JWT class .
35,806
protected function registerPayloadValidator ( ) { $ this -> app -> singleton ( 'tymon.jwt.validators.payload' , function ( ) { return ( new PayloadValidator ) -> setRefreshTTL ( $ this -> config ( 'refresh_ttl' ) ) -> setRequiredClaims ( $ this -> config ( 'required_claims' ) ) ; } ) ; }
Register the bindings for the payload validator .
35,807
protected function getConfigInstance ( $ key ) { $ instance = $ this -> config ( $ key ) ; if ( is_string ( $ instance ) ) { return $ this -> app -> make ( $ instance ) ; } return $ instance ; }
Get an instantiable configuration instance .
35,808
public function matches ( $ value , $ strict = true ) { return $ strict ? $ this -> value === $ value : $ this -> value == $ value ; }
Checks if the value matches the claim .
35,809
public function parse ( Request $ request ) { $ header = $ request -> headers -> get ( $ this -> header ) ? : $ this -> fromAltHeaders ( $ request ) ; if ( $ header && preg_match ( '/' . $ this -> prefix . '\s*(\S+)\b/i' , $ header , $ matches ) ) { return $ matches [ 1 ] ; } }
Try to parse the token from the request header .
35,810
protected function buildRefreshClaims ( Payload $ payload ) { extract ( $ payload -> toArray ( ) ) ; return array_merge ( $ this -> customClaims , compact ( $ this -> persistentClaims , 'sub' , 'iat' ) ) ; }
Build the claims to go into the refreshed token .
35,811
public function parseToken ( ) { foreach ( $ this -> chain as $ parser ) { if ( $ response = $ parser -> parse ( $ this -> request ) ) { return $ response ; } } }
Iterate through the parsers and attempt to retrieve a value otherwise return null .
35,812
public function getBuyableDescription ( $ options = null ) { if ( property_exists ( $ this , 'name' ) ) return $ this -> name ; if ( property_exists ( $ this , 'title' ) ) return $ this -> title ; if ( property_exists ( $ this , 'description' ) ) return $ this -> description ; return null ; }
Get the description or title of the Buyable item .
35,813
public function price ( $ decimals = null , $ decimalPoint = null , $ thousandSeperator = null ) { return $ this -> numberFormat ( $ this -> price , $ decimals , $ decimalPoint , $ thousandSeperator ) ; }
Returns the formatted price without TAX .
35,814
public function priceTax ( $ decimals = null , $ decimalPoint = null , $ thousandSeperator = null ) { return $ this -> numberFormat ( $ this -> priceTax , $ decimals , $ decimalPoint , $ thousandSeperator ) ; }
Returns the formatted price with TAX .
35,815
public function subtotal ( $ decimals = null , $ decimalPoint = null , $ thousandSeperator = null ) { return $ this -> numberFormat ( $ this -> subtotal , $ decimals , $ decimalPoint , $ thousandSeperator ) ; }
Returns the formatted subtotal . Subtotal is price for whole CartItem without TAX
35,816
public function total ( $ decimals = null , $ decimalPoint = null , $ thousandSeperator = null ) { return $ this -> numberFormat ( $ this -> total , $ decimals , $ decimalPoint , $ thousandSeperator ) ; }
Returns the formatted total . Total is price for whole CartItem with TAX
35,817
public function setQuantity ( $ qty ) { if ( empty ( $ qty ) || ! is_numeric ( $ qty ) ) throw new \ InvalidArgumentException ( 'Please supply a valid quantity.' ) ; $ this -> qty = $ qty ; }
Set the quantity for this cart item .
35,818
public function updateFromBuyable ( Buyable $ item ) { $ this -> id = $ item -> getBuyableIdentifier ( $ this -> options ) ; $ this -> name = $ item -> getBuyableDescription ( $ this -> options ) ; $ this -> price = $ item -> getBuyablePrice ( $ this -> options ) ; $ this -> priceTax = $ this -> price + $ this -> tax ;...
Update the cart item from a Buyable .
35,819
public function updateFromArray ( array $ attributes ) { $ this -> id = array_get ( $ attributes , 'id' , $ this -> id ) ; $ this -> qty = array_get ( $ attributes , 'qty' , $ this -> qty ) ; $ this -> name = array_get ( $ attributes , 'name' , $ this -> name ) ; $ this -> price = array_get ( $ attributes , 'price' , $...
Update the cart item from an array .
35,820
private function numberFormat ( $ value , $ decimals , $ decimalPoint , $ thousandSeperator ) { if ( is_null ( $ decimals ) ) { $ decimals = is_null ( config ( 'cart.format.decimals' ) ) ? 2 : config ( 'cart.format.decimals' ) ; } if ( is_null ( $ decimalPoint ) ) { $ decimalPoint = is_null ( config ( 'cart.format.deci...
Get the formatted number .
35,821
public function instance ( $ instance = null ) { $ instance = $ instance ? : self :: DEFAULT_INSTANCE ; $ this -> instance = sprintf ( '%s.%s' , 'cart' , $ instance ) ; return $ this ; }
Set the current cart instance .
35,822
public function remove ( $ rowId ) { $ cartItem = $ this -> get ( $ rowId ) ; $ content = $ this -> getContent ( ) ; $ content -> pull ( $ cartItem -> rowId ) ; $ this -> events -> fire ( 'cart.removed' , $ cartItem ) ; $ this -> session -> put ( $ this -> instance , $ content ) ; }
Remove the cart item with the given rowId from the cart .
35,823
public function content ( ) { if ( is_null ( $ this -> session -> get ( $ this -> instance ) ) ) { return new Collection ( [ ] ) ; } return $ this -> session -> get ( $ this -> instance ) ; }
Get the content of the cart .
35,824
public function associate ( $ rowId , $ model ) { if ( is_string ( $ model ) && ! class_exists ( $ model ) ) { throw new UnknownModelException ( "The supplied model {$model} does not exist." ) ; } $ cartItem = $ this -> get ( $ rowId ) ; $ cartItem -> associate ( $ model ) ; $ content = $ this -> getContent ( ) ; $ con...
Associate the cart item with the given rowId with the given model .
35,825
public function setTax ( $ rowId , $ taxRate ) { $ cartItem = $ this -> get ( $ rowId ) ; $ cartItem -> setTaxRate ( $ taxRate ) ; $ content = $ this -> getContent ( ) ; $ content -> put ( $ cartItem -> rowId , $ cartItem ) ; $ this -> session -> put ( $ this -> instance , $ content ) ; }
Set the tax rate for the cart item with the given rowId .
35,826
public function store ( $ identifier ) { $ content = $ this -> getContent ( ) ; if ( $ this -> storedCartWithIdentifierExists ( $ identifier ) ) { throw new CartAlreadyStoredException ( "A cart with identifier {$identifier} was already stored." ) ; } $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -...
Store an the current instance of the cart .
35,827
public function restore ( $ identifier ) { if ( ! $ this -> storedCartWithIdentifierExists ( $ identifier ) ) { return ; } $ stored = $ this -> getConnection ( ) -> table ( $ this -> getTableName ( ) ) -> where ( 'identifier' , $ identifier ) -> first ( ) ; $ storedContent = unserialize ( $ stored -> content ) ; $ curr...
Restore the cart with the given identifier .
35,828
protected function getContent ( ) { $ content = $ this -> session -> has ( $ this -> instance ) ? $ this -> session -> get ( $ this -> instance ) : new Collection ; return $ content ; }
Get the carts content if there is no cart content set yet return a new empty Collection
35,829
private function createCartItem ( $ id , $ name , $ qty , $ price , array $ options ) { if ( $ id instanceof Buyable ) { $ cartItem = CartItem :: fromBuyable ( $ id , $ qty ? : [ ] ) ; $ cartItem -> setQuantity ( $ name ? : 1 ) ; $ cartItem -> associate ( $ id ) ; } elseif ( is_array ( $ id ) ) { $ cartItem = CartItem ...
Create a new CartItem from the supplied attributes .
35,830
private function isMulti ( $ item ) { if ( ! is_array ( $ item ) ) return false ; return is_array ( head ( $ item ) ) || head ( $ item ) instanceof Buyable ; }
Check if the item is a multidimensional array or an array of Buyables .
35,831
public function prepareFieldsFromTable ( ) { foreach ( $ this -> columns as $ column ) { $ type = $ column -> getType ( ) -> getName ( ) ; switch ( $ type ) { case 'integer' : $ field = $ this -> generateIntFieldInput ( $ column , 'integer' ) ; break ; case 'smallint' : $ field = $ this -> generateIntFieldInput ( $ col...
Prepares array of GeneratorField from table columns .
35,832
public static function getPrimaryKeyOfTable ( $ tableName ) { $ schema = DB :: getDoctrineSchemaManager ( ) ; $ column = $ schema -> listTableDetails ( $ tableName ) -> getPrimaryKey ( ) ; return $ column ? $ column -> getColumns ( ) [ 0 ] : '' ; }
Get primary key of given table .
35,833
public static function getTimestampFieldNames ( ) { if ( ! config ( 'infyom.laravel_generator.timestamps.enabled' , true ) ) { return [ ] ; } $ createdAtName = config ( 'infyom.laravel_generator.timestamps.created_at' , 'created_at' ) ; $ updatedAtName = config ( 'infyom.laravel_generator.timestamps.updated_at' , 'upda...
Get timestamp columns from config .
35,834
private function generateIntFieldInput ( $ column , $ dbType ) { $ field = new GeneratorField ( ) ; $ field -> name = $ column -> getName ( ) ; $ field -> parseDBType ( $ dbType ) ; $ field -> htmlType = 'number' ; if ( $ column -> getAutoincrement ( ) ) { $ field -> dbInput .= ',true' ; } else { $ field -> dbInput .= ...
Generates integer text field for database .
35,835
private function checkForPrimary ( GeneratorField $ field ) { if ( $ field -> name == $ this -> primaryKey ) { $ field -> isPrimary = true ; $ field -> isFillable = false ; $ field -> isSearchable = false ; $ field -> inIndex = false ; $ field -> inForm = false ; } return $ field ; }
Check if key is primary key and sets field options .
35,836
private function generateField ( $ column , $ dbType , $ htmlType ) { $ field = new GeneratorField ( ) ; $ field -> name = $ column -> getName ( ) ; $ field -> parseDBType ( $ dbType ) ; $ field -> parseHtmlInput ( $ htmlType ) ; return $ this -> checkForPrimary ( $ field ) ; }
Generates field .
35,837
private function generateNumberInput ( $ column , $ dbType ) { $ field = new GeneratorField ( ) ; $ field -> name = $ column -> getName ( ) ; $ field -> parseDBType ( $ dbType . ',' . $ column -> getPrecision ( ) . ',' . $ column -> getScale ( ) ) ; $ field -> htmlType = 'number' ; return $ this -> checkForPrimary ( $ ...
Generates number field .
35,838
public function prepareForeignKeys ( ) { $ tables = $ this -> schemaManager -> listTables ( ) ; $ fields = [ ] ; foreach ( $ tables as $ table ) { $ primaryKey = $ table -> getPrimaryKey ( ) ; if ( $ primaryKey ) { $ primaryKey = $ primaryKey -> getColumns ( ) [ 0 ] ; } $ formattedForeignKeys = [ ] ; $ tableForeignKeys...
Prepares foreign keys from table with required details .
35,839
private function checkForRelations ( $ tables ) { $ modelTableName = $ this -> tableName ; $ modelTable = $ tables [ $ modelTableName ] ; unset ( $ tables [ $ modelTableName ] ) ; $ this -> relations = [ ] ; $ manyToOneRelations = $ this -> detectManyToOne ( $ tables , $ modelTable ) ; if ( count ( $ manyToOneRelations...
Prepares relations array from table foreign keys .
35,840
private function isManyToMany ( $ tables , $ tableName , $ modelTable , $ modelTableName ) { $ table = $ tables [ $ tableName ] ; $ isAnyKeyOnModelTable = false ; $ manyToManyTable = '' ; $ foreignKeys = $ table -> foreignKeys ; $ primary = $ table -> primaryKey ; foreach ( $ foreignKeys as $ foreignKey ) { if ( $ fore...
Detects many to many relationship If table has only two foreign keys Both foreign keys are primary key in foreign table Also one is from model table and one is from diff table .
35,841
private function isOneToOne ( $ primaryKey , $ foreignKey , $ modelTablePrimary ) { if ( $ foreignKey -> foreignField == $ modelTablePrimary ) { if ( $ foreignKey -> localField == $ primaryKey ) { return true ; } } return false ; }
Detects if one to one relationship is there If foreign key of table is primary key of foreign table Also foreign key field is primary key of this table .
35,842
private function isOneToMany ( $ primaryKey , $ foreignKey , $ modelTablePrimary ) { if ( $ foreignKey -> foreignField == $ modelTablePrimary ) { if ( $ foreignKey -> localField != $ primaryKey ) { return true ; } } return false ; }
Detects if one to many relationship is there If foreign key of table is primary key of foreign table Also foreign key field is not primary key of this table .
35,843
public function apply ( $ model , \ Prettus \ Repository \ Contracts \ RepositoryInterface $ repository ) { $ limit = $ this -> request -> get ( 'limit' , null ) ; $ offset = $ this -> request -> get ( 'offset' , null ) ; if ( $ limit ) { $ model = $ model -> limit ( $ limit ) ; } if ( $ offset && $ limit ) { $ model =...
Apply criteria in query repository .
35,844
public function generate ( $ format = 'php' ) { $ method = 'generate' . ucfirst ( $ format ) . 'Helper' ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( ) ; } return $ this -> generatePhpHelper ( ) ; }
Generate the helper file contents ;
35,845
protected function getValidAliases ( ) { $ aliases = new Collection ( ) ; foreach ( $ this -> getAliases ( ) as $ name => $ facade ) { if ( $ facade == 'Illuminate\Support\Facades\Redis' && $ name == 'Redis' && ! class_exists ( 'Predis\Client' ) ) { continue ; } $ magicMethods = array_key_exists ( $ name , $ this -> ma...
Find all aliases that are valid for us to render
35,846
public function addClass ( $ classes ) { $ classes = ( array ) $ classes ; foreach ( $ classes as $ class ) { if ( class_exists ( $ class ) || interface_exists ( $ class ) ) { $ this -> classes [ ] = $ class ; } else { echo "Class not exists: $class\r\n" ; } } }
Add one or more classes to analyze
35,847
public function getMethods ( ) { if ( count ( $ this -> methods ) > 0 ) { return $ this -> methods ; } $ this -> addMagicMethods ( ) ; $ this -> detectMethods ( ) ; return $ this -> methods ; }
Get the methods found by this Alias
35,848
protected function detectNamespace ( ) { if ( strpos ( $ this -> alias , '\\' ) ) { $ nsParts = explode ( '\\' , $ this -> alias ) ; $ this -> short = array_pop ( $ nsParts ) ; $ this -> namespace = implode ( '\\' , $ nsParts ) ; } else { $ this -> short = $ this -> alias ; } }
Detect the namespace
35,849
protected function detectExtendsNamespace ( ) { if ( strpos ( $ this -> extends , '\\' ) !== false ) { $ nsParts = explode ( '\\' , $ this -> extends ) ; $ this -> extendsClass = array_pop ( $ nsParts ) ; $ this -> extendsNamespace = implode ( '\\' , $ nsParts ) ; } }
Detect the extends namespace
35,850
protected function detectClassType ( ) { if ( interface_exists ( $ this -> facade ) ) { $ this -> classType = 'interface' ; $ this -> extends = $ this -> facade ; } else { $ this -> classType = 'class' ; if ( class_exists ( $ this -> facade ) ) { $ this -> extends = $ this -> facade ; } } }
Detect the class type
35,851
protected function detectRoot ( ) { $ facade = $ this -> facade ; try { if ( method_exists ( $ facade , 'getFacadeRoot' ) ) { $ root = get_class ( $ facade :: getFacadeRoot ( ) ) ; } else { $ root = $ facade ; } if ( ! class_exists ( $ root ) && ! interface_exists ( $ root ) ) { return ; } $ this -> root = $ root ; } c...
Get the real root of a facade
35,852
protected function addMagicMethods ( ) { foreach ( $ this -> magicMethods as $ magic => $ real ) { list ( $ className , $ name ) = explode ( '::' , $ real ) ; if ( ! class_exists ( $ className ) && ! interface_exists ( $ className ) ) { continue ; } $ method = new \ ReflectionMethod ( $ className , $ name ) ; $ class =...
Add magic methods as defined in the configuration files
35,853
protected function detectMethods ( ) { foreach ( $ this -> classes as $ class ) { $ reflection = new \ ReflectionClass ( $ class ) ; $ methods = $ reflection -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; if ( $ methods ) { foreach ( $ methods as $ method ) { if ( ! in_array ( $ method -> name , $ this -> usedMeth...
Get the methods for one or multiple classes .
35,854
protected function removeDuplicateMethodsFromPhpDoc ( ) { $ methodNames = array_map ( function ( Method $ method ) { return $ method -> getName ( ) ; } , $ this -> getMethods ( ) ) ; foreach ( $ this -> phpdoc -> getTags ( ) as $ tag ) { if ( $ tag instanceof MethodTag && in_array ( $ tag -> getMethodName ( ) , $ metho...
Removes method tags from the doc comment that already appear as functions inside the class . This prevents duplicate function errors in the IDE .
35,855
protected function normalizeDescription ( DocBlock $ phpdoc ) { $ description = $ phpdoc -> getText ( ) ; if ( strpos ( $ description , '{@inheritdoc}' ) !== false ) { $ inheritdoc = $ this -> getInheritDoc ( $ this -> method ) ; $ inheritDescription = $ inheritdoc -> getText ( ) ; $ description = str_replace ( '{@inhe...
Get the description and get the inherited docs .
35,856
protected function normalizeParams ( DocBlock $ phpdoc ) { $ paramTags = $ phpdoc -> getTagsByName ( 'param' ) ; if ( $ paramTags ) { foreach ( $ paramTags as $ tag ) { $ content = $ this -> convertKeywords ( $ tag -> getContent ( ) ) ; $ tag -> setContent ( $ content ) ; $ content = $ tag -> getType ( ) . ' ' . $ tag ...
Normalize the parameters
35,857
protected function convertKeywords ( $ string ) { $ string = str_replace ( '\Closure' , 'Closure' , $ string ) ; $ string = str_replace ( 'Closure' , '\Closure' , $ string ) ; $ string = str_replace ( 'dynamic' , 'mixed' , $ string ) ; return $ string ; }
Convert keywwords that are incorrect .
35,858
public function getParameters ( $ method ) { $ params = array ( ) ; $ paramsWithDefault = array ( ) ; foreach ( $ method -> getParameters ( ) as $ param ) { $ paramStr = '$' . $ param -> getName ( ) ; $ params [ ] = $ paramStr ; if ( $ param -> isOptional ( ) ) { $ default = $ param -> isDefaultValueAvailable ( ) ? $ p...
Get the parameters and format them correctly
35,859
protected function getAbstracts ( ) { $ abstracts = $ this -> laravel -> getBindings ( ) ; $ keys = array_keys ( $ abstracts ) ; sort ( $ keys ) ; return $ keys ; }
Get a list of abstracts from the Laravel Application .
35,860
protected function getTypeOverride ( $ type ) { $ typeOverrides = $ this -> laravel [ 'config' ] -> get ( 'ide-helper.type_overrides' , array ( ) ) ; return isset ( $ typeOverrides [ $ type ] ) ? $ typeOverrides [ $ type ] : $ type ; }
Returns the overide type for the give type .
35,861
protected function getPropertiesFromTable ( $ model ) { $ table = $ model -> getConnection ( ) -> getTablePrefix ( ) . $ model -> getTable ( ) ; $ schema = $ model -> getConnection ( ) -> getDoctrineSchemaManager ( $ table ) ; $ databasePlatform = $ schema -> getDatabasePlatform ( ) ; $ databasePlatform -> registerDoct...
Load the properties from the database table .
35,862
private function isRelationForeignKeyNullable ( Relation $ relation ) { $ reflectionObj = new \ ReflectionObject ( $ relation ) ; if ( ! $ reflectionObj -> hasProperty ( 'foreignKey' ) ) { return false ; } $ fkProp = $ reflectionObj -> getProperty ( 'foreignKey' ) ; $ fkProp -> setAccessible ( true ) ; return isset ( $...
Check if the foreign key of the relation is nullable
35,863
protected function getReturnTypeFromDocBlock ( \ ReflectionMethod $ reflection ) { $ type = null ; $ phpdoc = new DocBlock ( $ reflection ) ; if ( $ phpdoc -> hasTag ( 'return' ) ) { $ type = $ phpdoc -> getTagsByName ( 'return' ) [ 0 ] -> getType ( ) ; } return $ type ; }
Get method return type based on it DocBlock comment
35,864
protected function getSoftDeleteMethods ( $ model ) { $ traits = class_uses ( get_class ( $ model ) , true ) ; if ( in_array ( 'Illuminate\\Database\\Eloquent\\SoftDeletes' , $ traits ) ) { $ this -> setMethod ( 'forceDelete' , 'bool|null' , [ ] ) ; $ this -> setMethod ( 'restore' , 'bool|null' , [ ] ) ; $ this -> setM...
Generates methods provided by the SoftDeletes trait
35,865
protected function addNumber ( \ Aimeos \ MW \ View \ Iface $ view , \ Aimeos \ MW \ Config \ Iface $ config , $ locale ) { $ pattern = $ config -> get ( 'client/html/common/format/pattern' ) ; $ helper = new \ Aimeos \ MW \ View \ Helper \ Number \ Locale ( $ view , $ locale , $ pattern ) ; $ view -> addHelper ( 'numb...
Adds the number helper to the view object
35,866
public function exportAction ( ) { if ( config ( 'shop.authorize' , true ) ) { $ this -> authorize ( 'admin' , [ JqadmController :: class , [ 'admin' , 'editor' ] ] ) ; } $ cntl = $ this -> createAdmin ( ) ; if ( ( $ html = $ cntl -> export ( ) ) == '' ) { return $ cntl -> getView ( ) -> response ( ) ; } return $ this ...
Exports the data for a resource object
35,867
protected function getHtml ( $ content ) { $ site = Route :: input ( 'site' , Input :: get ( 'site' , 'default' ) ) ; return View :: make ( 'shop::jqadm.index' , array ( 'content' => $ content , 'site' => $ site ) ) ; }
Returns the generated HTML code
35,868
public function get ( $ name ) { if ( ! isset ( $ this -> objects [ $ name ] ) ) { $ client = \ Aimeos \ Client \ Html :: create ( $ this -> context , $ name ) ; $ client -> setView ( clone $ this -> view ) ; $ client -> process ( ) ; $ this -> objects [ $ name ] = $ client ; } return $ this -> objects [ $ name ] ; }
Returns the HTML client for the given name
35,869
protected function addListItem ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context , $ userid , $ groupid ) { $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer/lists' ) ; $ search = $ manager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'customer.lists.parentid' , $ userid ) , $ se...
Associates the user to the group by their given IDs
35,870
protected function createCustomerItem ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context , $ email , $ password ) { $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer' ) ; try { $ item = $ manager -> findItem ( $ email ) ; } catch ( \ Aimeos \ MShop \ Exception $ e ) { $ item = $ manager -> createItem ( ...
Returns the customer item for the given e - mail and set its password
35,871
protected function getGroupItem ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context , $ code ) { $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer/group' ) ; try { $ item = $ manager -> findItem ( $ code ) ; } catch ( \ Aimeos \ MShop \ Exception $ e ) { $ item = $ manager -> createItem ( ) ; $ item -> s...
Returns the customer group item for the given code
35,872
protected function getDbConfig ( \ Aimeos \ MW \ Config \ Iface $ conf ) { $ dbconfig = $ conf -> get ( 'resource' , array ( ) ) ; foreach ( $ dbconfig as $ rname => $ dbconf ) { if ( strncmp ( $ rname , 'db' , 2 ) !== 0 ) { unset ( $ dbconfig [ $ rname ] ) ; } } return $ dbconfig ; }
Returns the database configuration from the config object .
35,873
protected function addGroups ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context ) { if ( ( $ userid = Auth :: id ( ) ) !== null ) { $ context -> setGroupIds ( function ( ) use ( $ context , $ userid ) { $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer' ) ; return $ manager -> getItem ( $ userid , array...
Adds the group IDs if available
35,874
public function checkUserGroup ( \ Illuminate \ Foundation \ Auth \ User $ user , $ groupcodes ) { $ groups = ( is_array ( $ groupcodes ) ? implode ( ',' , $ groupcodes ) : $ groupcodes ) ; if ( isset ( $ this -> cache [ $ user -> id ] [ $ groups ] ) ) { return $ this -> cache [ $ user -> id ] [ $ groups ] ; } $ this -...
Checks if the user is in the specified group and associatied to the site
35,875
public function checkGroup ( $ userid , $ groupcodes ) { $ groups = ( is_array ( $ groupcodes ) ? implode ( ',' , $ groupcodes ) : $ groupcodes ) ; if ( isset ( $ this -> cache [ $ userid ] [ $ groups ] ) ) { return $ this -> cache [ $ userid ] [ $ groups ] ; } $ site = ( Route :: current ( ) ? Route :: input ( 'site' ...
Checks if the user with the given ID is in the specified group
35,876
public function getGroups ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context ) { $ list = array ( ) ; $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer/group' ) ; $ search = $ manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.group.id' , $ context -> getGro...
Returns the available group codes
35,877
protected function checkGroups ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context , $ userid , $ groupcodes ) { $ manager = \ Aimeos \ MShop :: create ( $ context , 'customer/group' ) ; $ search = $ manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.group.code' , ( array...
Checks if one of the groups is associated to the given user ID
35,878
public function init ( ) { $ this -> addConsoleCommands ( ) ; $ this -> getConsole ( ) -> add ( new WorkerCommand ( $ this ) ) ; $ this -> getConsole ( ) -> add ( $ this [ 'init_command' ] ) ; $ this -> getConsole ( ) -> add ( new SshCommand ( $ this ) ) ; $ this -> getConsole ( ) -> add ( new RunCommand ( $ this ) ) ;...
Init console application
35,879
public function addConsoleCommands ( ) { $ this -> getConsole ( ) -> addUserArgumentsAndOptions ( ) ; foreach ( $ this -> tasks as $ name => $ task ) { if ( $ task -> isPrivate ( ) ) { continue ; } $ this -> getConsole ( ) -> add ( new TaskCommand ( $ name , $ task -> getDescription ( ) , $ this ) ) ; } }
Transform tasks to console commands .
35,880
public function collectAnonymousStats ( CommandEvent $ commandEvent ) { if ( $ this -> config -> has ( 'allow_anonymous_stats' ) && $ this -> config [ 'allow_anonymous_stats' ] === false ) { return ; } $ stats = [ 'status' => 'success' , 'command_name' => $ commandEvent -> getCommand ( ) -> getName ( ) , 'project_hash'...
Collect anonymous stats about Deployer usage for improving developer experience . If you are not comfortable with this you will always be able to disable this by setting allow_anonymous_stats to false in your deploy . php file .
35,881
public function set ( string $ name , $ value ) { $ this -> config -> set ( $ name , $ value ) ; return $ this ; }
Set configuration option
35,882
public function add ( string $ name , array $ value ) { $ this -> config -> add ( $ name , $ value ) ; return $ this ; }
Add configuration option
35,883
private function createInitializer ( ) { $ initializer = new Initializer ( ) ; $ initializer -> addTemplate ( 'Common' , new CommonTemplate ( ) ) ; $ initializer -> addTemplate ( 'Laravel' , new LaravelTemplate ( ) ) ; $ initializer -> addTemplate ( 'Symfony' , new SymfonyTemplate ( ) ) ; $ initializer -> addTemplate (...
Create a initializer system
35,884
public static function parseHomeDir ( string $ path ) : string { if ( isset ( $ _SERVER [ 'HOME' ] ) ) { $ path = str_replace ( '~' , $ _SERVER [ 'HOME' ] , $ path ) ; } elseif ( isset ( $ _SERVER [ 'HOMEDRIVE' ] , $ _SERVER [ 'HOMEPATH' ] ) ) { $ path = str_replace ( '~' , $ _SERVER [ 'HOMEDRIVE' ] . $ _SERVER [ 'HOME...
Parse ~ symbol from path .
35,885
public function initialize ( $ template , $ directory , $ file = 'deploy.php' , $ params = [ ] ) { if ( ! isset ( $ this -> templates [ $ template ] ) ) { throw TemplateNotFoundException :: create ( $ template , array_keys ( $ this -> templates ) ) ; } $ this -> checkDirectoryBeforeInitialize ( $ directory ) ; $ this -...
Initialize deployer in project
35,886
private function checkDirectoryBeforeInitialize ( $ directory ) { if ( ! file_exists ( $ directory ) ) { set_error_handler ( function ( $ errCode , $ errStr ) use ( $ directory ) { $ parts = explode ( ':' , $ errStr , 2 ) ; $ errorMessage = isset ( $ parts [ 1 ] ) ? trim ( $ parts [ 1 ] ) : 'Undefined' ; throw new IOEx...
Check the directory before initialize
35,887
private function checkFileBeforeInitialize ( $ directory , $ file ) { $ filePath = $ directory . '/' . $ file ; if ( file_exists ( $ filePath ) ) { throw new IOException ( sprintf ( 'The file "%s" already exist.' , $ filePath ) ) ; } touch ( $ filePath ) ; }
Check the file before initialize
35,888
private function generateControlPath ( Host $ host ) { $ port = empty ( $ host -> getPort ( ) ) ? '' : ':' . $ host -> getPort ( ) ; $ connectionData = "$host$port" ; $ tryLongestPossible = 0 ; $ controlPath = '' ; do { switch ( $ tryLongestPossible ) { case 1 : $ controlPath = "~/.ssh/deployer_%C" ; break ; case 2 : $...
Return SSH multiplexing control path
35,889
public function getTasks ( $ name , array $ hosts = [ ] , $ hooksEnabled = true ) { $ collect = function ( $ name ) use ( & $ collect , $ hosts , $ hooksEnabled ) { $ task = $ this -> tasks -> get ( $ name ) ; if ( ! $ task -> shouldBePerformed ( ... array_values ( $ hosts ) ) ) { return [ ] ; } $ relatedTasks = [ ] ; ...
Return tasks to run
35,890
public function call ( $ hostname , $ source , $ destination , array $ config = [ ] ) { $ defaults = [ 'timeout' => null , 'options' => [ ] , ] ; $ config = array_merge ( $ defaults , $ config ) ; $ escapedSource = escapeshellarg ( $ source ) ; $ escapedDestination = escapeshellarg ( $ destination ) ; $ rsync = "rsync ...
Start rsync process
35,891
private function createTreeFromTaskName ( $ taskName , $ postfix = '' , $ isLast = false ) { $ task = $ this -> tasks -> get ( $ taskName ) ; if ( $ task -> getBefore ( ) ) { $ beforePostfix = sprintf ( ' [before:%s]' , $ task -> getName ( ) ) ; foreach ( $ task -> getBefore ( ) as $ beforeTask ) { $ this -> createTree...
Create a tree from the given taskname
35,892
private function runTask ( array $ hosts , Task $ task ) : int { $ processes = [ ] ; foreach ( $ hosts as $ host ) { if ( $ task -> shouldBePerformed ( $ host ) ) { $ processes [ $ host -> getHostname ( ) ] = $ this -> getProcess ( $ host , $ task ) ; if ( $ task -> isOnce ( ) ) { $ task -> setHasRun ( ) ; } } } $ call...
Run task on hosts .
35,893
protected function getProcess ( Host $ host , Task $ task ) : Process { $ dep = PHP_BINARY . ' ' . DEPLOYER_BIN ; $ options = $ this -> generateOptions ( ) ; $ arguments = $ this -> generateArguments ( ) ; $ hostname = $ host -> getHostname ( ) ; $ taskName = $ task -> getName ( ) ; $ configFile = $ host -> get ( 'host...
Get process for task on host .
35,894
protected function areRunning ( array $ processes ) : bool { foreach ( $ processes as $ process ) { if ( $ process -> isRunning ( ) ) { return true ; } } return false ; }
Determine if any of the processes are running .
35,895
private function generateOptions ( ) : string { $ inputs = [ ( string ) ( new VerbosityString ( $ this -> output ) ) , ] ; $ userDefinition = $ this -> console -> getUserDefinition ( ) ; foreach ( $ userDefinition -> getArguments ( ) as $ argument ) { $ inputs [ ] = Argument :: toString ( $ this -> input , $ argument )...
Generate options and arguments string .
35,896
public static function create ( $ template , array $ availableTemplates , $ code = 0 , \ Exception $ prev = null ) { return new static ( sprintf ( 'Not found template with name "%s". Available templates: "%s"' , $ template , implode ( '", "' , $ availableTemplates ) ) , $ code , $ prev ) ; }
Create a new exception via template name
35,897
public function addUserArgumentsAndOptions ( ) { $ this -> getDefinition ( ) -> addArguments ( $ this -> getUserDefinition ( ) -> getArguments ( ) ) ; $ this -> getDefinition ( ) -> addOptions ( $ this -> getUserDefinition ( ) -> getOptions ( ) ) ; }
Add user definition arguments and options to definition .
35,898
public function shouldBePerformed ( ... $ hosts ) { if ( $ this -> once && $ this -> hasRun ) { return false ; } foreach ( $ hosts as $ host ) { $ onHost = empty ( $ this -> on [ 'hosts' ] ) || in_array ( $ host -> getHostname ( ) , $ this -> on [ 'hosts' ] , true ) ; $ onRole = empty ( $ this -> on [ 'roles' ] ) ; for...
Checks what task should be performed on one of hosts .
35,899
protected function tenantDatabaseExists ( Website $ website ) : bool { try { $ this -> connection -> set ( $ website ) ; $ schema = $ this -> connection -> get ( ) -> getSchemaBuilder ( ) ; if ( $ schema -> hasTable ( $ this -> table ) ) { return true ; } } catch ( \ Exception $ e ) { } return false ; }
Checks if tenant database exists .