<commit_before><?php
namespace TYPO3\Flow\Resource;

/*                                                                        *
 * This script belongs to the TYPO3 Flow framework.                       *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

use Doctrine\ORM\Mapping as ORM;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Log\SystemLoggerInterface;
use TYPO3\Flow\Object\ObjectManagerInterface;
use TYPO3\Flow\Persistence\PersistenceManagerInterface;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Resource\Storage\StorageInterface;
use TYPO3\Flow\Resource\Storage\WritableStorageInterface;
use TYPO3\Flow\Resource\Streams\StreamWrapperAdapter;
use TYPO3\Flow\Resource\Target\TargetInterface;
use TYPO3\Flow\Utility\Unicode\Functions as UnicodeFunctions;

/**
 * The Resource Manager
 *
 * @Flow\Scope("singleton")
 * @api
 */
class ResourceManager {

	/**
	 * Names of the default collections for static and persistent resources.
	 */
	const DEFAULT_STATIC_COLLECTION_NAME = 'static';
	const DEFAULT_PERSISTENT_COLLECTION_NAME = 'persistent';

	/**
	 * @Flow\Inject
	 * @var ObjectManagerInterface
	 */
	protected $objectManager;

	/**
	 * @Flow\Inject
	 * @var SystemLoggerInterface
	 */
	protected $systemLogger;

	/**
	 * @Flow\Inject
	 * @var ResourceRepository
	 */
	protected $resourceRepository;

	/**
	 * @Flow\Inject
	 * @var PersistenceManagerInterface
	 */
	protected $persistenceManager;

	/**
	 * @Flow\Inject
	 * @var \Doctrine\Common\Persistence\ObjectManager
	 */
	protected $entityManager;

	/**
	 * @var array
	 */
	protected $settings;

	/**
	 * @var \SplObjectStorage
	 */
	protected $importedResources;

	/**
	 * @Flow\Inject
	 * @var \TYPO3\Flow\Utility\Environment
	 */
	protected $environment;

	/**
	 * @var array<\TYPO3\Flow\Resource\Storage\StorageInterface>
	 */
	protected $storages;

	/**
	 * @var array<\TYPO3\Flow\Resource\Target\TargetInterface>
	 */
	protected $targets;

	/**
	 * @var array<\TYPO3\Flow\Resource\CollectionInterface>
	 */
	protected $collections;

	/**
	 * Injects the settings of this package
	 *
	 * @param array $settings
	 * @return void
	 */
	public function injectSettings(array $settings) {
		$this->settings = $settings;
	}

	/**
	 * Initializes the Resource Manager by parsing the related configuration and registering the resource
	 * stream wrapper.
	 *
	 * @return void
	 */
	public function initialize() {
		$this->initializeStreamWrapper();
		$this->initializeStorages();
		$this->initializeTargets();
		$this->initializeCollections();

		$this->importedResources = new \SplObjectStorage();
	}

	/**
	 * Imports a resource (file) from the given location as a persistent resource.
	 *
	 * On a successful import this method returns a Resource object representing the
	 * newly imported persistent resource and automatically publishes it to the configured
	 * publication target.
	 *
	 * @param string | resource $source A URI (can therefore also be a path and filename) or a PHP resource stream(!) pointing to the Resource to import
	 * @param string $collectionName Name of the collection this new resource should be added to. By default the standard collection for persistent resources is used.
	 * @param string $forcedPersistenceObjectIdentifier INTERNAL: Force the object identifier for this resource to the given UUID
	 * @return \TYPO3\Flow\Resource\Resource A resource object representing the imported resource
	 * @throws Exception
	 * @api
	 */
	public function importResource($source, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = NULL) {
		if (!isset($this->collections[$collectionName])) {
			throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1375196643);
		}

		/* @var CollectionInterface $collection */
		$collection = $this->collections[$collectionName];

