@param Dropzone $dropzone

@return array
768392
public function serialize(Dropzone $dropzone)
    {
        return [
            'id' => $dropzone->getUuid(),
            'instruction' => $dropzone->getInstruction(),
            'parameters' => $this->serializeParameters($dropzone),
            'display' => $this->serializeDisplay($dropzone),
            'planning' => $this->serializePlanning($dropzone),
            'notifications' => $this->serializeNotifications($dropzone),
        ];
    }
53320
private function isDropzoneDropTimeIsUp(Dropzone $dropzone)
    {
        $dropDatePassed = false;
        if ($dropzone->getAutoCloseOpenedDropsWhenTimeIsUp() && false === $dropzone->getManualPlanning()) {
            $now = new \DateTime();
            $dropDatePassed = $now->getTimestamp() > $dropzone->getEndAllowDrop()->getTimeStamp();
        }

        return $dropDatePassed;
    }
439634
protected function getDropdownValues()
    {
        if ($source = array_get($this->field->options(), 'value_source')) {

            $values = $this->getDropdownValuesFromSource($source);

            if (false !== $values) {
                return $values;
            }
        }

        return array_get($this->field->options(), 'values', []);
    }
1178455
public function getSubFormsByZone($formChildren, $zone)
    {
        $zones = [];

        foreach ($formChildren as $subForms) {
            if ($this->getFormFieldZone($subForms) == $zone) {
                $zones[] = $subForms;
            }
        }

        return $zones;
    }
503012
private function getDroppedTables(Schema $oldSchema, Schema $newSchema)
    {
        $droppedTables = array();

        foreach ($oldSchema->getTables() as $table) {
            if (!$newSchema->hasTable($table->getName())) {
                $droppedTables[] = $table;
            }
        }

        return $droppedTables;
    }
1167681
public function checkSuccess(Drop $drop)
    {
        $this->om->startFlushSuite();

        $dropzone = $drop->getDropzone();
        $users = [$drop->getUser()];

        if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) {
            $users = $drop->getUsers();
        }
        $computeStatus = $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedDrop());

        if (!$computeStatus) {
            $nbValidCorrections = 0;
            $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal();
            $corrections = $drop->getCorrections();

            foreach ($corrections as $correction) {
                if ($correction->isFinished() && $correction->isValid()) {
                    ++$nbValidCorrections;
                }
            }
            $computeStatus = $nbValidCorrections >= $expectedCorrectionTotal;
        }
        if ($computeStatus) {
            $score = $drop->getScore();
            $scoreToPass = $dropzone->getScoreToPass();
            $scoreMax = $dropzone->getScoreMax();
            $status = !empty($scoreMax) && (($score / $scoreMax) * 100) >= $scoreToPass ?
                AbstractResourceEvaluation::STATUS_PASSED :
                AbstractResourceEvaluation::STATUS_FAILED;

            foreach ($users as $user) {
                $this->resourceEvalManager->createResourceEvaluation(
                    $dropzone->getResourceNode(),
                    $user,
                    null,
                    [
                        'status' => $status,
                        'score' => $score,
                        'scoreMax' => $scoreMax,
                        'data' => $this->serializeDrop($drop),
                    ],
                    ['status' => true, 'score' => true]
                );
            }

            $this->eventDispatcher->dispatch('log', new LogDropEvaluateEvent($dropzone, $drop, $drop->getScore()));

            //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected
        }

        $this->om->endFlushSuite();
    }
1305382
public function closeAllUnfinishedDrops(Dropzone $dropzone)
    {
        $this->om->startFlushSuite();

        $currentDate = new \DateTime();
        $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'finished' => false]);

        /** @var Drop $drop */
        foreach ($drops as $drop) {
            $drop->setFinished(true);
            $drop->setDropDate($currentDate);
            $drop->setAutoClosedDrop(true);
            $this->om->persist($drop);
        }
        $dropzone->setDropClosed(true);
        $this->om->persist($dropzone);

        $this->om->endFlushSuite();
    }
