Export a portable element to a zip package

@param PortableElementObject $object
@return string
@throws \common_Exception
976959
public function export(PortableElementObject $object)
    {
        $zip = new \ZipArchive();
        $path = $this->getZipLocation($object);

        if ($zip->open($path, \ZipArchive::CREATE) !== TRUE) {
            throw new \common_Exception('Unable to create zipfile ' . $path);
        }

        $manifest = $this->getManifest($object);
        $zip->addFromString($this->getModel()->getManifestName(), $manifest);

        $files = $this->getFilesFromPortableElement($object);

        $filesystem = $this->getFileSystem();
        foreach ($files as $file) {
            if(strpos($file, './') === 0){
                //only export the files that are in the portable element package (exclude the shared libraries)
                $zip->addFromString($file, $filesystem->getFileContentFromModelStorage($object, $file));
            }
        }

        $zip->close();
        return $path;
    }
1275612
protected function serializerFor($object): ObjectXmlSerializer
    {
        if (!annotationsOf($object)->contain('XmlSerializer')) {
            return AnnotationBasedObjectXmlSerializer::fromObject($object);
        }

        return $this->injector->getInstance(
                annotationsOf($object)
                        ->firstNamed('XmlSerializer')
                        ->getValue()
                        ->getName()
        );
    }
1113649
public function extract( $object )
    {
        $result = array();
        $type   = $object->paragraph->type;

        $result['paragraph-' . $type] = $this->getParagraphMapper()
                                             ->extract( $object->paragraph );

        $propertyHydrator = $this->getHydrateSimpleProperties();

        foreach ( $object->rules as $key => $rule )
        {
            $result['customize-' . $key] = $propertyHydrator->extract( $rule )
                                                              [ 'properties' ];
        }

        return $result;
    }
923924
protected function optimizeObjectContent($object)
	{
		$object = $this->recordObject($object);
		$this->deduplicateConfigValues();

		return $object->getValue();
	}
801902
protected static function objectToArray($object)
    {
        if (!\is_object($object)) {
            return $object;
        }

        if (\is_object($object)) {
            $object = \get_object_vars($object);
        }

        return \array_map(['static', 'objectToArray'], $object);
    }
