Annotate files from plugin configuration
@param backup_nested_element $assign the backup structure of the activity
@param string $subtype the plugin type to handle
@return void
349037
protected function annotate_plugin_config_files(backup_nested_element $assign, $subtype) {
        $dummyassign = new assign(null, null, null);
        $plugins = $dummyassign->load_plugins($subtype);
        foreach ($plugins as $plugin) {
            $component = $plugin->get_subtype() . '_' . $plugin->get_type();
            $areas = $plugin->get_config_file_areas();
            foreach ($areas as $area) {
                $assign->annotate_files($component, $area, null);
            }
        }
    }
1286008
private function addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass)
    {
        if ($subClass->isEmbeddedDocument) {
            return;
        }

        $indexFactory = new IndexFactory($subClass);
        $parentIndex  = $parentClass->getIndex();

        if ($parentIndex !== null) {
            $index = $indexFactory->createInherited($parentIndex);
            $subClass->setIndex($index);
        }

        foreach ($parentClass->getSecondaryIndexes() as $parentIndex) {
            $index = $indexFactory->createInherited($parentIndex);
            $subClass->addSecondaryIndex($index);
        }
    }
864574
public function processList($list, $subListType = 'ul')
    {
        $out = '';

        foreach ($list as $key => $value) {
            if (is_array($value) && (isset($value['list']) || isset($value['attr']))) {
                $attr = (isset($value['attr'])) ? $value['attr'] : null;
                $listAttr = (isset($value['listAttr'])) ? $value['listAttr'] : null;
                $subList = (isset($value['list'])) ? $this->{$subListType}($value['list'], $listAttr) : '';

                $out .= $this->tag('li', $attr, $key . $subList, true);
            } elseif (is_array($value)) {
                $out .= $this->tag('li', null, $key . $this->{$subListType}($value), true);
            } else {
                $out .= $this->tag('li', null, $value, true);
            }
        }

        return $out;
    }
1242239
public function assignElementToSubShop($sElementTable, $sShopId, $sElementId)
    {
        /** @var BaseModel $oBase */
        $oBase = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
        $oBase->init($sElementTable);
        if ($oBase->load($sElementId)) {
            /** @var \OxidEsales\Eshop\Core\Element2ShopRelations $oElement2ShopRelations */
            $oElement2ShopRelations = oxNew(\OxidEsales\Eshop\Core\Element2ShopRelations::class, $sElementTable);
            $oElement2ShopRelations->setShopIds($sShopId);
            $oElement2ShopRelations->addToShop($oBase->getId());
        }
    }
1219256
public function createFileSystem($id, $subPath = null)
    {
        $path = $this->getOption(self::OPTION_FILE_PATH).
            (is_null($subPath) ? \helpers_File::sanitizeInjectively($id) : ltrim($subPath, '/'));
        $adapters = $this->hasOption(self::OPTION_ADAPTERS) ? $this->getOption(self::OPTION_ADAPTERS) : array();
        $adapters[$id] = array(
            'class' => self::FLYSYSTEM_LOCAL_ADAPTER,
            'options' => array('root' => $path)
        );
        $this->setOption(self::OPTION_ADAPTERS, $adapters);
        return $this->getFileSystem($id);
    }
