Get Data object from cache if is enabled.

@param  DataAbstract $data
@return bool|DataAbstract
194620
protected function getCache(DataAbstract $data)
    {
        if (!$this->isCacheEnabled) {
            return false;
        }

        return $this->cache->get($data->getCacheKey());
    }
439428
public function refresh(Data $data)
    {
        if ($data->isFresh()) {
            return $data;
        }

        return $this->find($data->id(true), $data);
    }
129120
protected function resolveQueueableEntities($data)
	{
		if (is_string($data))
		{
			return $this->resolveQueueableEntity($data);
		}

		if (is_array($data))
		{
			array_walk($data, function(&$d) { $d = $this->resolveQueueableEntity($d); });
		}

		return $data;
	}
883002
public function makeData(Data $data): ?DataObjectFormat
    {
        if (!$data->isInstanceOf(Data::class)) {
            return null;
        }

        return DataObjectFormat::make($data);
    }
695559
public function getData()
    {
        if (!Cache::has($this->cacheKey)) {
            $this->refreshCache();
        }

        return Cache::get($this->cacheKey);
    }
515048
public function putInCache($data)
    {
        if (!$data) {
            throw new CacheException("No data provided for storing in the cache");
        }

        $serializationEnabled = static::config('serialize');

        if(!$serializationEnabled && !is_scalar($data)) {
            throw new CacheException("Trying to store non-scalar data with serialization disabled");
        }

        $data = $serializationEnabled ? serialize($data) : $data;


        if($this->isCached() && !is_writable($this->filePath())) {
            throw new CacheException(sprintf("File '%s' is not writable", $this->filePath()));
        }

        $success = file_put_contents($this->filePath(), $data);

        if ($success === false) {
            throw new CacheException("Couldn't write to file: {$this->file}");
        } 

        return true;
    }
24312
public function getOrFail($data, $with = [], $cache = false)
    {
        return $this->get($data, $with, $cache, true);
    }
334655
public function takeData($data)
    {
        if ($this->debug === true) {
            $fbRelations = [];
            $fbColumns   = $this->getColumnsInfo();
            foreach ($this->getRelationsInfo() as $relation) {
                if (is_array($relation) && isset($relation['url'])) {
                    $fbRelations[$relation['url']] = $relation['url'];
                }
            }
            if (count($fbColumns)) {
                foreach ($data as $key => $value) {
                    if (!array_key_exists($key, $fbColumns)) {

                        if (!array_key_exists($key, $fbRelations)) {
                            $this->addStatusMessage(sprintf('unknown column %s for evidence %s',
                                    $key, $this->getEvidence()), 'warning');
                        } else {
                            if (!is_array($value)) {
                                $this->addStatusMessage(sprintf('subevidence %s in evidence %s must bee an array',
                                        $key, $this->getEvidence()), 'warning');
                            }
                        }
                    }
                }
            }
        }
        return parent::takeData($data);
    }
348017
protected function handleCorruptCache($data)
    {
        $path = array_get($data, 'filePath', $this->getCacheFilePath());

        if (is_file($path)) {
            if (($className = $this->extractClassFromFile($path)) && class_exists($className)) {
                $data['className'] = $className;
                return $data;
            }

            @unlink($path);
        }

        unset(self::$cache[$this->filePath]);

        return $this->parse();
    }
325720
public function get($url, $data = null)
    {
        if ($this->cache) {
            $result = $this->cache->get($url, array('$data' => $data));
            if (array_key_exists('$data', (array)$result)) {
                return $this->response_data($result, 'get', $url);
            }
        }

        return $this->request('get', $url, $data);
    }
782928
public function process(DataObjectInterface $data = null)
    {
        if ( ! is_null($data)) {
            $this->data = $data;
        }

        $this->before();

        $this->doProcessing();

        $this->after();

        return $this->getResult();
    }
188431
private function unserialize($data)
    {
        if ($this->type == 'db') {
            return $this->db->decode($data, $this->packed);
        }

        return $this->packed ? @unserialize($data) : $data;
    }
1107893
public function checkData($data)
    {
        $class_name = $this->getTypeClassName();

        if (!$data instanceof $class_name) {
            $data = $this->createObjectFrom($data);
        }

        return $data;
    }
891323
private function getManager($data): ?DoctrineObjectManager
    {
        return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
    }
456228
public function filter_data_for_persistent($data) {
        $data = parent::filter_data_for_persistent($data);

        $classname = static::$persistentclass;
        $properties = $classname::properties_definition();

        $data = (object) array_filter((array) $data, function($value, $key) use ($properties) {
            return isset($properties[$key]);
        }, ARRAY_FILTER_USE_BOTH);

        return $data;
    }
203905
protected function seeSuccessData($data = null)
    {
        collect($data)->each(function ($value, $key) {
            if (is_array($value)) {
                $this->seeSuccessData($value);
            } else {
                $this->seeJson([$key => $value]);
            }
        });

        return $this;
    }
148639
public function initByData( array $data = null )
    {

        if( !$data ) {
            return null;
        }

        // table inheritance - ghetto?
        /*
        if( isset( $data['tableoid'] ) ) {
            if( $data['tableoid'] != static::OID ) {
                $repo = Repository::init( $data['tableoid'] );
                return $repo->initByData( $data );
            }
            unset( $data['tableoid'] );
        }
        */

        $key = call_user_func(
            array( $this->entityClass, 'keyGet' ),
            $data
        );

        // is this already in the cache? Are we initalising something we've already loaded?
        if( isset( $this->instancesPersisted[$key] ) ) {

            // Late loading? Don't need this anymore.
            $obj = $this->instancesPersisted[$key];
            $obj->__construct( $data );
            return $obj;

        }

        $obj = parent::initByData($data);
        $this->instancesPersisted[$key] = $obj;

        return $obj;

    }