@param BundleInterface $bundle     The bundle
@param string          $entityName The entity name
@param string          $sortField  The name of the sort field

@throws \RuntimeException
430149
public function generateController(BundleInterface $bundle, $entityName, $sortField)
    {
        $className = sprintf('%sAdminListController', $entityName);
        $dirPath = sprintf('%s/Controller', $bundle->getPath());
        $classPath = sprintf('%s/%s.php', $dirPath, str_replace('\\', '/', $className));
        $extensions = 'csv';
        if (class_exists('\\Kunstmaan\\AdminListBundle\\Service\\ExportService')) {
            $extensions = implode('|', \Kunstmaan\AdminListBundle\Service\ExportService::getSupportedExtensions());
        }

        if (file_exists($classPath)) {
            throw new \RuntimeException(
                sprintf(
                    'Unable to generate the %s class as it already exists under the %s file',
                    $className,
                    $classPath
                )
            );
        }

        $this->setSkeletonDirs(array($this->skeletonDir));
        $this->renderFile(
            '/Controller/EntityAdminListController.php',
            $classPath,
            array(
                'namespace' => $bundle->getNamespace(),
                'bundle' => $bundle,
                'entity_class' => $entityName,
                'export_extensions' => $extensions,
                'sortField' => $sortField,
                'isV4' => Kernel::VERSION_ID >= 40000,
            )
        );
    }
1286841
public function sortByEntityField($getterName)
    {
        usort($this->collection, function (ArraySerializable $a, ArraySerializable $b) use ($getterName) {
            if ($a->$getterName() === $b->$getterName()) {
                return 0;
            }

            return $a->$getterName() > $b->$getterName() ? 1 : -1;
        });

        return $this;
    }
925615
public function addBundle(Bundle $bundle)
    {
        foreach ($bundle as $resource) {
            if (is_string($resource)) {
                $this->addFile($resource);
            } else {
                $this->buildFromIterator($resource);
            }
        }
    }
257411
public static void removeLocalBundle(String name, Version version, boolean removePhysical, boolean doubleTap) throws BundleException {
	name = name.trim();
	CFMLEngine engine = CFMLEngineFactory.getInstance();
	CFMLEngineFactory factory = engine.getCFMLEngineFactory();

	BundleFile bf = _getBundleFile(factory, name, version, null);
	if (bf != null) {
	    BundleDefinition bd = bf.toBundleDefinition();
	    if (bd != null) {
		Bundle b = bd.getLocalBundle();
		if (b != null) {
		    stopIfNecessary(b);
		    b.uninstall();
		}
	    }
	}

	if (!removePhysical) return;

	// remove file
	if (bf != null) {
	    if (!bf.getFile().delete() && doubleTap) bf.getFile().deleteOnExit();
	}
    }
328764
public function checkDependencies(array $requiredBundles, ContainerBuilder $container)
    {
        if (false === ($this instanceof Bundle)) {
            throw new RuntimeException('It is a bundle trait, you shouldn\'t have to use in other instances');
        }

        $enabledBundles = $container->getParameter('kernel.bundles');
        foreach ($requiredBundles as $requiredBundle) {
            if (!isset($enabledBundles[$requiredBundle])) {
                throw new RuntimeException(
                    sprintf(
                        'In order to use "%s" you also need to enable and configure the "%s"',
                        $this->getName(),
                        $requiredBundle
                    )
                );
            }
        }
    }
1333089
public void addField(String fieldName, SortDirection sortDirection) {
        if (sortFields == null) sortFields = new HashMap<>();

        sortFields.put(fieldName, sortDirection);
    }
637413
public function setBundle(AbstractBundle $bundle)
    {
        $data = $bundle->getValues();
        foreach ($data as $name => $value) {
            $query = $this->getNewQuery();
            $query = $bundle->makeQueryFiltered($query);
            $setting = $query->firstOrNew(['name' => $name]);
            $setting->value = $value;
            $setting->save();
        }
    }
