Feature #30418

Package bootstrapping following dependencies

Added by Benjamin Heek over 9 years ago. Updated over 9 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Core
Target version:
-
Start date:
2011-09-29
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
Complexity:

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 handlingResolved2013-12-02

Actions
#1

Updated by Benjamin Heek over 9 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 over 9 years ago

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

Updated by Karsten Dambekalns over 9 years ago

  • Category set to Core

Also available in: Atom PDF