Syncronise all file templates to the database.
@return void
482094
public static function syncAll()
    {
        MailLayout::createLayouts();
        MailPartial::createPartials();

        $templates = MailManager::instance()->listRegisteredTemplates();
        $dbTemplates = self::lists('is_custom', 'code');
        $newTemplates = array_diff_key($templates, $dbTemplates);

        /*
         * Clean up non-customized templates
         */
        foreach ($dbTemplates as $code => $isCustom) {
            if ($isCustom) {
                continue;
            }

            if (!array_key_exists($code, $templates)) {
                self::whereCode($code)->delete();
            }
        }

        /*
         * Create new templates
         */
        foreach ($newTemplates as $code) {
            $sections = self::getTemplateSections($code);
            $layoutCode = array_get($sections, 'settings.layout', 'default');
            $description = array_get($sections, 'settings.description');

            $template = self::make();
            $template->code = $code;
            $template->description = $description;
            $template->is_custom = 0;
            $template->layout_id = MailLayout::getIdFromCode($layoutCode);
            $template->forceSave();
        }
    }
1168678
private function publishTemplates()
    {
        if (!$this->fileSystem->isDirectory(getcwd().'/resources/crudmaker')) {
            $this->copyDirectory(__DIR__.'/../Templates/Lumen', getcwd().'/resources/crudmaker');
            $this->info("\n\nLumen templates files have been published");
        } else {
            $this->error('Lumen templates files has already been published');
        }
    }
1202206
protected function loadTemplates()
    {
        $templates = $this->templatesObjectBackend->loadObject();
        if (!is_array($templates)) {
            $templates = array();
        }
        
        $this->templates = $templates;
    }
480289
def sync_in_files(self, force=False):
        """"""
        self.log('---- Sync Files ----')

        self.dstate = self.STATES.BUILDING

        for f in self.build_source_files:

            if self.source_fs.exists(f.record.path):
                # print f.path, f.fs_modtime, f.record.modified, f.record.source_hash, f.fs_hash
                if f.fs_is_newer or force:
                    self.log('Sync: {}'.format(f.record.path))
                    f.fs_to_record()

        self.commit()
868401
protected function setupFile() {
		$this->_file->setNamespace($this->getNames()->namespace_model);

		$this->_file->setUse('Zend\Db\TableGateway\AbstractTableGateway');
		$this->_file->setUse('Zend\Db\TableGateway\Feature');
		$this->_file->setUse('Zend\Db\ResultSet\HydratingResultSet');
		$this->_file->setUse('Zend\Hydrator\Reflection');

		$this->_file->setUse('Zend\EventManager\EventManagerInterface');
		$this->_file->setUse('Zend\EventManager\EventManager');
		$this->_file->setUse('Zend\EventManager\SharedEventManager');
		$this->_file->setUse('Zend\EventManager\EventManagerAwareInterface');

		$this->_file->setUse('Zend\Paginator\Adapter\DbSelect');
		$this->_file->setUse('Zend\Paginator\Paginator');
		
		$this->_file->setUse('Zend\Db\Sql\Select');

		$this->_file->setUse("{$this->getNames()->namespace_entity}\\{$this->getNames()->entityName}");
	}
406164
public function afterCreateServer(): void
    {
        // load task data
        if (\is_file($this->dataFile)) {
            $this->server->data = \unserialize(\file_get_contents($this->dataFile), ['allowed_classes' => false]);
        } else {
            $this->server->data = [];
        }

        // $this->initCommands($this->server);
        $this->registerCommands($this->server);
    }
292445
protected function synchronizeConfigs(array $configFiles): void
	{
		foreach($configFiles as $variableName => $path) {
			$rowToAdd = $this->createRow($path);
			Helpers::appendToFile($this->configurationFile, $rowToAdd);
		}
	}
1051689
public function syncToMember()
    {
        $member = $this->Member();
        $sync = $this->config()->sync_fields;
        $write = false;

        if (!$member->exists()) {
            return;
        }

        foreach ($this->getChangedFields() as $field => $change) {
            // If this field is a field to sync, and it is different
            // then update member
            if (in_array($field, $sync) && $member->$field != $this->$field) {
                $member->$field = $this->$field;
                $write = true;
            }
        }

        if ($write) {
            $member->write();
        }
    }
