<?php

return [
  'pattern' => '(:all)save-page.json',
  'method' => 'POST',
  'action'  => function () {
      $json = file_get_contents('php://input');
      $data = json_decode($json);

      $page = page($data->pageUri);

      $newProperties = [];

      foreach ($data->properties as $incomingProperty) {
        $newProperties[$incomingProperty->name] = $incomingProperty->value;
      }

      $newPage = $page->update($newProperties);

      return json_encode($newProperties);
  }
];