		try {
			$resource = $collection->importResource($source);
			if ($forcedPersistenceObjectIdentifier !== NULL) {<commit_msg>[TASK] Remove unused injection of Doctrine EntityManager<commit_after><?php
namespace TYPO3\Flow\Resource;

/*                                                                        *
 * This script belongs to the TYPO3 Flow framework.                       *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

use Doctrine\ORM\Mapping as ORM;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Log\SystemLoggerInterface;
use TYPO3\Flow\Object\ObjectManagerInterface;
use TYPO3\Flow\Persistence\PersistenceManagerInterface;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Resource\Storage\StorageInterface;
use TYPO3\Flow\Resource\Storage\WritableStorageInterface;
use TYPO3\Flow\Resource\Streams\StreamWrapperAdapter;
use TYPO3\Flow\Resource\Target\TargetInterface;
use TYPO3\Flow\Utility\Unicode\Functions as UnicodeFunctions;

/**
 * The Resource Manager
 *
 * @Flow\Scope("singleton")
 * @api
 */
class ResourceManager {

	/**
	 * Names of the default collections for static and persistent resources.
	 */
	const DEFAULT_STATIC_COLLECTION_NAME = 'static';
	const DEFAULT_PERSISTENT_COLLECTION_NAME = 'persistent';

	/**
	 * @Flow\Inject
	 * @var ObjectManagerInterface
	 */
	protected $objectManager;

	/**
	 * @Flow\Inject
	 * @var SystemLoggerInterface
	 */
	protected $systemLogger;

	/**
	 * @Flow\Inject
	 * @var ResourceRepository
	 */
	protected $resourceRepository;

	/**
	 * @Flow\Inject
	 * @var PersistenceManagerInterface
	 */
	protected $persistenceManager;

	/**
	 * @var array
	 */
	protected $settings;

	/**
	 * @Flow\Inject
	 * @var \TYPO3\Flow\Utility\Environment
	 */
	protected $environment;

	/**
	 * @var array<\TYPO3\Flow\Resource\Storage\StorageInterface>
	 */
	protected $storages;

	/**
	 * @var array<\TYPO3\Flow\Resource\Target\TargetInterface>
	 */
	protected $targets;

	/**
	 * @var array<\TYPO3\Flow\Resource\CollectionInterface>
	 */
	protected $collections;

	/**
	 * Injects the settings of this package
	 *
	 * @param array $settings
	 * @return void
	 */
	public function injectSettings(array $settings) {
		$this->settings = $settings;
	}

	/**
	 * Initializes the Resource Manager by parsing the related configuration and registering the resource
	 * stream wrapper.
	 *
	 * @return void
	 */
	public function initialize() {
		$this->initializeStreamWrapper();
		$this->initializeStorages();
		$this->initializeTargets();
		$this->initializeCollections();
	}

	/**
	 * Imports a resource (file) from the given location as a persistent resource.
	 *
	 * On a successful import this method returns a Resource object representing the
	 * newly imported persistent resource and automatically publishes it to the configured
	 * publication target.
	 *
	 * @param string | resource $source A URI (can therefore also be a path and filename) or a PHP resource stream(!) pointing to the Resource to import
	 * @param string $collectionName Name of the collection this new resource should be added to. By default the standard collection for persistent resources is used.
	 * @param string $forcedPersistenceObjectIdentifier INTERNAL: Force the object identifier for this resource to the given UUID
	 * @return \TYPO3\Flow\Resource\Resource A resource object representing the imported resource
	 * @throws Exception
	 * @api
	 */
	public function importResource($source, $collectionName = ResourceManager::DEFAULT_PERSISTENT_COLLECTION_NAME, $forcedPersistenceObjectIdentifier = NULL) {
		if (!isset($this->collections[$collectionName])) {
			throw new Exception(sprintf('Tried to import a file into the resource collection "%s" but no such collection exists. Please check your settings and the code which triggered the import.', $collectionName), 1375196643);
		}

		/* @var CollectionInterface $collection */
		$collection = $this->collections[$collectionName];

		try {
			$resource = $collection->importResource($source);
			if ($forcedPersistenceObjectIdentifier !== NULL) {
{'fraction_non_alphanumeric': 0.09608540925266904, 'fraction_numerical': 0.0064501779359430605, 'mean_word_length': 2.9547053649956023, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2978739', 'n_tokens_mistral': 2464, 'n_tokens_neox': 2280, 'n_words': 714}