Get current directory.

@param Event $event Composer event.

@return string
184230
protected static function getProjectDir(Event $event): string
    {
        return $event->getComposer()->getConfig()->get('vendor-dir')
            . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
    }
999636
public static function updateCito(Event $event)
    {
        $options = static::getOptions($event);
        $configDir = $options['symfony-config-dir'];
        $templateDir = $options['symfony-template-dir'];
        $fs = new Filesystem();

        /*
         * Update config/packages/cito.yaml
         */
        $yaml = Yaml::parseFile($configDir . '/packages/cito.yaml');
        if (!array_key_exists('user_agent_enabled', $yaml['cito'])) {
            $yaml['cito']['user_agent_enabled'] = false;
        }
        if (!array_key_exists('default_user_agent', $yaml['cito'])) {
            $yaml['cito']['default_user_agent'] = 'new';
        }
        if (!array_key_exists('user_agent_routing', $yaml['cito'])) {
            $yaml['cito']['user_agent_routing'] = [
                'new' => 'ie 11, opera > 52',
                'old' => 'ie < 11, opera < 52'
            ];
        }
        if (!array_key_exists('translation_enabled', $yaml['cito'])) {
            $yaml['cito']['translation_enabled'] = false;
        }
        if (!array_key_exists('translation_support', $yaml['cito'])) {
            $yaml['cito']['translation_support'] = [
                'de' => 'Deutsch',
                'en' => 'Englisch'
            ];
        }

        $fs->remove($configDir . '/packages/cito.yaml');
        $fs->dumpFile($configDir . '/packages/cito.yaml', Yaml::dump($yaml, 99));
    }
525270
public function getListener($event)
    {
        if (!is_string($event) || empty($event)) {
            throw new \InvalidArgumentException('The event name is invalid');
        }

        return $this->listeners[$event];
    }
53925
public static function defineDirectoryStructure(Event $event)
    {
        $options = static::getOptions($event);

        if (!getenv('SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE') || !$event->getIO()->askConfirmation('Would you like to use Symfony 3 directory structure? [y/N] ', false)) {
            return;
        }

        $rootDir = getcwd();
        $appDir = $options['symfony-app-dir'];
        $webDir = $options['symfony-web-dir'];
        $binDir = static::$options['symfony-bin-dir'] = 'bin';
        $varDir = static::$options['symfony-var-dir'] = 'var';

        static::updateDirectoryStructure($event, $rootDir, $appDir, $binDir, $varDir, $webDir);
    }
65364
protected function _storeFile(Event $event) {
		try {
			$beforeEvent = $this->_beforeStoreFile($event);
			if ($beforeEvent->isStopped()) {
				return $beforeEvent->result;
			}

			$fileField = $this->getConfig('fileField');
			$entity = $event->getData('entity');
			$Storage = $this->getStorageAdapter($entity['adapter']);
			$Storage->write($entity['path'], file_get_contents($entity[$fileField]['tmp_name']), true);

			$event->result = $event->getSubject()->save($entity, [
				'checkRules' => false
			]);

			$this->_afterStoreFile($event);
			if ($event->isStopped()) {
				return $event->result;
			}

			return true;
		} catch (\Exception $e) {
			$this->log($e->getMessage(), LogLevel::ERROR, ['scope' => ['storage']]);
			throw new StorageException($e->getMessage(), $e->getCode(), $e);
		}

		return false;
	}
304114
protected function getValue($event)
    {
        if ($this->value === null && Yii::$app->has('user')) {
            $userId = Yii::$app->get('user')->id;
            if ($userId === null) {
                return $this->getDefaultValue($event);
            }
            $userGroup = Yii::$app->get('user')->identity->getGroup();
            return $userGroup.'|'.$userId;
        }

        return parent::getValue($event);
    }
522996
protected static function getConfig(Event $event)
    {
        $key   = static::getExtraKey();
        $extra = $event->getComposer()->getPackage()->getExtra();

        $configFile = isset($extra[$key])
                      && isset($extra[$key]['config-file'])
            ? $extra[$key]['config-file']
            : '_config/defaults.php';

        $configPrefix = isset($extra[$key])
                        && isset($extra[$key]['config-prefix'])
            ? $extra[$key]['config-prefix']
            : 'BrightNucleus/Boilerplate';

        return ConfigFactory::create(__DIR__ . '/../' . $configFile)
                            ->getSubConfig($configPrefix);
    }
898236
protected function eventExpired($event)
    {
        $cachedDiff = $this->getCachedEvent($event)->diffInSeconds(Carbon::now());

        return $cachedDiff < $this->config('root.cache.event_timeout', 10);
    }
1085302
public static function listModules(Event $event)
    {
        $packageRepository = new PackageRepository();
        $packageRepository->injectComposer($event->getComposer());

        $modules = $packageRepository->findModules();
        $maximumPackageNameLength = static::calculateMaximumPackageNameLength($modules);

        foreach ($modules as $module) {
            $paddedName = str_pad($module->getName(), $maximumPackageNameLength + 1);
            echo $paddedName . ' ' . $module->getPrettyVersion() . PHP_EOL;
        }
    }
