@param string $seed_key

@return bool|array
@throws BlendableException
171724
protected function loadObjectDataFromSeed($seed_key)
    {
        $data = $this->modx->cacheManager->get($seed_key, $this->seedCacheOptions);
        if ($data == false) {
            if ($this->type == 'blend') {
                $this->blender->outError('Error: Seed could not be found: '.$seed_key);
                throw new BlendableException('Error: Seed could not be found: '.$seed_key . ' in '. print_r($this->seedCacheOptions, true));
            }

        } else {
            $this->blendable_xpdo_simple_object_data = $data['columns'];
            $this->unique_key_history = $data['primaryKeyHistory'];
            $this->related_data = $data['related'];
        }

        return $data;
    }
861963
public function get($key, $default_value = null, $index_name = null)
	{

		list($index_name_x, $key) = $this->normalizeAccessKey($key, $index_name);

		if (!empty($index_name_x)) {
			$index_name = $index_name_x;
		}

		if (array_key_exists($index_name, $this->items)) {
			return $this->evaluate($this->walkConfig($this->items[$index_name], $key, $default_value));
		} else {
			return $this->evaluate($default_value);
		}
	}
508623
protected function blendOneFromMany($blendable, $seed_key, $object_type, $seeds_dir, $overwrite = false)
    {
        if (!empty($seeds_dir)) {
            $blendable->setSeedsDir($seeds_dir);
        }

        if ($success = $blendable->blendFromSeed($seed_key, $overwrite)) {
            $this->blender->outSuccess($seed_key.' ' . $object_type . ' has been blended into primary key: ' .
                $blendable->getXPDOSimpleObject()->getPrimaryKey());

        } elseif ($blendable->isExists()) {
            $this->blender->outError($seed_key.' ' . $object_type .' already exists');
            if ($this->userInteractionHandler->promptConfirm('Would you like to update?', true)) {
                if ($success = $blendable->blendFromSeed($seed_key, true)) {
                    $this->blender->out($seed_key.' has been blended');
                }
            }

        } else {
            $this->blender->outError('There was an error saving the ' . $object_type . ' for seed key '. $seed_key);
        }

        return $success;
    }
131272
function (key, seed) {
      key = key || ''
      seed = seed || 0
      var remainder = key.length % 16
      var bytes = key.length - remainder
      var h1 = [0, seed]
      var h2 = [0, seed]
      var k1 = [0, 0]
      var k2 = [0, 0]
      var c1 = [0x87c37b91, 0x114253d5]
      var c2 = [0x4cf5ad43, 0x2745937f]
      for (var i = 0; i < bytes; i = i + 16) {
        k1 = [((key.charCodeAt(i + 4) & 0xff)) | ((key.charCodeAt(i + 5) & 0xff) << 8) | ((key.charCodeAt(i + 6) & 0xff) << 16) | ((key.charCodeAt(i + 7) & 0xff) << 24), ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24)]
        k2 = [((key.charCodeAt(i + 12) & 0xff)) | ((key.charCodeAt(i + 13) & 0xff) << 8) | ((key.charCodeAt(i + 14) & 0xff) << 16) | ((key.charCodeAt(i + 15) & 0xff) << 24), ((key.charCodeAt(i + 8) & 0xff)) | ((key.charCodeAt(i + 9) & 0xff) << 8) | ((key.charCodeAt(i + 10) & 0xff) << 16) | ((key.charCodeAt(i + 11) & 0xff) << 24)]
        k1 = x64Multiply(k1, c1)
        k1 = x64Rotl(k1, 31)
        k1 = x64Multiply(k1, c2)
        h1 = x64Xor(h1, k1)
        h1 = x64Rotl(h1, 27)
        h1 = x64Add(h1, h2)
        h1 = x64Add(x64Multiply(h1, [0, 5]), [0, 0x52dce729])
        k2 = x64Multiply(k2, c2)
        k2 = x64Rotl(k2, 33)
        k2 = x64Multiply(k2, c1)
        h2 = x64Xor(h2, k2)
        h2 = x64Rotl(h2, 31)
        h2 = x64Add(h2, h1)
        h2 = x64Add(x64Multiply(h2, [0, 5]), [0, 0x38495ab5])
      }
      k1 = [0, 0]
      k2 = [0, 0]
      switch (remainder) {
        case 15:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 14)], 48))
        // fallthrough
        case 14:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 13)], 40))
        // fallthrough
        case 13:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 12)], 32))
        // fallthrough
        case 12:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 11)], 24))
        // fallthrough
        case 11:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 10)], 16))
        // fallthrough
        case 10:
          k2 = x64Xor(k2, x64LeftShift([0, key.charCodeAt(i + 9)], 8))
        // fallthrough
        case 9:
          k2 = x64Xor(k2, [0, key.charCodeAt(i + 8)])
          k2 = x64Multiply(k2, c2)
          k2 = x64Rotl(k2, 33)
          k2 = x64Multiply(k2, c1)
          h2 = x64Xor(h2, k2)
        // fallthrough
        case 8:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 7)], 56))
        // fallthrough
        case 7:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 6)], 48))
        // fallthrough
        case 6:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 5)], 40))
        // fallthrough
        case 5:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 4)], 32))
        // fallthrough
        case 4:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 3)], 24))
        // fallthrough
        case 3:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 2)], 16))
        // fallthrough
        case 2:
          k1 = x64Xor(k1, x64LeftShift([0, key.charCodeAt(i + 1)], 8))
        // fallthrough
        case 1:
          k1 = x64Xor(k1, [0, key.charCodeAt(i)])
          k1 = x64Multiply(k1, c1)
          k1 = x64Rotl(k1, 31)
          k1 = x64Multiply(k1, c2)
          h1 = x64Xor(h1, k1)
        // fallthrough
      }
      h1 = x64Xor(h1, [0, key.length])
      h2 = x64Xor(h2, [0, key.length])
      h1 = x64Add(h1, h2)
      h2 = x64Add(h2, h1)
      h1 = x64Fmix(h1)
      h2 = x64Fmix(h2)
      h1 = x64Add(h1, h2)
      h2 = x64Add(h2, h1)
      return ('00000000' + (h1[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h1[1] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[0] >>> 0).toString(16)).slice(-8) + ('00000000' + (h2[1] >>> 0).toString(16)).slice(-8)
    }