256189
public static function getCodeFromTimezone($sTimezone)
    {
        $aAbbreviations = \DateTimeZone::listAbbreviations();
        foreach ($aAbbreviations as $sCode => $aValues) {
            foreach ($aValues as $aValue) {
                if ($aValue['timezone_id'] == $sTimezone) {
                    return strtoupper($sCode);
                }
            }
        }

        return false;
    }
593960
protected function getDropdownValuesFromSource($source)
    {
        if (is_a($source, Enum::class, true)) {
            /** @var Enum $source */
            return array_map(
                function ($value) { return (string) $value; },
                $source::values()
            );
        }

        if (is_a($source, DropdownStrategyInterface::class, true)) {
            /** @var DropdownStrategyInterface $source */
            $source = app($source);
            return $source->values();
        }

        return false;
    }
1372663
public function dueEvents(\DateTimeZone $timeZone)
    {
        return \array_filter(
            $this->events,
            function (Event $event) use ($timeZone) {
                return $event->isDue($timeZone);
            }
        );
    }
994
private function getZoneOptions(\stdClass $zone)
    {
        $options = array(
            'parameters' => array(
                'class' => array(
                    'type' => 'scalar',
                    'options' => array('default' => 'row'),
                ),
            ),
        );

        if (true === property_exists($zone, 'accept')
                && true === is_array($zone->accept)
                && 0 < count($zone->accept)
                && $zone->accept[0] != '') {
            $options['accept'] = $zone->accept;

            $func = function (&$item, $key) {
                        $item = ('' == $item) ? null : 'BackBee\ClassContent\\'.$item;
                    };

            array_walk($options['accept'], $func);
        }

        if (true === property_exists($zone, 'maxentry') && 0 < $zone->maxentry) {
            $options['maxentry'] = $zone->maxentry;
        }

        return $options;
    }
804818
public static function fillOutZone(Zone $zone)
    {
        $class = $zone->getClass();

        foreach ($zone as &$rr) {
            $rr->setName(self::fullyQualify($rr->getName(), $zone->getName()));
            $rr->setTtl($rr->getTtl() ?? $zone->getDefaultTtl());
            $rr->setClass($class);
            $rdata = $rr->getRdata();

            if ($rdata instanceof SOA) {
                $rdata->setMname(self::fullyQualify($rdata->getMname(), $zone->getName()));
                $rdata->setRname(self::fullyQualify($rdata->getRname(), $zone->getName()));
            }

            if ($rdata instanceof CNAME) {
                $rdata->setTarget(self::fullyQualify($rdata->getTarget(), $zone->getName()));
            }

            if ($rdata instanceof MX) {
                $rdata->setExchange(self::fullyQualify($rdata->getExchange(), $zone->getName()));
            }

            if ($rdata instanceof AAAA) {
                $rdata->setAddress(Toolbox::expandIpv6($rdata->getAddress()));
            }
        }
    }
1141161
public function render()
    {
        $dropzoneAttributes = array_diff_key($this->field->attributes, array_flip(['class']));

        if (!isset($dropzoneAttributes['container'])) {
            throw new RuntimeException('Invalid Dropzone Container Id');
        }
        $this->field->attributes = ['class' => $this->field->attributes['class']];

        $id             = $dropzoneAttributes['container'];
        $view           = isset($dropzoneAttributes['view']) ? $dropzoneAttributes['view'] : 'antares/foundation::widgets.forms.dropzone';
        $name           = $dropzoneAttributes['paramName'];
        $successDefault = <<<CBALL
        this.on("success", function(file,response) {        
            $('#$id').parent().find('input[name=$name]').val(response.path);
            %s 
            %s    
        }); 
CBALL;
        $afterLoad      = isset($dropzoneAttributes['previewsContainer']) ? $this->onSuccessDefault($id) : '';
        $onSuccess      = isset($dropzoneAttributes['onSuccess']) ? $dropzoneAttributes['onSuccess'] : '';
        $afterUpload    = sprintf($successDefault, $afterLoad, $onSuccess);


        $params = array_merge([
            'autoProcessQueue' => true,
            'uploadMultiple'   => false,
            'maxFiles'         => 100,
            'thumbnailWidth'   => 120,
            'thumbnailHeight'  => 120,
            'parallelUploads'  => 20,
            'init'             => new JavaScriptExpression(sprintf($this->onInit($dropzoneAttributes), $afterUpload))], $dropzoneAttributes);


        $cball        = <<<CBALL
(function(window,$){Dropzone.autoDiscover = false; Dropzone.options.%s = %s; %s })(window,jQuery);

CBALL;
        $attach       = <<<CBALL
                     $('#{$id}').dropzone(Dropzone.options.$id);
CBALL;
        $inlineScript = sprintf($cball, $id, JavaScriptDecorator::decorate(array_except($params, ['view', 'container', 'onSuccess'])), $attach);
        $this->asset->container('antares/foundation::scripts')->inlineScript('dropzone-' . $id, $inlineScript);
        $attributes   = $this->html->decorate($this->field->get('attributes'), ['class' => 'form-control']);
        $input        = $this->form->input('hidden', $params['paramName'], $this->field->get('value'), ['id' => $id . 'Container']);
        return view($view, ['field' => $this->field, 'attributes' => $attributes, 'params' => $params, 'input' => $input, 'id' => $id]);
    }