946509
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
    {
        foreach ($parentClass->fieldMappings as $fieldName) {
            $subClass->mapField($parentClass->mappings[$fieldName], $parentClass);
        }
        foreach ($parentClass->referenceMappings as $fieldName) {
            $mapping = $parentClass->mappings[$fieldName];
            if ($mapping['type'] == ClassMetadata::MANY_TO_ONE) {
                $subClass->mapManyToOne($mapping, $parentClass);
            } else {
                $subClass->mapManyToMany($mapping, $parentClass);
            }
        }
        foreach ($parentClass->childMappings as $fieldName) {
            $mapping = $parentClass->mappings[$fieldName];
            $subClass->mapChild($mapping, $parentClass);
        }
        foreach ($parentClass->childrenMappings as $fieldName) {
            $subClass->mapChildren($parentClass->mappings[$fieldName], $parentClass);
        }
        foreach ($parentClass->referrersMappings as $fieldName) {
            $subClass->mapReferrers($parentClass->mappings[$fieldName], $parentClass);
        }
        if ($parentClass->identifier) {
            $subClass->mapId($parentClass->mappings[$parentClass->identifier], $parentClass);
        }
        if ($parentClass->node) {
            $subClass->mapNode($parentClass->mappings[$parentClass->node], $parentClass);
        }
        if ($parentClass->nodename) {
            $subClass->mapNodename($parentClass->mappings[$parentClass->nodename], $parentClass);
        }
        if ($parentClass->parentMapping) {
            $subClass->mapParentDocument($parentClass->mappings[$parentClass->parentMapping], $parentClass);
        }
        if ($parentClass->localeMapping) {
            $subClass->mapLocale($parentClass->mappings[$parentClass->localeMapping], $parentClass);
        }
        if ($parentClass->depthMapping) {
            $subClass->mapDepth($parentClass->mappings[$parentClass->depthMapping], $parentClass);
        }
        if ($parentClass->versionNameField) {
            $subClass->mapVersionName($parentClass->mappings[$parentClass->versionNameField], $parentClass);
        }
        if ($parentClass->versionCreatedField) {
            $subClass->mapVersionCreated($parentClass->mappings[$parentClass->versionCreatedField], $parentClass);
        }
        if ($parentClass->lifecycleCallbacks) {
            $subClass->mapLifecycleCallbacks($parentClass->lifecycleCallbacks);
        }

        $subClass->setReferenceable($parentClass->referenceable);

        // Versionable defaults to false - only set on child class if it is non-false
        if ($parentClass->versionable) {
            $subClass->setVersioned($parentClass->versionable);
        }

        $subClass->setTranslator($parentClass->translator);
        $subClass->setNodeType($parentClass->nodeType);
        $subClass->setCustomRepositoryClassName($parentClass->customRepositoryClassName);
    }
722145
private function publishClasses($register, $subfolder)
    {
        // read middleware from folder
        $path = $this->path . '/src/' . $subfolder;
        if (!file_exists($path)) {
            return;
        }

        $classes = [];
        $ns = $this->namespace . $subfolder;
        list_classes($classes, $path, $ns);

        // update manifest

        $manifest = $this->getManifest(lcfirst($subfolder));
        /** @noinspection PhpIncludeInspection */
        $list = file_exists($manifest) ? include $manifest : [];
        $len = strlen($ns);
        foreach ($classes as $class) {
            if (strpos($class, '\\Contracts\\') !== false) {
                continue; // contracts
            }
            $name = substr($class, $len + 1);
            if ($register) {
                if (!isset($list[$name])) {
                    $list[$name] = [];
                }
                if (($i = array_search($class, $list[$name])) === false) {
                    $list[$name][] = $class;
                }
            }
            else {
                if (isset($list[$name]) && ($i = array_search($class, $list[$name])) !== false) {
                    unset($list[$name][$i]);
                    if (empty($list[$name])) {
                        unset($list[$name]);
                    }
                    else {
                        $list[$name] = array_values($list[$name]);
                    }
                }
            }
        }

        $this->saveArray($manifest, $list);
    }
1175306
public void addSubtype(String subtype) {
    if(!StringUtils.isBlank(subtype) && !subtypes.contains(subtype.trim())) {
      subtypes.add(subtype.trim());
    }
  }
1025699
def save_subresource(self, subresource):
        
        data = deepcopy(subresource._resource)
        data.pop('id', None)
        data.pop(self.resource_type + '_id', None)

        subresources = getattr(self, subresource.parent_key, {})
        subresources[subresource.id] = data
        setattr(self, subresource.parent_key, subresources)

        yield self._save()