94675
private function _seed()
    {
        list($usec, $sec) = explode(' ', microtime());
        $a                = (float) $sec + ((float) $usec * 100000);

        return (float) $a + $this->config->kernel->security->cryptography->keys->private;
    }
523220
public function makeChunkSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true)
    {
        $keys = [];
        $collection = $this->modx->getCollection('modChunk', $criteria);

        foreach ($collection as $chunk) {
            /** @var \LCI\Blend\Blendable\Chunk $blendChunk */
            $blendChunk = new Chunk($this->modx, $this->blender, $chunk->get('name'));
            $seed_key = $blendChunk
                ->setSeedsDir($this->format->getMigrationName('chunk', $name))
                ->seed();
            $this->blender->out("Chunk: ".$chunk->get('name').' Key: '.$seed_key);
            $keys[] = $seed_key;
        }

        if ($create_migration_file) {
            /** @var MigrationsCreator $migrationCreator */
            $migrationCreator = new MigrationsCreator($this->blender->getUserInteractionHandler(), $keys);

            $migrationCreator
                ->setPathTimeStamp($this->format->getPathTimeStamp())
                ->setVerbose($this->blender->getVerbose())
                ->setName($name)
                ->setDescription('')
                ->setServerType($server_type)
                ->setMigrationsPath($this->blender->getMigrationPath())
                ->createChunkMigrationClassFile();

            $this->logCreatedSeedMigration($migrationCreator->getLogData());
        }
        return $keys;
    }
330092
public static function wrapped_session_get($session_object,$key,$default=null)
    {
        global $TSUGI_SESSION_OBJECT;
        if ( $session_object === null && isset($TSUGI_SESSION_OBJECT) ) $session_object = $TSUGI_SESSION_OBJECT;
        if ( is_object($session_object) ) {
            return $session_object->get($key,$default);
        }
        if ( is_array($session_object) ) {
            if ( isset($session_object[$key]) ) return $session_object[$key];
            return $default;
        }
        if ( ! isset($_SESSION) ) return $default;
        if ( ! isset($_SESSION[$key]) ) return $default;
        return $_SESSION[$key];
    }
495162
public function makeTemplateSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true)
    {
        $keys = [];
        $collection = $this->modx->getCollection('modTemplate', $criteria);

        foreach ($collection as $template) {
            //exit();
            /** @var \LCI\Blend\Blendable\Template $blendTemplate */
            $blendTemplate = new Template($this->modx, $this->blender, $template->get('templatename'));
            $seed_key = $blendTemplate
                ->setSeedsDir($this->format->getMigrationName('template', $name))
                ->seed();
            $this->blender->out("Template ID: ".$template->get('id').' Key: '.$seed_key);
            $keys[] = $seed_key;
        }

        if ($create_migration_file) {
            /** @var MigrationsCreator $migrationCreator */
            $migrationCreator = new MigrationsCreator($this->blender->getUserInteractionHandler(), $keys);

            $migrationCreator
                ->setPathTimeStamp($this->format->getPathTimeStamp())
                ->setVerbose($this->blender->getVerbose())
                ->setName($name)
                ->setDescription('')
                ->setServerType($server_type)
                ->setMigrationsPath($this->blender->getMigrationPath())
                ->createTemplateMigrationClassFile();

            $this->logCreatedSeedMigration($migrationCreator->getLogData());
        }
        return $keys;
    }
1189505
private function createCacheFile($key)
    {
        $cache_file = $this->path($key);
        if (!file_exists($cache_file)) {
            $directory = dirname($cache_file);
            if (!is_dir($directory)) {
                $make_dir_result = mkdir($directory, 0755, true);
                if ($make_dir_result === false) {
                    return false;
                }
            }
            $create_result = touch($cache_file);
            if ($create_result === false) {
                return false;
            }
        }

        return $cache_file;
    }
