toArray

@param array $ignore

@return array
504101
public function toArray(
        $ignore = ['additionalDomains', 'domainValidator', 'site']
    ) {
        $data = parent::toArray($ignore);

        if (!in_array('siteId', $ignore)) {
            $data['siteId'] = $this->getSiteId();
        }

        if (!in_array('additionalDomains', $ignore)) {
            $data['additionalDomains'] = $this->modelArrayToArray(
                $this->getAdditionalDomains()->toArray(),
                ['additionalDomains', 'domainValidator', 'site']
            );
        }

        // @bc support
        if (!in_array('domain', $ignore)) {
            $data['domain'] = $this->getDomainName();
        }

        if (!in_array('isPrimary', $ignore)) {
            $data['isPrimary'] = $this->isPrimary();
        }

        if (!in_array('isPrimaryDomain', $ignore)) {
            $data['isPrimaryDomain'] = $this->isPrimaryDomain();
        }

        return $data;
    }
644429
public function toArray() : array {
        return [
            'command'   => $this->getCommand(),
            'running'   => $this->isRunning(),
            'info'      => $this->getInfo() ? $this->getInfo()->toArray() : null,
        ];
    }
495470
public function toArray($withNull = false)
    {
        $result = [];
        foreach (get_object_vars($this) as $property => $value) {
            $getter = 'get' . str_replace('_', '', $property);
            if (method_exists($this, $getter)) {
                $result[$property] = $this->{$getter}();
            } else {
                $result[$property] = $this->{$property};
            }
        }
        if ($withNull) {
            return $result;
        }

        return array_filter(
            $result, function ($value) {
            return isset($value);
        }
        );
    }
1134472
protected function convertExceptionToArray(Exception $exception): array
    {
        $errors = [
            'exception' => get_class($exception),
            'file' => $exception->getFile(),
            'line' => $exception->getLine(),
            'trace' => collect($exception->getTrace())->map(function ($trace) {
                return Arr::except($trace, ['args']);
            })->all(),
        ];

        return [
            'message' => $exception->getMessage() ?: 'Server error',
            'errors' => config('app.debug') ? $errors : [],
        ];
    }
1153987
public function toArray($ignoreEmpty = false)
    {
        if (!$ignoreEmpty) {
            return $this->data;
        }

        return array_filter(
            $this->data,
            function ($value) {
                return !empty($value);
            }
        );
    }
300811
public function toArray(array $options = null)
    {
        $array = [];

        foreach ($this->getResult() as $item) {
            if (method_exists($item, 'toArray')) {
                array_push($array, $item->toArray($options));
            } else {
                array_push($array, $item);
            }
        }

        return $array;
    }
1278315
public function toArray()
    {
        $ary = [];

        foreach ($this as $key => $value) {
            $ary[$key] = $value;
        }

        return $ary;
    }
80203
public static function toArray($value, $keepEmpty = false, $keepNull = false)
	{
		$array = [];

		foreach ($value as $k => $v)
		{
			$isDictionary = $v instanceof Dictionary;
			if ($v instanceof ConfigProvider)
			{
				$v = $v->asConfig();
			}
			elseif ($v instanceof Traversable || is_array($v))
			{
				$v = self::toArray($v, $keepEmpty, $keepNull);
			}
			elseif (is_scalar($v) || is_null($v))
			{
				// Do nothing
			}
			else
			{
				$type = (is_object($v))
				      ? 'an instance of ' . get_class($v)
				      : 'a ' . gettype($v);

				throw new RuntimeException('Cannot convert ' . $type . ' to array');
			}

			if (!isset($v) && !$keepNull)
			{
				// We don't record NULL values
				continue;
			}

			if (!$keepEmpty && $v === [])
			{
				// We don't record empty structures
				continue;
			}

			$array[$k] = ($isDictionary) ? new Dictionary($v) : $v;
		}

		return $array;
	}
45258
public function toArray(): array
    {
        return [
            "clientFilename" => $this->getClientFilename(),
            "unverifiedContentType" => $this->error ? "" : $this->getContentType(true),
            "verifiedContentType" => $this->error ? "" : $this->getContentType(),
            "size" => $this->error ? 0 : $this->getSize(),
            "tempPath" => $this->error ? "" : $this->getTempPath(),
            "error" => $this->error ? $this->error->getMessage() : "",
        ];
    }
981694
public function toArray($simplify = false): array
    {
        $r = [];
        foreach ($this as $key => $val) {
            $r[$key] = $val;
        }
        if ($simplify) {
            $r = array_filter($r);
        }

        return $r;
    }