118818
protected function isAllow(Dropzone $dropzone, $actionName)
    {
        $collection = new ResourceCollection([$dropzone->getResourceNode()]);

        if (false === $this->container->get('security.authorization_checker')->isGranted($actionName, $collection)) {
            throw new AccessDeniedException();
        }
    }
490750
public function getEmailTemplateDropdownValues()
    {
        $templates = [];

        $finder = new FileFinder();
        $finder->setOption('name_regex', '/^.*\.ss$/');

        $parent = $this->getFormParent();

        if (!$parent) {
            return [];
        }

        $emailTemplateDirectory = $parent->config()->get('email_template_directory');
        $templateDirectory = ModuleResourceLoader::resourcePath($emailTemplateDirectory);

        if (!$templateDirectory) {
            return [];
        }

        $found = $finder->find(BASE_PATH . DIRECTORY_SEPARATOR . $templateDirectory);

        foreach ($found as $key => $value) {
            $template = pathinfo($value);
            $absoluteFilename = $template['dirname'] . DIRECTORY_SEPARATOR . $template['filename'];

            // Optionally remove vendor/ path prefixes
            $resource = ModuleResourceLoader::singleton()->resolveResource($emailTemplateDirectory);
            if ($resource instanceof ModuleResource && $resource->getModule()) {
                $prefixToStrip = $resource->getModule()->getPath();
            } else {
                $prefixToStrip = BASE_PATH;
            }
            $templatePath = substr($absoluteFilename, strlen($prefixToStrip) + 1);

            // Optionally remove "templates/" prefixes
            if (preg_match('/(?<=templates\/).*$/', $templatePath, $matches)) {
                $templatePath = $matches[0];
            }

            $templates[$templatePath] = $template['filename'];
        }

        return $templates;
    }
1244036
protected function dropzoneAttributes($url)
    {

        $init      = new JavaScriptExpression($this->init('translationImport'));
        $validator = app(CsvValidator::class);
        $rules     = $this->getValidationRules('file', $validator);
        return [
            'container'     => 'translationImport',
            'paramName'     => 'file',
            'view'          => 'antares/translations::admin.partials._dropzone',
            'url'           => $url,
            'maxFiles'      => 1,
            'acceptedFiles' => '.csv',
            'init'          => $init] + $rules;
    }
855145
protected function convertZoneToHash(Zone $zone)
    {
        $hash = array();

        foreach ($zone->getState() as $propName => $propValue) {
            switch ($propName) {
                case 'id':
                case 'identifier':
                case 'action':
                    if ($propValue !== null) {
                        $hash[$propName] = $propValue;
                    }
                    break;
                case 'attributes':
                    if ($propValue !== null && $propValue !== array()) {
                        $hash['attributes'] = $propValue;
                    }
                    break;
                case 'blocks':
                    foreach ($propValue as $block) {
                        $hash['blocks'][] = $this->convertBlockToHash($block);
                    }
                    break;
            }
        }

        return $hash;
    }