Feature #30418

Package bootstrapping following dependencies

Added by Benjamin Heek almost 4 years ago. Updated almost 4 years ago.

Status:New Start date:2011-09-29
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:Core
Target version:-
PHP Version: Complexity:
Has patch:

Description

It would be nice if packages are bootstrapped in correct order, following the dependency constraints that are described in the Package.xml of a package


Related issues

related to TYPO3.Flow - Feature #54151: Implement proper package dependency handling Resolved 2013-12-02

History

#1 Updated by Benjamin Heek almost 4 years ago

this is the code I use

/**
     * order all packages on dependency constraints
     * 
     * @return void
     */
    protected function orderPackages()
    {
        $ordering             = array();
        $orderedPackages     = array();

        /**
         * first we order all the dependencies per package
         */
        foreach ($this->packages AS $packageKey=>$package){
            $this->orderPackageDependencies($packageKey,$ordering);
        }

        /**
         * now add the packages that were not ordered, because they don't have dependencies
         */
        foreach ($this->packages AS $packageKey=>$package){
            if(!in_array($packageKey,$ordering)){
                $ordering[] = $packageKey;
            }
        }

        foreach ($ordering AS $orderedPackageKey){
            $orderedPackages[$orderedPackageKey] = $this->packages[$orderedPackageKey];
        }

        $this->activePackages = $orderedPackages;
    }

    /**
     * add dependencies of a package to the ordering
     * 
     * @param string $packageKey
     * @param array $ordering
     */
    protected function orderPackageDependencies($packageKey,&$ordering)
    {
        if(in_array($packageKey,$ordering)){
            return;
        }

        $package     = $this->getPackage($packageKey);
                $this->activatePackage($packageKey);
        $metadata    = $package->getPackageMetaData();
        if ($depends = $metadata->getConstraintsByType('depends')){
            foreach ($depends AS $dependeny){
                if($dependeny instanceof \TYPO3\FLOW3\Package\MetaData\PackageConstraint){
                    $packageDependencyKey = $dependeny->getValue();
                    $this->orderPackageDependencies($packageDependencyKey,$ordering);
                    $ordering[] = $packageDependencyKey;
                }
            }
        }
    }

#2 Updated by Karsten Dambekalns almost 4 years ago

  • Project changed from TYPO3 Flow Base Distribution to TYPO3.Flow

#3 Updated by Karsten Dambekalns almost 4 years ago

  • Category set to Core

Also available in: Atom PDF