taoceanz

I found Config::Inst()->get(MyClass::class, 'property'); would fail if the property didn't exist.

Oh yeah, good point about the dev build. If the table doesn't exist, return what the table should be.

taoceanz

It definitely returns something, at least.

taoceanz

Nice find @phyzical. Lol, this is from documentation of the tableName function. "Note that this does not confirm a table actually exists (or should exist), but returns the name that would be used if this table did exist."

taoceanz

I've thought to do Config::Inst()->get('\MyNamespace\IsWellNamed\MyClass', 'table_name'); but that isn't fool proof. Was hoping for an existing method within the framework to attain table name.

taoceanz

Is there a reliable way to get model's database table name from an ArrayList of classes, or to get the table name for a FQCN string, kinda like the opposite of SilverStripe/ORM/DataObjectSchema::tableClass($table)? e.g. classTable('\MyNamespace\IsWellNamed\MyClass')

  1. $my_class_instances = MyClass::get()->byIDs($my_ids)
  2. foreach (MyClass::get()->byIDs($my_ids) as $instance) {
  3. echo $instance->getTableName() . "\r\n";
  4. }
taoceanz

I've tried using Debug::message('Thing to log', false) and also tried setting up a logger ($this->logger->info('thing to log')), but nothing prints to the terminal. It prints to the browser window though via Debug::message.

taoceanz

During a dev/task, what's the best way to print text to the terminal running the task?

taoceanz

With a build task, what's the correct way to print status info as text to the terminal when running in cli while also printing to screen when running in browser? I've tried Debug::message and setting up the logger to run $this->logger->info though they're not printing anything to the terminal. echo or var_dump shouldn't be reasonable options, though they seem to be the most reliable to print to both cli and web.

taoceanz

Thanks for your help @theruss got the task sorted

👍 (1)