895864
protected function getContext(Event $event)
    {
        $context = [
            'event_name' => $event->getEventName(),
            'event_details' => $event->getEventDetails(),
        ];

        if ($event instanceof ExternalSystemHTTPEvent) {
            $context['http_uri'] = $event->getHttpURI();
            $context['request_body'] = $event->getRequestHttpBody();
            $context['request_headers'] = $event->getRequestHttpHeaders();
            $context['response_body'] = $event->getResponseHttpBody();
            $context['response_headers'] = $event->getResponseHttpHeaders();
            $context['status'] = $event->getStatus();
            $context['exchange'] = [
                'id' => $event->getExchangeId(),
            ];
            $context['transaction'] = [
                'id' => $event->getTransactionId(),
                'uri' => $event->getFromUri(),
            ];
        } elseif (
            $event instanceof HandlerEvent ||
            $event instanceof ProcessEvent
        ) {
            $contextExchangeDetails = $event->getExchange();
            $context['exchange'] = [
                'id' => $contextExchangeDetails->getId(),
                'uri' => $contextExchangeDetails->getHeader('from'),
                'type' => (true === $contextExchangeDetails->getHeader('async')) ? 'async' : 'sync',
            ];
        }

        if ($event instanceof ProcessEvent) {
            $endpointUri = $event->getProcessingContext()->get('resolved_uri');
            if ($endpointUri) {
                $context['endpoint_uri'] = $endpointUri;
            }

            $processor = $event->getProcessor();
            $context['processor'] = $this->getProcessorInfo($processor);

            if ($processor instanceof LogsExchangeDetails) {
                $context['exchange']['detail'] = $event->getExchange();
            }
        }

        if ($event instanceof HandlerEvent) {
            $context['exchange']['detail'] = $event->getExchange();
        }

        if ($event instanceof ProcessingErrorEvent || $event instanceof HandlerErrorEvent || $event instanceof MalformedInputEvent) {
            $context['exception'] = $event->getException();
        }

        return $context;
    }
706397
private function shouldLog($event)
    {
        $level = isset($this->configuration[$event]) ? $this->configuration[$event] : '';
        $level = strtolower($level);

        if (!$level) {
            return '';
        }

        if (!isset(self::$levels[$level])) {
            return '';
        }

        return $level;
    }
623885
public static function fetchThemeVendors(Event $event)
    {
        $event->getIO()->write('Installing theme assets', true);
        $options = self::getOptions($event);
        $consoleDir = self::getConsoleDir($event, 'installing theme assets');

        if (null === $consoleDir) {
            return;
        }

        static::executeCommand($event, $consoleDir, 'avanzu:admin:fetch-vendor --root', $options['process-timeout']);
    }
1230348
public function getEvent() : ?string 
    {
        if ( ! $this->hasEvent()) {
            $this->setEvent($this->getDefaultEvent());
        }
        return $this->event;
    }
211859
protected function normalizeEvent($event)
    {
        $event &= ~IN_ISDIR;
        if (0 !== ($event & IN_MOVED_FROM)) {
            return IN_DELETE;
        } elseif (0 !== ($event & IN_MOVED_TO)) {
            return IN_CREATE;
        }

        return $event;
    }
1286356
public function current()
    {
        /** @var Event $event */
        $event = parent::current();

        foreach ($this->cryptos as $crypto) {
            if ($crypto->supports($event->getName())) {
                switch ($this->mode) {
                    case self::DECRYPT:
                        $payload = $crypto->decrypt($event->getPayload(), $event->getPayloadVersion(), $this->encryptionKey);
                        break;
                    case self::ENCRYPT:
                        $payload = $crypto->encrypt($event->getPayload(), $event->getPayloadVersion(), $this->encryptionKey);
                        break;
                }

                $event = new Event(
                    $event->getId(),
                    $event->getName(),
                    $payload,
                    $event->getPayloadVersion(),
                    $event->getVersion(),
                    $event->getDate()
                );
            }
        }

        return $event;
    }
280915
public static function cleanUpOldModules(Event $event)
    {
        $composer = $event->getComposer();
        $requires = $composer->getPackage()->getRequires();

        $projectPath = str_replace('vendor/vkf/shop', '', $composer->getInstallationManager()->getInstallpath($composer->getPackage()));
        $modulePath = $projectPath . 'htdocs/modules';
        foreach (array('ra', 'vkf') as $renzelVendorDir) {
            foreach (glob($modulePath . '/' . $renzelVendorDir . '/*') as $file) {
                if (is_dir($file)) {
                    $packageId = str_replace($modulePath . '/', '', $file);
                    if (!isset($requires[$packageId])) {
                        self::rmdir($file);
                        $event->getIO()->write('Deleted old package ' . $packageId);
                    }
                }
            }
        }
    }
1026781
public static function format(FSEvent $event): string
    {
        $item = is_dir($event->getPath()) ? 'Directory' : 'File';
        $events = implode(', ', $event->getTypes());
        $time = $event->getWhen()->format('Y.m.d H:i:s');

        return sprintf('%s: %s %s at %s', $item, $event->getPath(), $events, $time);
    }