idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
15,900
public function getEditionLogOfPageEditionById ( $ pageId ) { $ data = array ( ) ; $ pageEdition = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ dataLogs = $ pageEdition -> getEditionLogsOfPage ( $ pageId ) ; $ data = $ dataLogs ; return $ data ; }
Returns edition log of page edition
15,901
public function saveEditionAction ( ) { $ idPage = $ this -> params ( ) -> fromRoute ( 'idPage' , $ this -> params ( ) -> fromQuery ( 'idPage' , '' ) ) ; $ translator = $ this -> serviceLocator -> get ( 'translator' ) ; $ eventDatas = array ( 'idPage' => $ idPage ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscms...
Save Page edition
15,902
public function getTinyTemplatesAction ( ) { $ idPage = $ this -> params ( ) -> fromRoute ( 'idPage' , $ this -> params ( ) -> fromQuery ( 'idPage' , '' ) ) ; $ success = 1 ; $ tinyTemplates = array ( ) ; if ( ! empty ( $ idPage ) ) { $ melisPage = $ this -> getServiceLocator ( ) -> get ( 'MelisEnginePage' ) ; $ datasP...
This method sends back the list of mini - templates for TinyMCE It takes the page id as a parameter determines the website folder in order to list only the mini - templates of the website and not all of them
15,903
public static function create ( Node $ object , $ method_name ) { $ node = new static ( ) ; $ node -> addChild ( $ object , 'object' ) ; $ node -> addChild ( Token :: objectOperator ( ) , 'operator' ) ; $ node -> addChild ( Token :: identifier ( $ method_name ) , 'methodName' ) ; $ node -> addChild ( Token :: openParen...
Creates a method call on an object with an empty argument list .
15,904
protected function parseFilters ( SimpleXMLElement $ xml ) { if ( false === $ filters = $ xml -> xpath ( '//config:filters/config:filter' ) ) { return ; } try { $ filterConfig = $ this -> container -> getParameter ( "Thelia.parser.filters" ) ; } catch ( ParameterNotFoundException $ e ) { $ filterConfig = array ( ) ; } ...
parse Filters property
15,905
protected function parseTemplateDirectives ( SimpleXMLElement $ xml ) { if ( false === $ baseParams = $ xml -> xpath ( '//config:templateDirectives/config:templateDirective' ) ) { return ; } try { $ baseParamConfig = $ this -> container -> getParameter ( "Thelia.parser.templateDirectives" ) ; } catch ( ParameterNotFoun...
parse BaseParams property
15,906
protected function parseService ( $ id , $ service , $ file ) { if ( ( string ) $ service [ 'alias' ] ) { $ public = true ; if ( isset ( $ service [ 'public' ] ) ) { $ public = $ this -> getAttributeAsPhp ( $ service , 'public' ) ; } $ this -> container -> setAlias ( $ id , new Alias ( ( string ) $ service [ 'alias' ] ...
Parses an individual Definition
15,907
private function getArgumentsAsPhp ( SimpleXMLElement $ xml , $ name , $ lowercase = true ) { $ arguments = array ( ) ; foreach ( $ xml -> $ name as $ arg ) { if ( isset ( $ arg [ 'name' ] ) ) { $ arg [ 'key' ] = ( string ) $ arg [ 'name' ] ; } $ key = isset ( $ arg [ 'key' ] ) ? ( string ) $ arg [ 'key' ] : ( ! $ argu...
Returns arguments as valid PHP types .
15,908
public function create ( ProductCreateEvent $ event ) { $ defaultTaxRuleId = null ; if ( null !== $ defaultTaxRule = TaxRuleQuery :: create ( ) -> findOneByIsDefault ( true ) ) { $ defaultTaxRuleId = $ defaultTaxRule -> getId ( ) ; } $ product = new ProductModel ( ) ; $ product -> setDispatcher ( $ this -> eventDispatc...
Create a new product entry
15,909
public function update ( ProductUpdateEvent $ event ) { if ( null !== $ product = ProductQuery :: create ( ) -> findPk ( $ event -> getProductId ( ) ) ) { $ con = Propel :: getWriteConnection ( ProductTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ prevRef = $ product -> getRef ( ) ; $ product -> ...
Change a product
15,910
public function delete ( ProductDeleteEvent $ event ) { if ( null !== $ product = ProductQuery :: create ( ) -> findPk ( $ event -> getProductId ( ) ) ) { $ con = Propel :: getWriteConnection ( ProductTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ fileList = [ 'images' => [ ] , 'documentList' => ...
Delete a product entry
15,911
public function toggleVisibility ( ProductToggleVisibilityEvent $ event ) { $ product = $ event -> getProduct ( ) ; $ product -> setDispatcher ( $ this -> eventDispatcher ) -> setVisible ( $ product -> getVisible ( ) ? false : true ) -> save ( ) ; $ event -> setProduct ( $ product ) ; }
Toggle product visibility . No form used here
15,912
public function updateAccessoryPosition ( UpdatePositionEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { return $ this -> genericUpdatePosition ( AccessoryQuery :: create ( ) , $ event , $ dispatcher ) ; }
Changes accessry position selecting absolute ou relative change .
15,913
public function deleteFeatureProductValue ( FeatureProductDeleteEvent $ event ) { FeatureProductQuery :: create ( ) -> filterByProductId ( $ event -> getProductId ( ) ) -> filterByFeatureId ( $ event -> getFeatureId ( ) ) -> delete ( ) ; }
Delete a product feature value
15,914
public function deleteTemplateFeature ( TemplateDeleteFeatureEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ products = ProductQuery :: create ( ) -> filterByTemplateId ( $ event -> getTemplate ( ) -> getId ( ) ) -> find ( ) ; foreach ( $ products as $ product ) { $ dispatcher -> dispatch ( Th...
When a feature is removed from a template the products which are using this feature should be updated .
15,915
public function deleteTemplateAttribute ( TemplateDeleteAttributeEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ pseToDelete = ProductSaleElementsQuery :: create ( ) -> useProductQuery ( ) -> filterByTemplateId ( $ event -> getTemplate ( ) -> getId ( ) ) -> endUse ( ) -> useAttributeCombinatio...
When an attribute is removed from a template the conbinations and PSE of products which are using this template should be updated .
15,916
public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'product' ) { $ product = ProductQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ product == 0 ) { $ dispatcher -> disp...
Check if is a product view and if product_id is visible
15,917
public function checkDuplicateCouponCode ( $ value , ExecutionContextInterface $ context ) { $ exists = CouponQuery :: create ( ) -> filterByCode ( $ value ) -> count ( ) > 0 ; if ( $ exists ) { $ context -> addViolation ( Translator :: getInstance ( ) -> trans ( "The coupon code '%code' already exists. Please choose a...
Check coupon code unicity
15,918
public function checkLocalizedDate ( $ value , ExecutionContextInterface $ context ) { $ format = LangQuery :: create ( ) -> findOneByByDefault ( true ) -> getDatetimeFormat ( ) ; if ( false === \ DateTime :: createFromFormat ( $ format , $ value ) ) { $ context -> addViolation ( Translator :: getInstance ( ) -> trans ...
Validate a date entered with the default Language date format .
15,919
public function getModulesDependOf ( $ active = true ) { $ code = $ this -> getModuleDefinition ( ) -> getCode ( ) ; $ query = ModuleQuery :: create ( ) ; $ dependantModules = [ ] ; if ( true === $ active ) { $ query -> findByActivate ( 1 ) ; } elseif ( false === $ active ) { $ query -> findByActivate ( 0 ) ; } $ modul...
Get an array of modules that depend of the current module
15,920
public function getCurrentModuleDependencies ( $ recursive = false ) { if ( empty ( $ this -> moduleDescriptor -> required ) ) { return [ ] ; } $ dependencies = [ ] ; foreach ( $ this -> moduleDescriptor -> required -> module as $ dependency ) { $ dependencyArray = [ "code" => ( string ) $ dependency , "version" => ( s...
Get the dependencies of this module .
15,921
public function sortKey ( ) { if ( $ this instanceof RootNode ) { return spl_object_hash ( $ this ) ; } if ( ! $ this -> parent ) { return '~/' . spl_object_hash ( $ this ) ; } $ path = $ this -> parent -> sortKey ( ) . '/' ; $ position = 0 ; $ previous = $ this -> previous ; while ( $ previous ) { $ position ++ ; $ pr...
Get a unique key for sorting this node .
15,922
public function is ( $ test ) { if ( is_callable ( $ test ) ) { return ( boolean ) $ test ( $ this ) ; } elseif ( is_string ( $ test ) ) { return $ this -> is ( Filter :: isInstanceOf ( $ test ) ) ; } else { throw new \ InvalidArgumentException ( ) ; } }
Tests this node against a condition .
15,923
public function isAnyOf ( array $ tests ) { foreach ( $ tests as $ test ) { if ( $ this -> is ( $ test ) ) { return TRUE ; } } return FALSE ; }
Tests if this node matches any the tests in the array .
15,924
public function isAllOf ( array $ tests ) { foreach ( $ tests as $ test ) { if ( ! $ this -> is ( $ test ) ) { return FALSE ; } } return TRUE ; }
Tests if this node matches all of the tests in the array .
15,925
public static function fromValue ( $ value ) { if ( is_array ( $ value ) ) { $ elements = [ ] ; foreach ( $ value as $ k => $ v ) { $ elements [ ] = ArrayPairNode :: create ( static :: fromValue ( $ k ) , static :: fromValue ( $ v ) ) ; } return ArrayNode :: create ( $ elements ) ; } elseif ( is_string ( $ value ) ) { ...
Creates a Node from a php value .
15,926
protected function init ( ) { $ this -> setLevel ( ConfigQuery :: read ( self :: VAR_LEVEL , self :: DEFAULT_LEVEL ) ) ; $ this -> dir_destinations = array ( __DIR__ . DS . 'Destination' , THELIA_LOCAL_DIR . 'tlog' . DS . 'destinations' ) ; $ this -> setPrefix ( ConfigQuery :: read ( self :: VAR_PREFIXE , self :: DEFAU...
initialize default configuration
15,927
protected function listExport ( OutputInterface $ output ) { $ table = new Table ( $ output ) ; foreach ( ( new ExportQuery ) -> find ( ) as $ export ) { $ table -> addRow ( [ $ export -> getRef ( ) , $ export -> getTitle ( ) , $ export -> getDescription ( ) ] ) ; } $ table -> setHeaders ( [ 'Reference' , 'Title' , 'De...
Output available exports
15,928
protected function listSerializer ( OutputInterface $ output ) { $ table = new Table ( $ output ) ; $ serializerManager = $ this -> getContainer ( ) -> get ( RegisterSerializerPass :: MANAGER_SERVICE_ID ) ; foreach ( $ serializerManager -> getSerializers ( ) as $ serializer ) { $ table -> addRow ( [ $ serializer -> get...
Output available serializers
15,929
protected function listArchiver ( OutputInterface $ output ) { $ table = new Table ( $ output ) ; $ archiverManager = $ this -> getContainer ( ) -> get ( RegisterArchiverPass :: MANAGER_SERVICE_ID ) ; foreach ( $ archiverManager -> getArchivers ( true ) as $ archiver ) { $ table -> addRow ( [ $ archiver -> getId ( ) , ...
Output available archivers
15,930
public function getCurrency ( $ forceDefault = true ) { $ currency = $ this -> get ( "thelia.current.currency" ) ; if ( null === $ currency && $ forceDefault ) { $ currency = Currency :: getDefaultCurrency ( ) ; } return $ currency ; }
Return current currency
15,931
public function setSessionCart ( Cart $ cart = null ) { if ( null === $ cart || $ cart -> isNew ( ) ) { self :: $ transientCart = $ cart ; $ this -> remove ( "thelia.cart_id" ) ; } else { self :: $ transientCart = null ; $ this -> set ( "thelia.cart_id" , $ cart -> getId ( ) ) ; } return $ this ; }
Set the cart to store in the current session .
15,932
public function getSessionCart ( EventDispatcherInterface $ dispatcher = null ) { $ cart_id = $ this -> get ( "thelia.cart_id" , null ) ; if ( null !== $ cart_id ) { $ cart = CartQuery :: create ( ) -> findPk ( $ cart_id ) ; } else { $ cart = self :: $ transientCart ; } if ( null === $ cart || ! $ this -> isValidCart (...
Return the cart stored in the current session
15,933
public function clearSessionCart ( EventDispatcherInterface $ dispatcher ) { $ event = new CartCreateEvent ( ) ; $ dispatcher -> dispatch ( TheliaEvents :: CART_CREATE_NEW , $ event ) ; if ( null === $ cart = $ event -> getCart ( ) ) { throw new \ LogicException ( "Unable to get a new empty Cart." ) ; } $ this -> setSe...
Clear the current session cart and store a new empty one in the session .
15,934
protected function isValidCart ( Cart $ cart ) { $ customer = $ this -> getCustomerUser ( ) ; return ( null !== $ customer && $ cart -> getCustomerId ( ) == $ customer -> getId ( ) ) || ( null === $ customer && $ cart -> getCustomerId ( ) === null ) ; }
A cart is valid if its customer ID is the same as the current logged in user
15,935
public function create ( CouponCreateOrUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ coupon = new CouponModel ( ) ; $ this -> createOrUpdate ( $ coupon , $ event , $ dispatcher ) ; }
Occurring when a Coupon is about to be created
15,936
public function update ( CouponCreateOrUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ coupon = $ event -> getCouponModel ( ) ; $ this -> createOrUpdate ( $ coupon , $ event , $ dispatcher ) ; }
Occurring when a Coupon is about to be updated
15,937
public function updateCondition ( CouponCreateOrUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ modelCoupon = $ event -> getCouponModel ( ) ; $ this -> createOrUpdateCondition ( $ modelCoupon , $ event , $ dispatcher ) ; }
Occurring when a Coupon condition is about to be updated
15,938
public function clearAllCoupons ( Event $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ this -> couponManager -> clear ( ) ; $ this -> getSession ( ) -> setConsumedCoupons ( array ( ) ) ; $ this -> updateOrderDiscount ( $ event , $ eventName , $ dispatcher ) ; }
Clear all coupons in session .
15,939
public function consume ( CouponConsumeEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ totalDiscount = 0 ; $ isValid = false ; $ coupon = $ this -> couponFactory -> buildCouponFromCode ( $ event -> getCode ( ) ) ; if ( $ coupon ) { $ isValid = $ coupon -> isMatching ( ) ; if ( $ isValid ) { $ ...
Occurring when a Coupon condition is about to be consumed
15,940
public function orderStatusChange ( OrderEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getOrder ( ) -> isCancelled ( ) || $ event -> getOrder ( ) -> isRefunded ( ) ) { $ usedCoupons = OrderCouponQuery :: create ( ) -> filterByUsageCanceled ( false ) -> findByOrderId ( $ event -...
Cancels order coupons usage when order is canceled or refunded or use canceled coupons again if the order is no longer canceled or refunded
15,941
protected function updateProductSaleElementsPrices ( $ pseList , $ promoStatus , $ offsetType , Calculator $ taxCalculator , $ saleOffsetByCurrency , ConnectionInterface $ con ) { foreach ( $ pseList as $ pse ) { if ( $ pse -> getPromo ( ) != $ promoStatus ) { $ pse -> setPromo ( $ promoStatus ) -> save ( $ con ) ; } f...
Update PSE for a given product
15,942
public function updateProductsSaleStatus ( ProductSaleStatusUpdateEvent $ event ) { $ taxCalculator = new Calculator ( ) ; $ sale = $ event -> getSale ( ) ; if ( null !== $ saleProducts = SaleProductQuery :: create ( ) -> filterBySale ( $ sale ) -> orderByProductId ( ) ) { $ saleOffsetByCurrency = $ sale -> getPriceOff...
Update the promo status of the sale s selected products and combinations
15,943
public function create ( SaleCreateEvent $ event ) { $ sale = new SaleModel ( ) ; $ sale -> setLocale ( $ event -> getLocale ( ) ) -> setTitle ( $ event -> getTitle ( ) ) -> setSaleLabel ( $ event -> getSaleLabel ( ) ) -> save ( ) ; $ event -> setSale ( $ sale ) ; }
Create a new Sale
15,944
public function update ( SaleUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ sale = SaleQuery :: create ( ) -> findPk ( $ event -> getSaleId ( ) ) ) { $ sale -> setDispatcher ( $ dispatcher ) ; $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -...
Process update sale
15,945
public function toggleActivity ( SaleToggleActivityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ sale = $ event -> getSale ( ) ; $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ sale -> setDispatcher ( $ dispatcher ) -> setActiv...
Toggle Sale activity
15,946
public function delete ( SaleDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ sale = SaleQuery :: create ( ) -> findPk ( $ event -> getSaleId ( ) ) ) { $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { if ( $ sale ...
Delete a sale
15,947
public function clearStatus ( SaleClearStatusEvent $ event ) { $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { SaleQuery :: create ( ) -> filterByActive ( true ) -> update ( [ 'Active' => false ] , $ con ) ; ProductSaleElementsQuery :: create ( ) -> filterB...
Clear all sales
15,948
public function checkSaleActivation ( SaleActiveStatusCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ con = Propel :: getWriteConnection ( SaleTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ now = time ( ) ; if ( null !== $ salesToDisable = SaleQuery :: create ( ) ->...
This method check the activation and deactivation dates of sales and perform the required action depending on the current date .
15,949
public function combine ( array $ schemaDocuments = [ ] , array $ externalSchemaDocuments = [ ] ) { $ globalDatabaseElements = [ ] ; foreach ( $ schemaDocuments as $ sourceSchemaDocument ) { if ( ! $ sourceSchemaDocument instanceof \ DOMDocument ) { throw new \ InvalidArgumentException ( 'Schema file is not a \DOMDocum...
Combine multiple schemas into one schema per database .
15,950
protected function inheritDatabaseAttributes ( \ DOMElement $ databaseElement ) { $ attributesToInherit = [ ] ; foreach ( static :: $ DATABASE_INHERITABLE_ATTRIBUTES as $ databaseAttribute => $ tableAttribute ) { if ( ! $ databaseElement -> hasAttribute ( $ databaseAttribute ) ) { continue ; } $ attributesToInherit [ $...
Copy inheritable database attribute to the tables in the database .
15,951
protected function applyDatabaseTablePrefix ( \ DOMElement $ databaseElement ) { if ( ! $ databaseElement -> hasAttribute ( 'tablePrefix' ) ) { return ; } $ tablePrefix = $ databaseElement -> getAttribute ( 'tablePrefix' ) ; foreach ( $ databaseElement -> getElementsByTagName ( 'table' ) as $ tableElement ) { if ( ! $ ...
Prefix table names with the prefix defined on the database .
15,952
protected function getDatabaseFromDatabaseElement ( \ DOMElement $ databaseElement ) { $ database = $ databaseElement -> getAttribute ( 'name' ) ; if ( empty ( $ database ) ) { throw new \ LogicException ( 'Unnamed database node.' ) ; } return $ database ; }
Get the database name from a database element .
15,953
protected function initGlobalDatabaseElement ( $ database ) { if ( \ in_array ( $ database , $ this -> databases ) ) { return ; } $ databaseDocument = new \ DOMDocument ( static :: $ GLOBAL_SCHEMA_XML_VERSION , static :: $ GLOBAL_SCHEMA_XML_ENCODING ) ; $ databaseElement = $ databaseDocument -> createElement ( 'databas...
Create a global database element in a new document .
15,954
protected function mergeDatabaseElement ( \ DOMElement $ sourceDatabaseElement ) { $ database = $ this -> getDatabaseFromDatabaseElement ( $ sourceDatabaseElement ) ; $ this -> initGlobalDatabaseElement ( $ database ) ; $ globalDatabaseElement = $ this -> globalDatabaseElements [ $ database ] ; $ fileStartMarkerComment...
Merge a source database element into the corresponding global database element for this database .
15,955
protected function includeExternalSchema ( \ DOMElement $ externalDatabaseElement ) { $ database = $ this -> getDatabaseFromDatabaseElement ( $ externalDatabaseElement ) ; $ this -> initGlobalDatabaseElement ( $ database ) ; $ globalDatabaseElement = $ this -> globalDatabaseElements [ $ database ] ; $ externalSchemaInc...
Include an external schema into a database element .
15,956
public function getImport ( $ importId , $ dispatchException = false ) { $ import = ( new ImportQuery ) -> findPk ( $ importId ) ; if ( $ import === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no id "%id" in the imports' , [ '%id' => $ importId ] ) ) ;...
Get import model based on given identifier
15,957
public function getImportByRef ( $ importRef , $ dispatchException = false ) { $ import = ( new ImportQuery ) -> findOneByRef ( $ importRef ) ; if ( $ import === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no id "%ref" in the imports' , [ '%ref' => $ i...
Get import model based on given reference
15,958
public function getCategory ( $ importCategoryId , $ dispatchException = false ) { $ category = ( new ImportCategoryQuery ) -> findPk ( $ importCategoryId ) ; if ( $ category === null && $ dispatchException ) { throw new \ ErrorException ( Translator :: getInstance ( ) -> trans ( 'There is no id "%id" in the import cat...
Get import category model based on given identifier
15,959
public function matchArchiverByExtension ( $ fileName ) { foreach ( $ this -> archiverManager -> getArchivers ( true ) as $ archiver ) { if ( stripos ( $ fileName , '.' . $ archiver -> getExtension ( ) ) !== false ) { return $ archiver ; } } return null ; }
Match archiver relative to file name
15,960
public function matchSerializerByExtension ( $ fileName ) { foreach ( $ this -> serializerManager -> getSerializers ( ) as $ serializer ) { if ( stripos ( $ fileName , '.' . $ serializer -> getExtension ( ) ) !== false ) { return $ serializer ; } } return null ; }
Match serializer relative to file name
15,961
public function dump ( $ glue = '' , $ before = '' , $ after = '' ) { $ ret = '' ; if ( 0 !== \ count ( $ this -> fragments ) ) { $ ret = $ before . implode ( $ glue , $ this -> fragments ) . $ after ; } return $ ret ; }
Concatenates all fragments in a string .
15,962
public function buildConnectionNode ( $ rootName , $ isArray ) { $ treeBuilder = new TreeBuilder ( ) ; $ connectionNode = $ treeBuilder -> root ( $ rootName ) ; if ( $ isArray ) { $ connectionNodePrototype = $ connectionNode -> prototype ( 'array' ) ; $ connectionNodeBuilder = $ connectionNodePrototype -> children ( ) ...
Build a configuration node describing one or more database connection
15,963
public function getUseDeclarations ( ) { $ declarations = [ ] ; $ use_blocks = $ this -> children ( Filter :: isInstanceOf ( '\Pharborist\Namespaces\UseDeclarationBlockNode' ) ) ; foreach ( $ use_blocks as $ use_block ) { foreach ( $ use_block -> getDeclarationStatements ( ) as $ use_statement ) { $ declarations = arra...
Get the use declarations of this statement block .
15,964
public function getClassAliases ( ) { $ mappings = array ( ) ; foreach ( $ this -> getUseDeclarations ( ) as $ use_declaration ) { if ( $ use_declaration -> isClass ( ) ) { $ mappings [ $ use_declaration -> getBoundedName ( ) ] = $ use_declaration -> getName ( ) -> getAbsolutePath ( ) ; } } return $ mappings ; }
Return mapping of class names to fully qualified names .
15,965
public function appendStatement ( StatementNode $ statementNode ) { if ( ! $ this -> isEmpty ( ) && $ this -> firstToken ( ) -> getType ( ) === '{' ) { $ this -> lastChild ( ) -> before ( $ statementNode ) ; } else { $ this -> appendChild ( $ statementNode ) ; } return $ this ; }
Append statement to block .
15,966
public function make ( array $ config ) { Arr :: requires ( $ config , [ 'token' ] ) ; $ client = new Client ( ) ; return new SlackGateway ( $ client , $ config ) ; }
Create a new slack gateway instance .
15,967
public static function get ( $ key = null ) { $ configs = self :: $ configs ; if ( $ key ) { $ configs = ! empty ( self :: $ configs [ $ key ] ) ? self :: $ configs [ $ key ] : null ; } else { $ configs = self :: $ configs ; } return $ configs ; }
Get configs or config by key .
15,968
public static function any ( $ filters ) { return function ( $ node ) use ( $ filters ) { foreach ( $ filters as $ filter ) { if ( $ filter ( $ node ) ) { return TRUE ; } } return FALSE ; } ; }
Callback returns true if any of the callbacks pass .
15,969
public static function all ( $ filters ) { return function ( $ node ) use ( $ filters ) { foreach ( $ filters as $ filter ) { if ( ! $ filter ( $ node ) ) { return FALSE ; } } return TRUE ; } ; }
Callback returns true if all of the callbacks pass .
15,970
public static function isInstanceOf ( $ class_name ) { $ classes = func_get_args ( ) ; return function ( $ node ) use ( $ classes ) { foreach ( $ classes as $ class ) { if ( $ node instanceof $ class ) { return TRUE ; } } return FALSE ; } ; }
Callback to filter for nodes of certain types .
15,971
public static function isFunction ( $ function_name ) { $ function_names = func_get_args ( ) ; return function ( $ node ) use ( $ function_names ) { if ( $ node instanceof FunctionDeclarationNode ) { return in_array ( $ node -> getName ( ) -> getText ( ) , $ function_names , TRUE ) ; } return FALSE ; } ; }
Callback to filter for specific function declaration .
15,972
public static function isFunctionCall ( $ function_name ) { $ function_names = func_get_args ( ) ; return function ( $ node ) use ( $ function_names ) { if ( $ node instanceof FunctionCallNode ) { return in_array ( $ node -> getName ( ) -> getText ( ) , $ function_names , TRUE ) ; } return FALSE ; } ; }
Callback to filter for calls to a function .
15,973
public static function isClass ( $ class_name ) { $ class_names = func_get_args ( ) ; return function ( $ node ) use ( $ class_names ) { if ( $ node instanceof ClassNode ) { return in_array ( $ node -> getName ( ) -> getText ( ) , $ class_names , TRUE ) ; } return FALSE ; } ; }
Callback to filter for specific class declaration .
15,974
public static function isClassMethodCall ( $ class_name , $ method_name ) { return function ( $ node ) use ( $ class_name , $ method_name ) { if ( $ node instanceof ClassMethodCallNode ) { $ call_class_name_node = $ node -> getClassName ( ) ; $ call_class_name = $ call_class_name_node instanceof NameNode ? $ call_class...
Callback to filter for calls to a class method .
15,975
public static function isComment ( $ include_doc_comment = TRUE ) { if ( $ include_doc_comment ) { return function ( $ node ) { if ( $ node instanceof LineCommentBlockNode ) { return TRUE ; } elseif ( $ node instanceof CommentNode ) { return ! ( $ node -> parent ( ) instanceof LineCommentBlockNode ) ; } else { return F...
Callback to filter comments .
15,976
public static function isTokenType ( $ type ) { $ types = func_get_args ( ) ; return function ( $ node ) use ( $ types ) { return $ node instanceof TokenNode && in_array ( $ node -> getType ( ) , $ types ) ; } ; }
Callback to test if match to given token type .
15,977
public static function isNewline ( ) { static $ callback = NULL ; if ( ! $ callback ) { $ callback = function ( Node $ node ) { return $ node instanceof WhitespaceNode && $ node -> getNewlineCount ( ) > 0 ; } ; } return $ callback ; }
Callback to match whitespace containing newlines .
15,978
public static function create ( string $ contents ) { $ contextInst = new ContextFactory ( ) ; $ context = function ( string $ namespace ) use ( $ contents , $ contextInst ) { return $ contextInst -> createForNamespace ( $ namespace , $ contents ) ; } ; $ phpdocInst = DocBlockFactory :: createInstance ( ) ; $ phpdoc = ...
Create a new doc visitor aware of file contents .
15,979
public function enterNode ( Node $ node ) { if ( $ node instanceof Namespace_ ) { $ this -> resetContext ( $ node -> name ) ; } $ this -> recordDoc ( $ node -> getAttribute ( 'comments' , [ ] ) ) ; return $ node ; }
Enter the node and record the phpdoc .
15,980
protected function recordDoc ( array $ comments ) { $ callable = $ this -> phpdocFactory ; foreach ( $ comments as $ comment ) { if ( $ comment instanceof Doc ) { $ this -> doc [ ] = $ callable ( $ comment -> getText ( ) , $ this -> context ) ; } } }
Reset the visitor context .
15,981
protected static function sortUnique ( $ nodes ) { $ sort = [ ] ; $ detached = [ ] ; foreach ( $ nodes as $ node ) { $ key = $ node -> sortKey ( ) ; if ( $ key [ 0 ] === '~' ) { $ detached [ ] = $ node ; } else { $ sort [ $ key ] = $ node ; } } ksort ( $ sort , SORT_NATURAL ) ; return array_merge ( array_values ( $ sor...
Sort nodes and remove duplicates
15,982
public function slice ( $ start_index , $ end_index = NULL ) { if ( $ start_index < 0 ) { $ start_index = $ this -> count ( ) + $ start_index ; } if ( $ end_index < 0 ) { $ end_index = $ this -> count ( ) + $ end_index ; } $ last_index = $ this -> count ( ) - 1 ; if ( $ start_index > $ last_index ) { $ start_index = $ ...
Reduce the set of matched nodes to a subset specified by a range .
15,983
public function indexOf ( callable $ callback ) { foreach ( $ this -> nodes as $ i => $ node ) { if ( $ callback ( $ node ) ) { return $ i ; } } return - 1 ; }
Index of first element that is matched by callback .
15,984
public function is ( callable $ callback ) { foreach ( $ this -> nodes as $ node ) { if ( $ callback ( $ node ) ) { return TRUE ; } } return FALSE ; }
Test is any element in collection matches .
15,985
public function closest ( callable $ callback ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ match = $ node -> closest ( $ callback ) ) { $ matches [ ] = $ match ; } } return new NodeCollection ( $ matches ) ; }
For each node in the collection get the first node matched by the callback by testing this node and traversing up through its ancestors in the tree .
15,986
public function children ( callable $ callback = NULL ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ node instanceof ParentNode ) { $ matches = array_merge ( $ matches , $ node -> children ( $ callback ) -> nodes ) ; } } return new NodeCollection ( $ matches ) ; }
Get the immediate children of each node in the set of matched nodes .
15,987
public function clear ( ) { foreach ( $ this -> nodes as $ node ) { if ( $ node instanceof ParentNode ) { $ node -> clear ( ) ; } } return $ this ; }
Remove all child nodes of the set of matched elements .
15,988
public function previous ( callable $ callback = NULL ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ match = $ node -> previous ( $ callback ) ) { $ matches [ ] = $ match ; } } return new NodeCollection ( $ matches ) ; }
Get the immediately preceding sibling of each node in the set of matched nodes . If a callback is provided it retrieves the next sibling only if the callback returns TRUE .
15,989
public function previousAll ( callable $ callback = NULL ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { $ matches = array_merge ( $ matches , $ node -> previousAll ( $ callback ) -> nodes ) ; } return new NodeCollection ( $ matches ) ; }
Get all preceding siblings of each node in the set of matched nodes optionally filtered by a callback .
15,990
public function previousUntil ( callable $ callback , $ inclusive = FALSE ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { $ matches = array_merge ( $ matches , $ node -> previousUntil ( $ callback , $ inclusive ) -> nodes ) ; } return new NodeCollection ( $ matches ) ; }
Get all preceding siblings of each node up to the node matched by the callback .
15,991
public function find ( callable $ callback ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ node instanceof ParentNode ) { $ matches = array_merge ( $ matches , $ node -> find ( $ callback ) -> nodes ) ; } } return new NodeCollection ( $ matches ) ; }
Get the descendants of each node in the current set of matched nodes filtered by callback .
15,992
public function filter ( callable $ callback ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ index => $ node ) { if ( $ callback ( $ node , $ index ) ) { $ matches [ ] = $ node ; } } return new NodeCollection ( $ matches , FALSE ) ; }
Reduce the set of matched nodes to those that pass the callback filter .
15,993
public function has ( callable $ callback ) { $ matches = [ ] ; foreach ( $ this -> nodes as $ node ) { if ( $ node instanceof ParentNode && $ node -> has ( $ callback ) ) { $ matches [ ] = $ node ; } } return new NodeCollection ( $ matches , FALSE ) ; }
Reduce the set of matched nodes to those that have a descendant that match .
15,994
public function first ( ) { $ matches = [ ] ; if ( ! empty ( $ this -> nodes ) ) { $ matches [ ] = $ this -> nodes [ 0 ] ; } return new NodeCollection ( $ matches , FALSE ) ; }
Reduce the set of matched nodes to the first in the set .
15,995
public function last ( ) { $ matches = [ ] ; if ( ! empty ( $ this -> nodes ) ) { $ matches [ ] = $ this -> nodes [ count ( $ this -> nodes ) - 1 ] ; } return new NodeCollection ( $ matches , FALSE ) ; }
Reduce the set of matched nodes to the last in the set .
15,996
public function insertBefore ( $ targets ) { foreach ( $ this -> nodes as $ node ) { $ node -> insertBefore ( $ targets ) ; } return $ this ; }
Insert every node in the set of matched nodes before the targets .
15,997
public function before ( $ nodes ) { foreach ( $ this -> nodes as $ i => $ node ) { $ node -> before ( $ i === 0 ? $ nodes : clone $ nodes ) ; } return $ this ; }
Insert nodes before each node in the set of matched nodes .
15,998
public function insertAfter ( $ targets ) { foreach ( $ this -> nodes as $ node ) { $ node -> insertAfter ( $ targets ) ; } return $ this ; }
Insert every node in the set of matched nodes after the targets .
15,999
public function after ( $ nodes ) { foreach ( $ this -> nodes as $ i => $ node ) { $ node -> after ( $ i === 0 ? $ nodes : clone $ nodes ) ; } return $ this ; }
Insert nodes after each node in the set of matched nodes .