235541
public function init(Request $request, $postType, $id, $subPostType)
	{
		// Lets validate if the post type exists and if so, continue.
		$postTypeModel = $this->getPostType($postType);
		if(!$postTypeModel){
    		$errorMessages = 'You are not authorized to do this.';
    		return $this->abort($errorMessages);
    	}

		// Check if the post type has a identifier
    	if(empty($postTypeModel->identifier)){
    		$errorMessages = 'The post type does not have a identifier.';
    		if(array_has($postTypeModel->errorMessages, 'post_type_identifier_does_not_exist')){
    			$errorMessages = $postTypeModel->errorMessages['post_type_identifier_does_not_exist'];
    		}
    		return $this->abort($errorMessages);
    	}

		$post = $this->findPostInstance($postTypeModel, $request, $postType, $id, 'show_post');
		if(!$post){
			$errorMessages = 'Post does not exist.';
			if(array_has($postTypeModel->errorMessages, 'post_does_not_exist')){
				$errorMessages = $postTypeModel->errorMessages['post_does_not_exist'];
			}
			return $this->abort($errorMessages);
		}

		// Lets get the post type of the sub post type object
		$subPostTypeModel = $this->getPostType($subPostType);
		if(!$subPostTypeModel){
			$errorMessages = 'You are not authorized to do this.';
    		if(array_has($postTypeModel->errorMessages, 'sub_post_type_does_not_exist')){
    			$errorMessages = $postTypeModel->errorMessages['sub_post_type_does_not_exist'];
    		}
    		return $this->abort($errorMessages);
		}

		$collection = collect([
			'objects' => $post->posts()->where('post_type', '=', $subPostTypeModel->identifier)->get()->toArray(),
		]);

		// Returning the full collection
		return response()->json($collection);
	}
994510
public function getObjectsByType($type, $subtype = null)
    {
        $objects = array();

        foreach ($this->objects as $id => $object) {
            if ($object->getHeader()->get('Type') == $type &&
                (is_null($subtype) || $object->getHeader()->get('Subtype') == $subtype)
            ) {
                $objects[$id] = $object;
            }
        }

        return $objects;
    }
1307356
public function setFeedType(?SubFeed $subFeed): void
    {
        if ($subFeed && !$subFeed->getFeedType()) {
            throw new \InvalidArgumentException('The feedType field must be specified on the subfeed.');
        }
        $this->feedTypeSubFeed = $subFeed;
    }
1204847
public static function export_gradingform_instance_data(\context $context, int $instanceid, array $subcontext) {
        static::_export_gradingform_instance_data($context, $instanceid, $subcontext);
    }
927920
protected function define_submission_subplugin_structure() {

        return false; // This subplugin backup is only one example. Skip it.

        // remember this has not XML representation
        $subplugin = $this->get_subplugin_element(null, '/assignment/assignmenttype', 'offline');

        // type of the subplugin, name of the subplugin and name of the connection point (recommended)
        $asssuboff = new backup_nested_element($this->get_recommended_name());
        // Why 'submission_config' name? Because it must be unique in the hierarchy and we
        // already are using 'config' above withing the same file
        $config = new backup_nested_element('submission_config', null, array('name', 'value'));

        $subplugin->add_child($asssuboff);
        $asssuboff->add_child($config);

        $config->set_source_table('config', array('id' => backup::VAR_PARENTID));

        return $subplugin; // And we return the root subplugin element
    }