339012
public function cacheGet($key, $cache_mode = Cache::CACHE_AUTO)
    {
        if ($cache_mode === Cache::CACHE_FLUSH_ONLY ) {
            $this->getCache()->remove($key);
            return null;
        }
        
        return $this->getCache()->get($key);
    }
156524
protected function &searchTree(
        /*# string */ $key,
        /*# array */ &$tree,
        /*# bool */ $create = false
    ) {
        $found = &$tree;
        $parts = explode($this->field_splitter, $key);
        while (null !== ($part = array_shift($parts))) {
            if (!isset($found[$part])) {
                if ($create) {
                    $found[$part] = [];
                } else {
                    $bad = null;
                    return $bad;
                }
            }
            $found = &$found[$part];
        }
        return $found;
    }
88170
public function getResourceFromSeedKey($seed_key, $context = 'web')
    {
        // get the alias:
        $alias = $this->blender->getAliasFromSeedKey($seed_key);

        return $this->modx->getObject('modResource', ['alias' => $alias, 'context_key' => $context]);
    }
1025382
public static function generateKeys($seed = null, $hashKey = '')
    {
        # The keys are being generated from a seed.
        if ($seed !== null) {
            # Generate some repeatable hashes to create keys against for recovery
            $encrHash = Hash::hash($seed, $hashKey, Constants::BOX_SEEDBYTES);
            $signHash = Hash::hash($seed, $hashKey, Constants::SIGN_SEEDBYTES);

            # Build recoverable pre-seeded key pairs.
            $seeds = [
                'encr' => \Sodium\crypto_box_keypair($encrHash),
                'sign' => \Sodium\crypto_sign_keypair($signHash),
            ];
        } else {
            # Build un-recoverable key pairs.
            $seeds = [
                'encr' => \Sodium\crypto_box_keypair(),
                'sign' => \Sodium\crypto_sign_keypair(),
            ];
        }

        # Return the two generated key pairs to the client.
        return [
            'encr' => [
                'pri' => Helpers::bin2hex(\Sodium\crypto_box_secretkey($seeds['encr'])),
                'pub' => Helpers::bin2hex(\Sodium\crypto_box_publickey($seeds['encr'])),
            ],
            'sign' => [
                'pri' => Helpers::bin2hex(\Sodium\crypto_sign_secretkey($seeds['sign'])),
                'pub' => Helpers::bin2hex(\Sodium\crypto_sign_publickey($seeds['sign'])),
            ],
        ];
    }
1095852
public function makeContextSeeds($criteria, $server_type = 'master', $name = null, $create_migration_file = true)
    {
        $keys = [];
        $collection = $this->modx->getCollection('modContext', $criteria);

        foreach ($collection as $context) {
            /** @var Context $blendContext */
            $blendContext = new Context($this->modx, $this->blender, $context->get('key'));
            $seed_key = $blendContext
                ->setSeedsDir($this->format->getMigrationName('context', $name))
                ->seed();
            $this->blender->out("Context: ".$context->get('name').' Key: '.$seed_key);
            $keys[] = $seed_key;
        }

        if ($create_migration_file) {
            /** @var MigrationsCreator $migrationCreator */
            $migrationCreator = new MigrationsCreator($this->blender->getUserInteractionHandler(), $keys);

            $migrationCreator
                ->setPathTimeStamp($this->format->getPathTimeStamp())
                ->setVerbose($this->blender->getVerbose())
                ->setName($name)
                ->setDescription('')
                ->setServerType($server_type)
                ->setMigrationsPath($this->blender->getMigrationPath())
                ->createContextMigrationClassFile();

            $this->logCreatedSeedMigration($migrationCreator->getLogData());
        }
        return $keys;
    }
877411
protected function get_index_from_key($key) {
        if (isset(self::$lockidcache[$key])) {
            return self::$lockidcache[$key];
        }

        $index = 0;
        $record = $this->db->get_record('lock_db', array('resourcekey' => $key));
        if ($record) {
            $index = $record->id;
        }

        if (!$index) {
            $record = new \stdClass();
            $record->resourcekey = $key;
            try {
                $index = $this->db->insert_record('lock_db', $record);
            } catch (\dml_exception $de) {
                // Race condition - never mind - now the value is guaranteed to exist.
                $record = $this->db->get_record('lock_db', array('resourcekey' => $key));
                if ($record) {
                    $index = $record->id;
                }
            }
        }

        if (!$index) {
            throw new \moodle_exception('Could not generate unique index for key');
        }

        self::$lockidcache[$key] = $index;
        return $index;
    }
570097
public function getSessionData($key = null, $default_value = null)
	{
		if (!$this->remember_state) {
			return $key ? $default_value : [];
		}

		return ($key ? $this->grid_session->{$key} : $this->grid_session) ?: $default_value;
	}
1343584
public function createEmbedFor($key)
    {
        if (false === $this->isEmbed($key)) {
            throw new \RuntimeException(sprintf('Unable to create an Embed instance for property key "%s" - the property is not an embed.', $key));
        }

        $embedMeta = $this->getMetadata()->getEmbed($key)->embedMeta;
        $embed = $this->getStore()->loadEmbed($embedMeta, []);
        $embed->getState()->setNew();
        return $embed;
    }