本文整理汇总了PHP中ArrayObject::serialize方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::serialize方法的具体用法?PHP ArrayObject::serialize怎么用?PHP ArrayObject::serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::serialize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
public function serialize()
{
foreach (new \ArrayIterator($this) as $index => $object) {
if ($object instanceof DisposableInterface && $object->isDisposed()) {
$this->offsetUnset($index);
}
}
return parent::serialize();
}
示例2: getComponentData
public function getComponentData()
{
$cachedData = new \ArrayObject(['test_component1' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name1' => ['value' => 'value1']], ManagerInterface::CHILDREN_KEY => ['custom' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['custom_name1' => ['value' => 'custom_value1']], ManagerInterface::CHILDREN_KEY => []]]]]);
return [['test_component1', new \ArrayObject(), $cachedData->serialize(), [], ['test_component1' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name1' => ['argument' => 'value1']], ManagerInterface::CHILDREN_KEY => ['custom' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['custom_name1' => ['argument' => 'custom_value1']], ManagerInterface::CHILDREN_KEY => []]]]]], ['test_component2', new \ArrayObject(['test_component2' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name2' => ['value' => 'value2']], ManagerInterface::CHILDREN_KEY => ['test_component21' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name21' => ['value' => 'value21']], ManagerInterface::CHILDREN_KEY => []]]]]), false, ['componentGroup' => [0 => [Converter::DATA_ARGUMENTS_KEY => ['argument_name2' => ['value' => 'value2']], Converter::DATA_ATTRIBUTES_KEY => ['name' => 'attribute_name2'], 'test_component21' => [0 => [Converter::DATA_ARGUMENTS_KEY => ['argument_name21' => ['value' => 'value21']], Converter::DATA_ATTRIBUTES_KEY => ['name' => 'attribute_name21']]]]]], ['test_component2' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name2' => ['argument' => 'value2']], ManagerInterface::COMPONENT_ATTRIBUTES_KEY => ['name' => 'attribute_name2'], ManagerInterface::CHILDREN_KEY => ['attribute_name21' => [ManagerInterface::COMPONENT_ARGUMENTS_KEY => ['argument_name21' => ['argument' => 'value21']], ManagerInterface::COMPONENT_ATTRIBUTES_KEY => ['name' => 'attribute_name21'], ManagerInterface::CHILDREN_KEY => []]]]]]];
}
示例3: serialize
/**
* overwrites the ArrayObject serialize function so that:
* - $container->serialize() will serialize only the data collection but not the object instance
* - serialize($container) will serialize the whole container instance
*
* @error 16308
* @return string
*/
public function serialize()
{
$debug = debug_backtrace();
if (is_array($debug) && array_key_exists('line', $debug[0])) {
return serialize($this->getArrayCopy());
} else {
$this->rewind();
return parent::serialize();
}
}
示例4: serialize
public function serialize()
{
return parent::serialize();
}
示例5: serialize
/**
* Hack to unset logger instance which cannot be serialized
*
* @return string
*/
public function serialize()
{
$logger = $this->_logger;
unset($this->_logger);
$result = parent::serialize();
$this->_logger = $logger;
return $result;
}
示例6: serialize
/**
* Serializes key values data and root section name
*/
public function serialize()
{
return serialize(array('data' => parent::serialize(), 'name' => $this->_name));
}
示例7: serialize
/**
* Serialization
* { @internal Don't serialze the connection }}
*
* @return array
*/
public function serialize()
{
if (isset($this->_connection)) {
$clone = clone $this;
unset($clone->_connection);
return $clone->serialize();
}
return parent::serialize();
}
示例8: serialize
/**
* Serialize an ArrayObject
* @return void The serialized representation of the <b>ArrayObject</b>.
*/
public function serialize()
{
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
return parent::serialize();
}
$serialized = serialize($this->getArrayCopy());
$serialized = 'x:i:0;' . $serialized . ';m:a:0:{}';
return $serialized;
}
示例9: testTraitImpartsSerializableInterface
/**
* @covers ::serialize
* @covers ::unserialize
* @dataProvider basicDataProvider()
*/
public function testTraitImpartsSerializableInterface(\ArrayObject $seedArray)
{
$serialString = $seedArray->serialize();
$mock = $this->getArrayObjectDecorator($seedArray);
$this->assertEquals($serialString, $mock->serialize());
$mock2 = $this->getArrayObjectDecorator(new \ArrayObject());
$mock2->unserialize($serialString);
$this->assertEquals($serialString, $mock2->serialize());
}
开发者ID:pbull,项目名称:acquia-platform-cloud-data-model,代码行数:14,代码来源:ArrayObjectImplementationMethodsTest.php
示例10: getDirectoryHash
/**
* Calculates an hash value for all files with certain extensions.
* This is used to test if the hash value changed, so if
* it changed, the appserver can react accordingly.
*
* @param \SplFileInfo $directory The directory to watch
*
* @return string The hash value build out of the found filenames
*/
protected function getDirectoryHash(\SplFileInfo $directory)
{
// prepare the array
$files = new \ArrayObject();
// prepare the array with the file extensions of the files used to build the hash
$extensionsToWatch = $this->getExtensionsToWatch();
// clear the cache
clearstatcache();
// add all files with the found extensions to the array
foreach (glob($directory . '/*.{' . implode(',', $extensionsToWatch) . '}', GLOB_BRACE) as $filename) {
$files->append($filename);
}
// calculate and return the hash value for the array
return md5($files->serialize());
}
示例11: ArrayObject
<?php
$dados = ['salmão', 'tilápia', 'sardinha', 'badejo', 'pescada', 'dourado', 'corvina', 'cavala', 'bagre'];
$objarray = new ArrayObject($dados);
$objarray->append('bacalhau');
print 'Posição 2: ' . $objarray->offsetGet(2) . '<br>' . PHP_EOL;
$objarray->offsetSet(2, 'linguado');
print 'Posição 2: ' . $objarray->offsetGet(2) . '<br>' . PHP_EOL;
$objarray->offsetUnset(4);
if ($objarray->offsetExists(10)) {
echo 'Posição 10 encontrada' . '<br>' . PHP_EOL;
} else {
echo 'Posição 10 não encontrada' . '<br>' . PHP_EOL;
}
print 'Total: ' . $objarray->count();
$objarray[] = 'atum';
$objarray->natsort();
print '<br>' . PHP_EOL;
foreach ($objarray as $item) {
print 'Item: ' . $item . '<br>' . PHP_EOL;
}
print $objarray->serialize();
示例12: getDirectoryHash
/**
* Calculates an hash value for all files with certain extensions.
* This is used to test if the hash value changed, so if
* it changed, the appserver can react accordingly.
*
* @param \SplFileInfo $directory The directory to watch
* @param array $extensionsToWatch The extensions we have to look for
*
* @return string The hash value build out of the found filenames
*/
protected function getDirectoryHash(\SplFileInfo $directory, array $extensionsToWatch)
{
// prepare the array
$files = new \ArrayObject();
// add all files with the found extensions to the array
foreach (new \DirectoryIterator($directory) as $fileInfo) {
if ($fileInfo->isFile() && in_array($fileInfo->getExtension(), $extensionsToWatch)) {
$files->append($fileInfo->getFilename());
}
}
// calculate and return the hash value for the array
return md5($files->serialize());
}
示例13: ArrayObject
<?php
$a = new ArrayObject(array(1, 2, 3));
$b = $a->serialize();
$c = new ArrayObject();
$d = $c->unserialize($b);
var_dump($a);
var_dump($c);
var_dump($d);
var_dump($a == $c);
示例14: serialize
/**
* Implementation of ArrayAccess::serialize()
*
* Returns a serialized ArrayObject.
*
* @return string The serialized representation of the ArrayObject.
*/
public function serialize()
{
return $this->arrayObject->serialize();
}