586039
public function loadFile($filename, $subDir = null)
    {
        if (is_file($filename)) {
            if (strpos($filename, 'font') !== false) {
                $this->fonts->append($filename);
            } else {
                $type = pathinfo($filename, PATHINFO_EXTENSION);

                switch ($type) {
                    case 'css':
                        $this->styles->append($filename);
                        break;

                    case 'js':
                        $this->javascripts->append($filename);
                        break;
                }
            }
        } elseif (isset($subDir)) {
            $type = pathinfo($filename, PATHINFO_EXTENSION);

            if (empty($type)) {
                $type = substr($subDir, 0, -1);
            }

            switch ($type) {
                case 'css':
                    if (input()->env('DEBUG_STAGE') === 'PRODUCTION') {
                        if (false !== ($filePath = $this->getFilePath($filename . '.min.css', $subDir))) {
                            $this->styles->append($filePath);
                        }
                    } else {
                        if (false !== ($filePath = $this->getFilePath($filename . '.css', $subDir))) {
                            $this->styles->append($filePath);
                        }
                    }
                    break;

                case 'fonts':
                    if (input()->env('DEBUG_STAGE') === 'PRODUCTION') {
                        if (false !== ($filePath = $this->getFilePath($filename . '.min.css', $subDir))) {
                            $this->fonts->append($filePath);
                        }
                    } else {
                        if (false !== ($filePath = $this->getFilePath($filename . '.css', $subDir))) {
                            $this->fonts->append($filePath);
                        }
                    }
                    break;

                case 'js':
                    if (input()->env('DEBUG_STAGE') === 'PRODUCTION') {
                        if (false !== ($filePath = $this->getFilePath($filename . '.min.js', $subDir))) {
                            $this->styles->append($filePath);
                        }
                    } else {
                        if (false !== ($filePath = $this->getFilePath($filename . '.js', $subDir))) {
                            $this->styles->append($filePath);
                        }
                    }
                    break;
            }
        } else {
            $type = pathinfo($filename, PATHINFO_EXTENSION);

            if (empty($type)) {
                if (input()->env('DEBUG_STAGE') === 'PRODUCTION') {
                    // Search Style or Font
                    if (false !== ($filePath = $this->getFilePath($filename . '.min.css'))) {
                        $this->styles->append($filePath);
                    } elseif (false !== ($filePath = $this->getFilePath($filename . '.min.css'))) {
                        $this->fonts->append($filePath);
                    }

                    // Search Javascript
                    if (false !== ($filePath = $this->getFilePath($filename . '.min.js'))) {
                        $this->javascripts->append($filePath);
                    }
                } else {
                    // Search Style or Font
                    if (false !== ($filePath = $this->getFilePath($filename . '.css'))) {
                        $this->styles->append($filePath);
                    } elseif (false !== ($filePath = $this->getFilePath($filename . '.css'))) {
                        $this->fonts->append($filePath);
                    }

                    // Search Javascript
                    if (false !== ($filePath = $this->getFilePath($filename . '.js'))) {
                        $this->javascripts->append($filePath);
                    }
                }
            } else {
                switch ($type) {
                    case 'css':
                        if (false !== ($filePath = $this->getFilePath($filename))) {
                            $this->styles->append($filePath);
                        }
                        break;

                    case 'js':
                        if (false !== ($filePath = $this->getFilePath($filename))) {
                            $this->javascripts->append($filePath);
                        }
                        break;
                }
            }
        }
    }
125
public static function export_customfield_data(data_controller $data, array $subcontext) {
        $context = $data->get_context();

        $exportdata = $data->to_record();
        $exportdata->fieldtype = $data->get_field()->get('type');
        $exportdata->fieldshortname = $data->get_field()->get('shortname');
        $exportdata->fieldname = $data->get_field()->get_formatted_name();
        $exportdata->timecreated = \core_privacy\local\request\transform::datetime($exportdata->timecreated);
        $exportdata->timemodified = \core_privacy\local\request\transform::datetime($exportdata->timemodified);
        unset($exportdata->contextid);
        // Use the "export_value" by default for the 'value' attribute, however the plugins may override it in their callback.
        $exportdata->value = $data->export_value();

        $classname = manager::get_provider_classname_for_component('customfield_' . $data->get_field()->get('type'));
        if (class_exists($classname) && is_subclass_of($classname, customfield_provider::class)) {
            component_class_callback($classname, 'export_customfield_data', [$data, $exportdata, $subcontext]);
        } else {
            // Custom field plugin does not implement customfield_provider, just export default value.
            writer::with_context($context)->export_data($subcontext, $exportdata);
        }
    }
1183213
protected function is_valid_assignment_subplugin($type) {
        static $subplugins = null;

        if (is_null($subplugins)) {
            $subplugins = get_plugin_list('assignment');
        }
        return array_key_exists($type, $subplugins);
    }