820382
public function syncRaw()
    {
        if ($model = $this->fresh()) {
            $this->setRawAttributes($model->getAttributes());

            return true;
        }

        return false;
    }
524726
def sync(self):
        
        if self._customFormat:
            self._customFormat.save(self.fileName())
        else:
            super(XSettings, self).sync()
901811
public function execute() {
        global $DB;
        if (is_enabled_auth('ldap')) {
            $auth = get_auth_plugin('ldap');
            $users = $DB->get_records('user', array('auth' => 'ldap'));
            foreach ($users as $user) {
                $auth->sync_roles($user);
            }
        }
    }
564084
public function syncDatabase()
  {
    $tmpname = '/tmp/odango.php.cache';

    if (!file_exists($tmpname)) {
      $curl = new Curl();
      $curl->setOpt(CURLOPT_ENCODING, "gzip");
      $curl->download($this->titleDumpUrl, $tmpname);
      $curl->close();
    }

    $this->db->exec('START TRANSACTION');
    $this->db->exec('DELETE FROM ' . $this->table);

    $xml = simplexml_load_file($tmpname);
    foreach ($xml as $child) {
      $aid = (int)$child['aid'];
      $added = [];
      foreach($child->title as $title) {
        $type = (string)$title['type'];
        $lang = (string)$title->attributes('xml', true)['lang'];

        if ($lang == 'x-jat' || $lang == 'en') {

          if (!in_array((string)$title, $added)) {
            $added[] = (string)$title;

            $this->model->insert([
              'aniDbId'   => $aid,
              'title'     => (string)$title,
              'isDefault' => $type == 'main' ? 1 :0
            ]);
          } else if ( $type == 'main' ) {
            $this->model->update(['isDefault' => 1], 'AniDbId = '.$aid.' AND title = '.$this->db->quote((string)$title));
          }
        }
      }
    }

    $this->db->exec('COMMIT');
  }
921696
public function sync()
    {
        $this->sync_single_log($this->_messages, '');
        $this->sync_single_log($this->_debugs, '_debug');
        $this->sync_single_log($this->_errors, '_error');
    }
525901
protected function setCache()
    {
        if ($this->cache) {
            $cacheFile = $this->getCacheFile();
            file_put_contents($cacheFile, $this->templateOutput);
        }
    }
8415
protected function synchronizeIncludes(array $includes): void
	{
		foreach($includes as $include) {
			$rowToAdd = $this->createRow($include);
			Helpers::appendToFile($this->configurationFile, $rowToAdd);
		}
	}
1102746
public function sync()
    {
        $actionMap = $this->Guardian->getActionMap();

        // check existance of all permission entries for each individual group
        /** @var Query $groups */
        $groups = $this->GroupPermissions->Groups->find('all')
            ->where(['Groups.id <>' => 1]);// ignore Administrator group

        /** @var Connection $connection */
        $connection = $this->GroupPermissions->connection();
        $connection->begin();

        // delete guest actions
        $this->GroupPermissions->deleteAll([
            'path IN' => $this->Guardian->getGuestActions()
        ]);

        foreach ($groups as $group) {
            try {
                $this->GroupPermissions->createMissingPermissions($group->id, $actionMap);
                $this->GroupPermissions->deleteOrphans($group->id, $actionMap);
            } catch (Exception $e) {
                $connection->rollback();
            }
        }

        if ($connection->inTransaction()) {
            $connection->commit();
        }
        // delete guardian path cache
        $this->eventManager()->dispatch(new Event('Guardian.GroupPermissions.afterSync'));

        $this->Flash->success(__d('wasabi_core', 'All permissions have been synchronized.'));
        $this->redirect(['action' => 'index']);
        //@codingStandardIgnoreStart
        return;
        //@codingStandardIgnoreEnd
    }
246745
public function writeChanges()
    {
        foreach ($this->pendingOperations as $targetPath => $templateData) {
            if (isset($templateData['contents'])) {
                $this->fileManager->dumpFile($targetPath, $templateData['contents']);

                continue;
            }

            $this->fileManager->dumpFile(
                $targetPath,
                $this->getFileContentsForPendingOperation($targetPath, $templateData)
            );
        }

        $this->pendingOperations = [];
    }