storePluginYamlData

The method $this->storePluginYamlData(string $filename, array $data) is used to store YAML formatted data for the plugin. It validates the provided data against the plugin's field definitions and then updates the YAML file with the new data.

  • @param: (string) $filename. The name of the file to store the YAML data.
  • @param: (array) $data. The YAML data to be stored.
  • @return: (true|string|array) Returns true if the data is successfully stored. Returns an error message if an error occurs during the storage process. Returns an array of validation errors if the provided data does not pass validation.

Example Usage

<?php

namespace Plugins\Myplugin;

use \Typemill\Plugin;

class Myplugin extends Plugin
{
    ...

    public function myFunction()
    {
       $this->storePluginYamlData('config.yaml', ['key' => 'value']);
    }
}