1353954
private void initResourceBundles(List<JoinableResourceBundle> resourceBundles)
			throws DuplicateBundlePathException, BundleDependencyException {

		// Create custom defined bundles
		bundleDefinitionsWithDependencies = new HashSet<>();
		if (null != bundleDefinitions) {
			if (LOGGER.isInfoEnabled())
				LOGGER.info("Adding custom bundle definitions. ");
			for (ResourceBundleDefinition def : bundleDefinitions) {
				// If this is a composite bundle
				if (def.isComposite()) {
					resourceBundles.add(buildCompositeResourcebundle(def));
				} else
					resourceBundles.add(buildResourcebundle(def));
			}
		}

		// Normalize the base Dir if needed
		if (!jawrConfig.getGeneratorRegistry().isPathGenerated(baseDir)) {
			this.baseDir = PathNormalizer.asDirPath(baseDir);
		}

		// Use the dirmapper if specified
		if (useDirMapperFactory) {
			if (LOGGER.isInfoEnabled())
				LOGGER.info("Using ResourceBundleDirMapper. ");

			ResourceBundleDirMapper dirFactory = new ResourceBundleDirMapper(baseDir, resourceReaderHandler,
					resourceBundles, fileExtension, excludedDirMapperDirs);
			Map<String, String> mappings = dirFactory.getBundleMapping();
			for (Entry<String, String> entry : mappings.entrySet()) {
				resourceBundles.add(buildDirMappedResourceBundle(entry.getKey(), entry.getValue()));
			}
		}

		if (this.scanForOrphans) {
			// Add all orphan bundles
			OrphanResourceBundlesMapper orphanFactory = new OrphanResourceBundlesMapper(baseDir, resourceReaderHandler,
					jawrConfig.getGeneratorRegistry(), resourceBundles, fileExtension);
			List<String> orphans = orphanFactory.getOrphansList();

			// Orphans may be added separately or as one single resource bundle.
			if (useSingleResourceFactory) {
				// Add extension to the filename
				if (!singleFileBundleName.endsWith(fileExtension))
					singleFileBundleName += fileExtension;

				if (LOGGER.isInfoEnabled())
					LOGGER.info("Building bundle of orphan resources with the name: " + singleFileBundleName);

				resourceBundles.add(buildOrphansResourceBundle(singleFileBundleName, orphans));

			} else {
				if (LOGGER.isInfoEnabled())
					LOGGER.info("Creating mappings for orphan resources. ");
				for (Iterator<String> it = orphans.iterator(); it.hasNext();) {
					resourceBundles.add(buildOrphanResourceBundle(it.next()));
				}
			}
		} else if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Skipping orphan file auto processing. ");
			if ("".equals(jawrConfig.getServletMapping()))
				LOGGER.debug("Note that there is no specified mapping for Jawr "
						+ "(it has been seet to serve *.js or *.css requests). "
						+ "The orphan files will become unreachable through the server.");
		}

		// Initialize bundle dependencies
		for (ResourceBundleDefinition definition : bundleDefinitionsWithDependencies) {
			JoinableResourceBundle bundle = getBundleFromName(definition.getBundleName(), resourceBundles);
			if (bundle != null) {
				bundle.setDependencies(getBundleDependencies(definition, resourceBundles));
			}
		}
	}
1075430
public void setBundleList(java.util.Collection<BundleDetails> bundleList) {
        if (bundleList == null) {
            this.bundleList = null;
            return;
        }

        this.bundleList = new java.util.ArrayList<BundleDetails>(bundleList);
    }
844974
@Override
	public int compare(JoinableResourceBundle bundleA, JoinableResourceBundle bundleB) {
		Integer a = bundleA.getInclusionPattern().getInclusionOrder();
		Integer b = bundleB.getInclusionPattern().getInclusionOrder();
		return a.compareTo(b);
	}
608765
@Override
    public void removedBundle(Bundle bundle, BundleEvent bundleEvent, List<BundleWebJarLib> webJarLibs) {
        removeWebJarLibs(webJarLibs);
    }
648981
protected function generateMacrosView(AbstractResourceBundle $bundle)
    {
        $path = $bundle->getPath() . '/Resources/views/' . $this->model . '/macros.html.twig';

        if (!file_exists($path)) {
            $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($this->bundle->getName()) . '\\' . $this->model;
            $metadata = $this->getEntityMetadata($entityClass);
            $identifier = $this->getContainer()->get('doctrine')
                ->getManager()
                ->getClassMetadata($entityClass)
                ->getIdentifier();

            $actions = array();
            array_map(function($key) use ($bundle, &$actions) {
                if (in_array($key, array('show', 'update'))) {
                    $actions[$key] = strtolower($this->getBundlePrefix($bundle) . '_' . $this->model . '_' . $key);
                }
            }, $this->configuration['actions']);

            $actions['delete'] = strtolower($this->getBundlePrefix($bundle) . '_' . $this->model . '_delete');

            $this->renderFile('crud/macros.html.twig.twig',
                $bundle->getPath() . '/Resources/views/' . $this->model . '/macros.html.twig',
                array(
                    'bundle'  => $bundle->getName(),
                    'model'   => $this->model,
                    'prefix'  => $this->getBundlePrefix($bundle),
                    'vars'    => strtolower(Inflector::pluralize($this->model)),
                    'identifier' => $identifier[0],
                    'fields'  => $this->getFieldsFromMetadata($metadata[0]),
                    'actions' => $actions
                )
            );
        }
    }