189663
public function populate(array $data, array $ignore = ['createdByUserId', 'createdDate', 'createdReason'])
    {
        if (isset($data['site']) && $data['site'] instanceof Site
            && !in_array(
                'site',
                $ignore
            )
        ) {
            $this->setSite($data['site']);
        }

        if (isset($data['name']) && !in_array('name', $ignore)) {
            $this->setName($data['name']);
        }

        // @bc support
        if (isset($data['pageId']) && !in_array('pageId', $ignore)) {
            $this->setPageId($data['pageId']);
        }

        if (isset($data['pageTitle']) && !in_array('pageTitle', $ignore)) {
            $this->setPageTitle($data['pageTitle']);
        }

        if (isset($data['pageType']) && !in_array('pageType', $ignore)) {
            $this->setPageType($data['pageType']);
        }

        if (isset($data['description']) && !in_array('description', $ignore)) {
            $this->setDescription($data['description']);
        }

        if (isset($data['keywords']) && !in_array('keywords', $ignore)) {
            $this->setKeywords($data['keywords']);
        }

        if (isset($data['author']) && !in_array('author', $ignore)) {
            $this->setAuthor($data['author']);
        }

        if (isset($data['lastPublished'])
            && $data['lastPublished'] instanceof \DateTime
            && !in_array('lastPublished', $ignore)
        ) {
            $this->setLastPublished($data['lastPublished']);
        }

        if (isset($data['createdDate']) && $data['createdDate'] instanceof \DateTime
            && !in_array('createdDate', $ignore)
        ) {
            $this->setLastPublished($data['createdDate']);
        }

        if (isset($data['pageLayout']) && !in_array('pageLayout', $ignore)) {
            $this->setPageLayout($data['pageLayout']);
        }

        if (isset($data['siteLayoutOverride'])
            && !in_array(
                'siteLayoutOverride',
                $ignore
            )
        ) {
            $this->setSiteLayoutOverride($data['siteLayoutOverride']);
        }

        $parent = null;

        if (isset($data['parent']) && !in_array('parent', $ignore)) {
            $parent = $data['parent'];
        }

        if ($parent instanceof Page) {
            $this->setParent($parent);
        }
    }
1122567
public function toArray(array $allowed = null)
	{
		if ( ! $this->_toArray() || $this->isModified())
		{
			$response = $this->client->send((new Request($this->uri->withPath($this->uri->getPath().'trash/resources')
			                                                       ->withQuery(http_build_query(array_merge($this->getParameters($this->parametersAllowed), [
					'path' => $this->getPath()
				]), null, '&')), 'GET')));

			if ($response->getStatusCode() == 200)
			{
				$response = json_decode($response->getBody(), true);

				if ( ! empty($response))
				{
					$this->isModified = false;

					if (isset($response['_embedded']))
					{
						$response = array_merge($response, $response['_embedded']);
					}

					unset($response['_links'], $response['_embedded']);

					if (isset($response['items']))
					{
						$response['items'] = new Container\Collection(array_map(function($item) {
							return new self($item, $this->client, $this->uri);
						}, $response['items']));
					}
					
					$this->setContents($response);
				}
			}
		}

		return $this->_toArray($allowed);
	}
68779
public function toArray() : array
    {
        $result = [];

        if (!empty($this->id)) {
            $result['id'] = $this->id;
        }

        if (!empty($this->link)) {
            $result['links']['about'] = $this->link;
        }

        if (!empty($this->status)) {
            $result['status'] = "{$this->status}";
        }

        if (!empty($this->code)) {
            $result['code'] = "{$this->code}";
        }

        if (!empty($this->title)) {
            $result['title'] = $this->title;
        }

        if (!empty($this->detail)) {
            $result['detail'] = $this->detail;
        }

        if (!empty($this->source)) {
            $result['source'] = $this->source->map(function ($item) {
                return $item;
            });
        }

        if (!empty($this->meta)) {
            $result['meta'] = $this->meta;
        }

        if (!empty($this->exception)) {
            $e = $this->exception;
            if ($e instanceof ExtendedLoggingInformation) {
                $result['exception'] = $e->context();
            } else {
                $result['exception'] = [
                    'exception' => get_class($e),
                    'message' => $e->getMessage(),
                    'stacktrace' => $e->getTrace(),
                ];
            }
        }

        return $result;
    }
1222985
public function toArray($value)
    {
        if (empty($value)) {
            return null;
        }

        $output = [];
        foreach ($value as $val) {
            $output[] = $this->field->toArray($val);
        }

        return $output;
    }
852864
protected function convertToArray($data, $filter = 'raw')
    {
        $array = [];

        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $array[$key] = $this->convertToArray($value);
            } else {
                $array[$key] = $this->filter->clean($value, $filter);
            }
        }

        return $array;
    }
592004
public function populate(
        array $data,
        array $ignore = ['createdByUserId', 'createdDate', 'createdReason']
    ) {
        $prefix = 'set';

        foreach ($data as $property => $value) {
            // Check for ignore keys
            if (in_array($property, $ignore)) {
                continue;
            }

            $method = $prefix . ucfirst($property);

            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }
983346
function accessArray( $ignoreLimitIdentifier = false )
    {
        $accessArray = array();

        $policies = $this->attribute( 'policies' );
        foreach ( array_keys( $policies ) as $policyKey )
        {
            $accessArray = array_merge_recursive( $accessArray, $policies[$policyKey]->accessArray( $ignoreLimitIdentifier ) );
        }

        return $accessArray;
    }