1142411
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->javaPackage) && ($filter === null || isset($filter['javaPackage']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->javaPackage));
			$output .= $object->javaPackage;
		}

		if (isset($object->javaOuterClassname) && ($filter === null || isset($filter['javaOuterClassname']))) {
			$output .= "\x42";
			$output .= Binary::encodeVarint(strlen($object->javaOuterClassname));
			$output .= $object->javaOuterClassname;
		}

		if (isset($object->javaMultipleFiles) && ($filter === null || isset($filter['javaMultipleFiles']))) {
			$output .= "\x50";
			$output .= Binary::encodeVarint((int)$object->javaMultipleFiles);
		}

		if (isset($object->javaGenerateEqualsAndHash) && ($filter === null || isset($filter['javaGenerateEqualsAndHash']))) {
			$output .= "\xa0\x01";
			$output .= Binary::encodeVarint((int)$object->javaGenerateEqualsAndHash);
		}

		if (isset($object->javaStringCheckUtf8) && ($filter === null || isset($filter['javaStringCheckUtf8']))) {
			$output .= "\xd8\x01";
			$output .= Binary::encodeVarint((int)$object->javaStringCheckUtf8);
		}

		if (isset($object->optimizeFor) && ($filter === null || isset($filter['optimizeFor']))) {
			$output .= "\x48";
			$output .= Binary::encodeVarint($object->optimizeFor);
		}

		if (isset($object->goPackage) && ($filter === null || isset($filter['goPackage']))) {
			$output .= "\x5a";
			$output .= Binary::encodeVarint(strlen($object->goPackage));
			$output .= $object->goPackage;
		}

		if (isset($object->ccGenericServices) && ($filter === null || isset($filter['ccGenericServices']))) {
			$output .= "\x80\x01";
			$output .= Binary::encodeVarint((int)$object->ccGenericServices);
		}

		if (isset($object->javaGenericServices) && ($filter === null || isset($filter['javaGenericServices']))) {
			$output .= "\x88\x01";
			$output .= Binary::encodeVarint((int)$object->javaGenericServices);
		}

		if (isset($object->pyGenericServices) && ($filter === null || isset($filter['pyGenericServices']))) {
			$output .= "\x90\x01";
			$output .= Binary::encodeVarint((int)$object->pyGenericServices);
		}

		if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) {
			$output .= "\xb8\x01";
			$output .= Binary::encodeVarint((int)$object->deprecated);
		}

		if (isset($object->ccEnableArenas) && ($filter === null || isset($filter['ccEnableArenas']))) {
			$output .= "\xf8\x01";
			$output .= Binary::encodeVarint((int)$object->ccEnableArenas);
		}

		if (isset($object->objcClassPrefix) && ($filter === null || isset($filter['objcClassPrefix']))) {
			$output .= "\xa2\x02";
			$output .= Binary::encodeVarint(strlen($object->objcClassPrefix));
			$output .= $object->objcClassPrefix;
		}

		if (isset($object->csharpNamespace) && ($filter === null || isset($filter['csharpNamespace']))) {
			$output .= "\xaa\x02";
			$output .= Binary::encodeVarint(strlen($object->csharpNamespace));
			$output .= $object->csharpNamespace;
		}

		if (isset($object->javananoUseDeprecatedPackage) && ($filter === null || isset($filter['javananoUseDeprecatedPackage']))) {
			$output .= "\xb0\x02";
			$output .= Binary::encodeVarint((int)$object->javananoUseDeprecatedPackage);
		}

		if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) {
			foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) {
				$output .= "\xba\x3e";
				$buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
508560
public function prePersist($object)
    {
        /* @var $object MetaTagContent */
        $path = $this->getForm()->get('path')->getData();
        if (strpos('/', $path) !== false) {
            $path = '/'.$path;
        }
        try {
            $key = $this->keyGenerator->generateMetaTagKeyFromRelativePath($path, $this->getRouter(), $this->translator->getLocale());
            $object->setKeyword($key);
        } catch (\Exception $e) {
        }
    }
800690
public static function createAdapterObject($object)
    {
        $wrapperObject = self::create($object, null, function ($method, $arguments, $result) {
            $data['method']    = $method;
            $data['arguments'] = $arguments;

            $appType = php_sapi_name();
            if ($appType == 'cli') {
                $processName = @cli_get_process_title();
                if (strpos($processName, 'msf') !== false) {
                    $appType = 'msf';
                }
            } else {
                $appType = 'web';
            }

            if ($appType != 'msf' && $result instanceof \Generator) {
                $data['result'] = $result->getReturn();
                return $data;
            }

            $data['result'] = $result;
            return $data;
        });

        return $wrapperObject;
    }
1123119
public function extract($object)
    {
        if (!$object instanceof BlockEntityInterface) {
            throw new Exception\InvalidArgumentException(
                '$object must be an instance of PlaygroundCms\Entity\BlockInterface'
            );
        }

        /* @var $object BlockInterface*/
        $data = parent::extract($object);
        //$data = $this->mapField('id', 'block_id', $data);
        return $data;
    }
1342074
public function extract($object)
    {
        if (!$object instanceof ServerInfo) {
            throw new \Exception('$object must be an instance of ServerInfo');
        }
        /* @var $object ServerInfo */
        $data = parent::extract($object);

        return $data;
    }
417058
protected function getObjectString($object)/*# : string */
    {
        // exception found
        if ($object instanceof \Exception) {
            return 'EXCEPTION: ' . $object->getMessage();

        // toString() found
        } elseif (method_exists($object, '__toString')) {
            return (string) $object;

        // other type object
        } else {
            return 'OBJECT: ' . get_class($object);
        }
    }
986558
protected function normalize($object)
    {
        // If its a paginator instance, create a collection with its items.
        if ($object instanceof Paginator) {
            return collect($object->items());
        } elseif (is_array($object)) {
            // If its an array, package it in a collection.
            return collect($object);
        }

        return $object;
    }
1016717
public function unregisterFiles(PortableElementObject $object, $files)
    {
        $deleted = true;
        $filesystem = $this->getFileStorage();
        foreach ($files as $relPath) {
            $fileId = $this->getPrefix($object) . $relPath;
            if (!$filesystem->has($fileId)) {
                throw new \common_Exception('File does not exists in the filesystem: ' . $relPath);
            }
            $deleted = $filesystem->delete($fileId);
        }
        return $deleted;
    }
502795
protected function extractLabel($object)
    {
        if ($this->property) {
            if ($this->property instanceof \Closure) {
                return $this->property->__invoke($object);
            } else {
                return $this->accessor->getValue($object, $this->property);
            }
        } elseif (method_exists($object, '__toString')) {
            return (string)$object;
        } else {
            throw new \Exception('"choice_label" option or "__toString" method must be defined"');
        }
    }
969458
protected function getActorFromObject($object)
    {
        $entryObject = [null, null, null];

        if (is_object($object)) {
            $entryObject[2] = $object->getId();
            $pathParts      = explode('\\', get_class($object));
            $entryObject[1] = array_pop($pathParts);
            foreach ($pathParts as $pathPart) {
                if (strstr($pathPart, 'Bundle')) {
                    $entryObject[0] = $pathPart;
                    break;
                }
            }
        }

        return $entryObject;
    }
1239969
protected static function convert_object_to_array($object) {
	if (is_object($object) == false) {
		throw new \Exception('can only convert objects');
	}
	
	if ($object instanceof \alsvanzelf\jsonapi\resource) {
		return $object->get_array();
	}
	
	return get_object_vars($object);
}
822245
public function toItemUUID($object): ? ItemUUID
    {
        foreach ($this->writeTransformers as $writeTransformer) {
            if ($writeTransformer->isValidObject($object)) {
                return $writeTransformer->toItemUUID($object);
            }
        }

        return null;
    }