1026963
@Override
	public void streamBundleTo(String bundlePath, OutputStream out) throws ResourceNotFoundException {

		try {
			// byte[] gzip = gzipCache.get(bundlePath);
			byte[] gzip = (byte[]) cacheMgr.get(ZIP_CACHE_PREFIX + bundlePath);
			// If it's not cached yet
			if (null == gzip) {
				// Stream the stored data
				ByteArrayOutputStream baOs = new ByteArrayOutputStream();
				BufferedOutputStream bfOs = new BufferedOutputStream(baOs);
				rsHandler.streamBundleTo(bundlePath, bfOs);

				// Copy the data into the ByteBuffer
				bfOs.close();
				gzip = baOs.toByteArray();

				// Cache the byte array
				cacheMgr.put(ZIP_CACHE_PREFIX + bundlePath, gzip);
			}

			// Write bytes to the outputstream
			IOUtils.write(gzip, out);

		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException writing bundle[" + bundlePath + "]", e);
		}

	}
281553
protected function prepareTableRegistry(DOMElement $table, $bundle)
    {
        if (($tableName = $table->getAttribute('name')) !== '') {
            $tmpTableClass = null;
            if (!empty($tableClass = $table->getAttribute('tableClass'))) {
                $tmpTableClass = "'" . $tableClass . "'";
            }

            $tmpEntityClass = null;
            if (!empty($entityClass = $table->getAttribute('entityClass'))) {
                $tmpEntityClass = "'" . $entityClass . "'";
            }

            $tmpAlias = null;
            if (!empty($alias = $table->getAttribute('alias'))) {
                $tmpAlias = "'" . $alias . "'";
            }

            $code = <<<PHP
Cake\ORM\TableRegistry::config(
    '$bundle.$alias',
    [
        'table' => '$tableName',
        'alias' => $tmpAlias,
        'className' => $tmpTableClass,
        'entityClass' => $tmpEntityClass,
    ]
);
PHP;

            $this->tablesModel[$bundle][] = [
                'tableClass' => $tableClass,
                'entityClass' => $entityClass,
                'alias' => $alias
            ];
            $this->tableRegistryCode[$bundle][] = $code;
        }
    }
370809
public function checkSortableGroupField($sortableGroupField, $entity)
    {
        if (is_array($sortableGroupField)) {
            foreach ($sortableGroupField as $field) {
                $this->checkFieldEquals($this, $entity, $field);
            }
        } else {
            $this->checkFieldEquals($this, $entity, $sortableGroupField);
        }
    }
861398
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $finder = Finder::create()
            ->in($input->getArgument('baseDir'))
            ->name('GravitonDynBundleBundle.php');

        $files = iterator_to_array($finder);

        if (empty($files)) {
            throw new \LogicException('Could not locate BundleBundle source file.');
        }

        $bundleFile = array_pop($files);
        $bundleFilePath = $bundleFile->getPathname();
        $content = file_get_contents($bundleFilePath);

        $contentData = $this->getContentData($content);
        // if something not found, we do nothing
        if ($contentData['startStringPos'] === false || $contentData['endStringPos'] === false) {
            return;
        }

        $bundleList = explode(',', $contentData['bundleList']);
        if (empty($bundleList)) {
            return;
        }

        $newBundleList = $this->filterBundleList($bundleList);

        // all the same? don't do anything..
        if (count($bundleList) == count($newBundleList)) {
            return;
        }

        $output->writeln(
            'Writing new DynBundleBundle file, now at '.count($newBundleList).
            ' bundles, before we had '.count($bundleList)
        );

        file_put_contents(
            $bundleFilePath,
            $this->getNewContent($content, $newBundleList)
        );
    }
965170
private void addBundle(String baseName, Locale locale, I_CmsResourceBundle bundle) {

        CmsResourceBundleLoader.addBundleToCache(baseName, locale, bundle);
    }