---------------------------------------------------------------------------
785
function replaceInFile (filename, regex, replacement) {
    let contents = fs.readFileSync (filename, 'utf8')
    const parts = contents.split (regex)
    const newContents = parts[0] + replacement + parts[1]
    fs.truncateSync (filename)
    fs.writeFileSync (filename, newContents)
}
810772
public function initialize()
    {
        if ($this->initialized || ! $this->association) {
            return;
        }

        $this->doInitialize();

        $this->initialized = true;
    }
835651
public function count() {
		if ($this->count === null) {
			$groupPart = $this->select->getPart(Select::GROUP);
			
			$select = empty($groupPart)
				? $this->prepareSelect(clone $this->select)
				: $this->prepareSubquerySelect(clone $this->select);
			
			$this->count = (int) $select->query(PDO::FETCH_OBJ)->fetch()->{self::COUNT_COLUMN};
		}
		
		return $this->count;
	}
670056
public function init()
    {
        parent::init();

        if (is_array($this->pager) && !ArrayHelper::keyExists('class', $this->pager)) {
            $this->pager = [
                'class' => LinkPager::class,
            ];
        }
    }
395675
public function init()
    {
        if ($this->widget !== null) {
            $this->widget->init();
        }

        // ensure the widget has an id
        if ($this->widget->id === null) {
            $this->widget->id = $this->widget->getUniqueId();
        }
    }
25372
public function init()
    {
        parent::init();

        $relations = [];

        foreach ($this->relations as $i => $relation) {
            if (key_exists('name', $relation)) {
                $name = $relation['name'];
            } else {
                $name = $i;
            }

            $name = $this->prepareRelationName($name);

            $relation['name'] = $name;
            $relations[$name] = $relation;
        }

        $this->relations = $relations;
    }
439901
public function initializeObject()
    {
        if ($this->cache->has('fractions')) {
            $this->fractions = $this->cache->get('fractions');
        } else {
            $this->generateFractions();
            $this->cache->set('fractions', $this->fractions);
        }
    }
649406
protected function initItems()
	{
		$initItems = null;
		
		if ($this->items != null)
		{
			foreach ($this->items as $item)
			{
				if (isset($item['value']))
				{
					$i = $item['value'];
					unset($item['value']);
					$initItems[$i] = $item;
				}
				else 
				{
					$initItems = $this->items;	
				}
			}
			
			$this->items = array_replace($this->defaults, $initItems);
		}
		else 
		{
			$this->items = $this->defaults;
		}
	}
1142015
public function init()
    {
        parent::init();

        if (!$this->our_field) {
            $this->our_field = $this->link;
        }

        if (!$this->owner->hasField($this->our_field)) {
            $this->owner->addField($this->our_field, [
                'type'              => $this->type,
                'reference'         => $this,
                'system'            => $this->system,
                'join'              => $this->join,
                'default'           => $this->default,
                'never_persist'     => $this->never_persist,
                'read_only'         => $this->read_only,
                'caption'           => $this->caption,
                'ui'                => $this->ui,
                'mandatory'         => $this->mandatory,
                'required'          => $this->required,
                'typecast'          => $this->typecast,
                'serialize'         => $this->serialize,
                'persist_format'    => $this->persist_format,
                'persist_timezone'  => $this->persist_timezone,
                'dateTimeClass'     => $this->dateTimeClass,
                'dateTimeZoneClass' => $this->dateTimeZoneClass,
            ]);
        }
    }
1306724
public function initialize()
    {
        if (null !== $this->collection) {
            return;
        }

        if (empty($this->dbOptions['database'])) {
            throw new \RuntimeException('The option "database" must be set');
        }
        if (empty($this->dbOptions['collection'])) {
            throw new \RuntimeException('The option "collection" must be set');
        }

        $this->collection = $this
            ->mongo
            ->selectDB($this->dbOptions['database'])
            ->selectCollection($this->dbOptions['collection']);
    }
1336043
public function commit()
  {
    if (!is_null($this->_changes)) {
      $this->_commit($this->_changes);

      $this->_changes = null;
    }
  }
1112419
public function init() {
        $this->cachePath = PathUtility::mapPath($this->config->cachePath);
        $this->accessTime = (isset($this->config->accessTime) ? (int)$this->config->accessTime : 100) * 1000;
        $this->hash = (isset($this->config->hash) ? $this->config->hash : null);
    }
303001
public void execute() {
		Iterator it = memberList.iterator();
		while (it.hasNext()) {
			GroupMember member = (GroupMember) it.next();
			member.getCommand().execute();
		}
	}
289667
public function init() {

		parent::init();

		// Views
		$this->setViewPath( '@cmsgears/module-community/admin/views/group/member' );

		// Permission
		$this->crudPermission = CmnGlobal::PERM_GROUP_ADMIN;

		// Services
		$this->modelService = Yii::$app->factory->get( 'groupMemberService' );

		$this->parentService = Yii::$app->factory->get( 'groupService' );

		$this->userService		= Yii::$app->factory->get( 'userService' );
		$this->memberService	= Yii::$app->factory->get( 'siteMemberService' );

		$this->roleService	= Yii::$app->factory->get( 'roleService' );

		// Super Admin
		$superRole = $this->roleService->getBySlugType( CoreGlobal::ROLE_SUPER_ADMIN, CoreGlobal::TYPE_SYSTEM );

		$this->superRoleId = isset( $superRole ) ?$superRole->id : null;
	}
1116651
public function init()
    {
        $this->userService = $this->di->get("userService");
        $this->session = $this->di->get("session");
        $this->response = $this->di->get("response");
        $this->view = $this->di->get("view");
        $this->pageRender = $this->di->get("pageRender");
    }
1315126
public function onBeforeWrite()
    {
        $owner = $this->owner;
        if(!$owner->ID && !$owner->SubsiteID){
            $owner->SubsiteID = Subsite::currentSubsiteID();
        }
        parent::onBeforeWrite();
    }
836456
public function init()
    {
        parent::init();
        if (!isset($this->translations['yii']) && !isset($this->translations['yii*'])) {
            $this->translations['yii'] = [
                '__class' => PhpMessageSource::class,
                'sourceLanguage' => 'en-US',
                'basePath' => '@yii/messages',
            ];
        }

        if (!isset($this->translations['app']) && !isset($this->translations['app*'])) {
            $this->translations['app'] = [
                '__class' => PhpMessageSource::class,
                'sourceLanguage' => $this->app->sourceLanguage,
                'basePath' => '@app/messages',
            ];
        }
    }